plot.saeTrafo {saeTrafo}R Documentation

Plots for an saeTrafo object

Description

Diagnostic plots of the nested error regression model (see also NER_Trafo) are obtained. These include Q-Q plots and density plots of residuals and random effects, a Cook's distance plot for detecting outliers and the log-likelihood of the estimation of the optimal parameter in log-shift transformations. The return depends on the transformation, such that a plot for the optimal parameter is only returned in case if a transformation with transformation parameter is chosen. The range of the x-axis is optional but necessary to change if there are convergence problems. All plots are obtained by ggplot.

Usage

## S3 method for class 'saeTrafo'
plot(
  x,
  label = "orig",
  color = c("blue", "lightblue3"),
  gg_theme = NULL,
  cooks = TRUE,
  range = NULL,
  ...
)

Arguments

x

an object of type "NER", representing point and, if chosen, MSE estimates obtained by the (transformed) nested error regression model (see also NER_Trafo).

label

argument that enables to customize title and axis labels. There are three instant options to label the diagnostic plot: (i) original labels ("orig"), (ii) axis lables but no title ("no_title"), (iii) neither axis labels nor title ("blank"), (iv) individual labels by a list that needs to have below structure. Six elements can be defined called qq_res, qq_ran, d_res, d_ran, cooks and opt_lambda for the six different plots and these list elements need to have three elements each called title, y_lab and x_lab. Only the labels for the plots that should be different to the original need to be specified. Please see the details section for an example with the default labels.

color

a character vector with two elements. The first element defines the color for the line in the QQ-plots, for the Cook's Distance plot and for the optimal parameter plot. The second element defines the color for the densities.

gg_theme

theme list from package ggplot2. For using this argument, package ggplot2 must be loaded via library(ggplot2).

cooks

optional logical. If TRUE, a Cook's distance plot is returned. The used method mdffits.default from the package HLMdiag struggles when data sets get large. In these cases, cooks should be set to FALSE. It defaults to TRUE.

range

optional sequence determining the range of the x-axis for plots of the optimal transformation parameter that defaults to NULL. In that case a range of the default interval is used for the plots of the optimal parameter. This leads in some cases to convergence problems such that it should be changed to e.g. the selected interval. The default value depends on the chosen data driven transformation and equals the default interval for the estimation of the optimal parameter.

...

optional arguments passed to generic function.

Details

The default settings of the label argument are as follows:

list(
qq_res =

c(title="Error term", y_lab="Quantiles of pearson residuals", x_lab="Theoretical quantiles"),

qq_ran =

c(title="Random effect", y_lab="Quantiles of random effects", x_lab="Theoretical quantiles"),

d_res =

c(title="Density - Pearson residuals", y_lab="Density", x_lab="Pearson residuals"),

d_ran =

c(title="Density - Standardized random effects", y_lab="Density", x_lab="Standardized random effects"),

cooks =

c(title="Cook's Distance Plot", y_lab="Cook's Distance", x_lab="Index"),

opt_lambda =

c(title="Log-Shift - REML", y_lab="Log-Likelihood", x_lab="expression(lambda)"))

Value

Two Q-Q plots in one grid, two density plots, a Cook's distance plot and a likelihood plot for the optimal parameter of transformations with transformation parameter obtained by ggplot.

See Also

saeTrafoObject, NER_Trafo

Examples



# Examples for diagnostic plots

# Load Data
data("eusilcA_smp")
data("pop_area_size")
data("pop_mean")
data("pop_cov")

# Nested error regression model
NER_model <- NER_Trafo(fixed = eqIncome ~ gender + eqsize + cash +
                       self_empl + unempl_ben + age_ben + surv_ben +
                       sick_ben + dis_ben + rent + fam_allow + house_allow +
                       cap_inv + tax_adj,
                       smp_domains = "district",
                       pop_area_size = pop_area_size,
                       pop_mean = pop_mean, pop_cov = pop_cov,
                       smp_data = eusilcA_smp)

# Example 1: Default diagnostic plot
plot(NER_model)

# Example 2: Creation of diagnostic plots without labels and titles,
# different colors and without Cook's distance plot.

plot(NER_model, label = "no_title", color = c("red", "yellow"),
     cooks = FALSE)




[Package saeTrafo version 1.0.2 Index]