Title Diagnostic tools for hierarchical (multilevel) linear models
Author Adam Loy <[email protected]>
Maintainer Adam Loy <[email protected]>
Description A suite of diagnostic tools for hierarchical (multilevel) linear models. The package offers
not only leverage and traditional deletion diagnostics (Cook'sdistance, covratio, covtrace, and MDFFITS) but also providesconvenience functions and graphics for residual analysis. The packageassumes that models were fit using the lme4 package.
Depends R (>= 2.15.0), lme4 (>= 1.0)
Imports ggplot2 (>= 0.9.2), stats, stats4, methods, plyr, reshape2,MASS, Matrix, Rcpp
Collate 'diagnostic_functions.R' 'group_level_residual_functions.R'
'identification.R' 'plot_functions.R' 'quantile_functions.R''adjust_formula_lmList.R' 'case_delete.R' 'LSresids.R''HLMresid.R' 'help.R' 'influence_functions.R''utility_functions.R' 'rotate_ranefs.R' 'autism.R' 'ahd.R' 'radon.R'
adjust_lmList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
adjust_lmList-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ahd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
autism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
case_delete.default . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
covratio.default . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
dotplot_diag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ggplot_qqnorm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . group_qqnorm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . HLMdiag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . HLMresid.default . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . leverage.default . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LSresids.default . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . mdffits.default . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . radon
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
rotate_ranef.default . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . rvc.default . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . varcomp.mer
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
wages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Separate linear models are fit via lm similar to lmList, however, adjust_lmList can handle modelswhere a factor takes only one level within a group. In this case, the formula is updated eliminatingthe offending factors from the formula for that group as the effect is absorbed into the intercept.
a linear formula such as that used by lmList, e.g. y ~ x1 + . + xn | g,where g is a grouping factor.
a data frame containing the variables in the model.
a logical value that indicates whether the pooled standard deviation/error shouldbe used.
Douglas Bates, Martin Maechler and Ben Bolker (2012). lme4: Linear mixed-effects models usingS4 classes. R package version 0.999999-0.
sepLM <- adjust_lmList(normexam ~ standLRT + sex + schgend | school, data = Exam)
Adjusted List of lm Objects with a Common Model
Objects can be created by calls of the form new("adjust_lmList", .) or by adjust_lmList.
.Data: Object of class "list", a list of lm objectscall: Object of class "call", the call used to create the adjust_lmList object. pool: Object of class "logical", a logical expression stating whether the pooled standard devia-
tion should be estimate should be used.
Class , from data part. Class , by class "list", distance 2.
coef signature(object = "adjust_lmList"): extracts the model coefficients from the individ-
confint signature(object = "adjust_lmList"): computes confidence intervals for the for the
parameters of the individually fit models.
show signature(object = "adjust_lmList"): extracts the formula used to create the adjust_lmList
plot signature(object = "adjust_lmList.confint"): plot the confidence intervals for the
parameters of the individually fit models using the ggplot2 framework.
Data from a longitudinal study exmaining the effectiveness of Methylprednisolone as a treatmentfor patients with severe alcoholic hepatitis. Subjects were randomly assigned to a treatment (31received a placebo, 35 received the treatment) and serum bilirubin was measures each week for fourweeks.
A data frame with 330 observations on the following 5 variables:
treatment The treatment a subject received - a factor. Levels are placebo and treated.
week Week of the study (0–4) - the time variable.
sbvalue Serum bilirubin level (in µmol/L).
baseline A subject’s serum bilirubin level at week 0.
Vonesh, E. F. and Chinchilli, V. M. (1997) Linear and Nonlinear Models for the Analysis of Re-peated Measurements. Marcel Dekker, New York.
Carithers, R. L., Herlong, H. F., Diehl, A. M., Shaw, E. W., Combes, B., Fallon, H. J. & Maddrey,W. C. (1989) Methylprednisolone therapy in patients with severe alcoholic hepatitis. Annals ofInternal Medicine, 110(9), 685–690.
Data from a prospective longitudinal study following 214 children between the ages of 2 and 13who were diagnosed with either autism spectrum disorder or non-spectrum developmental delaysat age 2.
A data frame with 604 observation on the following 7 variables:
sicdegp Sequenced Inventory of Communication Development group (an assessment of expressive
language development) - a factor. Levels are low, med, and high.
age2 Age (in years) centered around age 2 (age at diagnosis).
vsae Vineland Socialization Age Equivalent
gender Child’s gender - a factor. Levels are male and female.
race Child’s race - a factor. Levels are white and nonwhite.
bestest2 Diagnosis at age 2 - a factor. Levels are autism and pdd (pervasive developmental disor-
Anderson, D. K., Lord, C., Risi, S., DiLavore, P. S., Shulman, C., Thurm, A., et al. (2007). Patternsof growth in verbal abilities among children with autism spectrum disorder. Journal of Consultingand Clinical Psychology, 75(4), 594–604.
Anderson, D. K., Oti, R. S., Lord, C., & Welch, K. (2009). Patterns of Growth in Adaptive SocialAbilities Among Children with Autism Spectrum Disorders. Journal of Abnormal Child Psychol-ogy, 37(7), 1019–1034.
This function is used to iteratively delete groups corresponding to the levels of a hierarchical linearmodel. It uses lmer() to fit the models for each deleted case (i.e. uses brute force). To investigatenumerous levels of the model, the function will need to be called multiple times, specifying thegroup (level) of interest each time.
type = c("both", "fixef", "varcomp"), delete = NULL,
type = c("both", "fixef", "varcomp"), delete = NULL,
the original hierarchical model fit using lmer()
a variable used to define the group for which cases will be deleted. If this is leftNULL (default), then the function will delete individual observations.
the part of the model for which you are obtaining deletion diagnostics: the fixedeffects ("fixef"), variance components ("varcomp"), or "both" (default).
index of individual cases to be deleted. For higher level units specified in thismanner, the group parameter must also be specified. If delete = NULL then allcases are iteratively deleted.
fixef.original the original fixed effects estimatesranef.original the original predicted random effectsvcov.original the original variance-covariance matrix for the fixed effectsvarcomp.original the original estimated variance componentsfixef.delete a list of the fixed effects estimated after case deletionranef.delete a list of the random effects predicted after case deletionvcov.delete a list of the variance-covariance matrices for the fixed effects obtained after case
fitted.delete a list of the fitted values obtained after case deletionvarcomp.delete a list of the estimated variance components obtained after case deletion
Christensen, R., Pearson, L.M., and Johnson, W. (1992) Case-Deletion Diagnostics for Mixed Mod-els, Technometrics, 34, 38 – 45.
Schabenberger, O. (2004) Mixed Model Influence Diagnostics, in Proceedings of the Twenty-NinthSAS Users Group International Conference, SAS Users Group International.
fm <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
fmDel <- case_delete(model = fm, group = "Subject", type = "both")
del308 <- case_delete(model = fm, group = "Subject", type = "both", delete = 308)
delSubset <- case_delete(model = fm, group = "Subject", type = "both", delete = 308:310)
Visually comparing shrinkage and LS estimates
This function creates a plot (using qplot()) where the shrinkage estimate appears on the horizontalaxis and the LS estimate appears on the vertical axis.
compare_eb_ls(eb, ols, identify = FALSE, silent = TRUE,
a matrix of the OLS estimates found using random_ls_coef
the percentage of points to identify as unusual, FALSE if you do not want thepoints identified.
logical: should the list of data frames used to make the plots be supressed.
wages.fm1 <- lmer(lnw ~ exper + (exper | id), data = wages)
wages.sepLM <- adjust_lmList(lnw ~ exper | id, data = wages)
compare_eb_ls(eb = rancoef.eb, ols = rancoef.ols, identify = 0.01)
Influence on precision of fixed effects in HLMs
These functions calculate measures of the change in the covariance matrices for the fixed effectsbased on the deletetion of an observation, or group of observations, for a hierarchical linear modelfit using lmer.
variable used to define the group for which cases will be deleted. If group = NULL,then individual cases will be deleted.
index of individual cases to be deleted. To delete specific observations the rownumber must be specified. To delete higher level units the group ID and groupparameter must be specified. If delete
Both the covariance ratio (covratio) and the covariance trace (covtrace) measure the change inthe covariance matrix of the fixed effects based on the deletion of a subset of observations. The keydifference is how the variance covariance matrices are compared: covratio compares the ratio ofthe determinants while covtrace compares the trace of the ratio.
If delete = NULL then a vector corresponding to each deleted observation/group is returned.
If delete is specified then a single value is returned corresponding to the deleted subset specified.
Christensen, R., Pearson, L., & Johnson, W. (1992) Case-deletion diagnostics for mixed models. Technometrics, 34(1), 38–45.
Schabenberger, O. (2004) Mixed Model Influence Diagnostics, in Proceedings of the Twenty-NinthSAS Users Group International Conference, SAS Users Group International.
ss <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
ss.cr2 <- covratio(ss, group = "Subject")
fm <- lmer(normexam ~ standLRT * schavg + (standLRT | school), Exam)
cr2 <- covratio(fm, group = "school")
ss.ct2 <- covtrace(ss, group = "Subject")
ct2 <- covtrace(fm, group = "school")
Calculating influence diagnostics for HLMs.
This group of functions is used to compute deletion diagnostics for a hierarchical linear model basedon the building blocks returned by case_delete.
an object containing the output returned by case_delete()
an object containing the output returned by case_delete(). This is only nameddifferently to agree with the generic.
The primary function is diagnostics which returns either a list or data frame of influence mea-sures depending on whether type = "both" (list) or if only one aspect of the model is selected(data.frame). If type = "both", then a list with Cook’s distance, MDFFITS, COVTRACE, andCOVRATIO are returned for the fixed effects and relative variance change (RVC) is returned for thevariance components.
The methods cooks.distance, mdffits, covtrace, covratio, and rvc can be used for directcomputation of the corresponding diagnostic quantities from an object of class case_delete.
The results provided by this function will give exact values of the diagnostics; however, theseare computationally very slow. Approximate versions of cooks.distance, mdffits, covtrace,
covratio are implemented in HLMdiag, and can be called directly on the mer object.
Christensen, R., Pearson, L.M., and Johnson, W. (1992) “Case-Deletion Diagnostics for MixedModels, Technometrics, 34, 38 – 45.
Dillane, D. (2005), Deletion Diagnostics for the Linear Mixed Model,” Ph.D. thesis, Trinity CollegeDublin.
Schabenberger, O. (2004) Mixed Model Influence Diagnostics, in Proceedings of the Twenty-NinthSAS Users Group International Conference, SAS Users Group International.
fm <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
subject.del <- case_delete(model = fm, group = "Subject", type = "both")
subject.diag <- diagnostics(subject.del)
This is a function that can be used to create (modified) dotplots for the diagnostic measures. Theplot allows the user to understand the distribution of the diagnostic measure and visually identifyunusual cases.
name = c("cooks.distance", "mdffits", "covratio", "covtrace", "rvc", "leverage"),
value(s) specifying the boundary for unusual values of the diagnostic. The cut-off(s) can either be supplied by the user, or automatically calculated using mea-sures of internal scaling if cutoff = "internal"
what diagnostic is being plotted (one of "cooks.distance", "mdffits", "covratio",
"covtrace", "rvc", or "leverage"). this is used for the calculation of "inter-nal" cutoffs
specifies the geom to be used to produce a space-saving modification: either
The resulting plot uses coord_flip to rotate the plot, so when adding customized axis labels youwill need to flip the usage of xlab and ylab.
fm <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
subject.del <- case_delete(model = fm, group = "Subject", type = "both")
subject.diag <- diagnostics(subject.del)
dotplot_diag(x = COOKSD, index = IDS, data = subject.diag[["fixef_diag"]],
name = "cooks.distance", modify = FALSE,
xlab = "Subject", ylab = "Cook s Distance")
dotplot_diag(x = sigma2, , index = IDS, data = subject.diag[["varcomp_diag"]],
name = "rvc", modify = "dotplot", cutoff = "internal",
xlab = "Subject", ylab = "Relative Variance Change")
dotplot_diag(x = sigma2, , index = IDS, data = subject.diag[["varcomp_diag"]],
name = "rvc", modify = "boxplot", cutoff = "internal",
xlab = "Subject", ylab = "Relative Variance Change")
This function will construct a normal Q-Q plot within the ggplot2 framework. It combines thefunctionality of qqnorm and qqline.
the method used to fit a reference line. If no reference line is desired, leave thevalue as NULL. line = "rlm" will use robust regression to fit a reference line.
"quantile" will fit a line through the first and third quartiles. These
options are the same as those given for the qqPlot function in the car package.
This function will overlay multiple normal Q-Q plots on the same plot. This will be particularyuseful when comparing the distribution between groups. In this situation, significantly differentslopes would indicate the normal distributions for the groups do not share a common standarddeviation.
group_qqnorm(x, group, line = NULL, alpha_point = 1,
a numeric vector from which quantiles will be calculated
a vector indicating group membership for each value in x.
the method used to fit reference lines. If no reference lines are desired, leave thevalue as NULL. line = "rlm" will use robust regression to fit reference lines.
"quantile" will fit lines through the first and third quartiles.
Hilden-Minton, J. A. (1995) Mulilevel Diagnostics for Mixed and Hierarchical Linear Models,Ph.D. thesis, University of California Los Angeles.
Diagnostic tools for hierarchical (multilevel) linear models
HLMdiag provides a suite of diagnostic tools for hierarchical (multilevel) linear models fit usingThese tools are grouped below by purpose. See the help documentation for additional infor-mation about each function.
HLMdiag’s function provides a convenient wrapper to obtain residuals at each level ofa hierarchical linear model. In addition to being a wrapper function for functions implemented inthe lme4 package, HLMresid provides access to the marginal and least squares residuals (through
that were not previously implemented.
HLMdiag provides that calculates the influence that observations/groups have on the fit-ted values (leverage). For mixed/hierarchical models leverage can be decomposed into two parts:the fixed part and the random part. We refer the user to the references cited in the help documenta-tion for additional explanation.
HLMdiag provides and to assess the influence of subsets of observationson the fixed effects.
HLMdiag provides and to assess the influence of subsets of observations onthe precision of the fixed effects.
HLMdiag’s calculates the relative variance change to assess the influence of subsets of obser-vations on the variance components.
HLMdiag also strives to make graphical assessment easier in the ggplot2 framework by providingdotplots for influence diagnostics grouped Q-Q plots and Q-Qplots that combine the functionality of and
HLMresid is a function that extracts residuals from a hierarchical linear model fit using lmer. Thatis, it is a unified framework that extracts/calculates residuals from mer or lmerMod objects.
HLMresid(object, level, type = "EB",
HLMresid(object, level, type = "EB",
which residuals should be extracted: 1 for within-group (case-level) residu-als, the name of a grouping factor (as defined in flist of the mer object) forbetween-group residuals, or marginal.
how are the residuals predicted: either "EB" or "LS" (the default is "EB").
optional argument giving the data frame used for LS residuals. This is usedmainly for dealing with simulations.
if standardize = TRUE the standardized residuals will be returned; if standardize = "semi"then the semi-standardized level-1 residuals will be returned. Note that forhigher-level residuals of type = "LS", standardize = TRUE does not result instandardized residuals as they have not been implemented.
This function extracts residuals from the model, and can extract residuals estimated using leastsquares (LS) or Empirical Bayes (EB). This unified framework enables the analyst to more easilyconduct an upward residual analysis during model exploration/checking.
The HLMresid function provides a wrapper that will extract residuals from a fitted mer or lmerModobject. The function provides access to residual quantities already made available by the functionsresid and ranef, but adds additional functionality. Below is a list of types of residuals that can beextracted.
raw level-1 residuals These are equivalent to the residuals extracted by resid if level = 1, type
= "EB", and standardize = FALSE is specified. You can also specify type = "LS" for LSresiduals that are not equivalent to those from resid.
standardized level-1 residuals Specify level
with both type = "EB" or "LS".
semi-standardized level-1 residuals Specify level = 1, type = "LS" and standardize = "semi".
raw group level residuals These are equivalent to extracting the predicted random effects for a
given group using ranef. Set level to a grouping factor name and type = "EB". type = "LS"can also be specified, though this is less common.
standardized group level residuals Set level to a grouping factor name, type =
standardized = TRUE. This will not produce standardized residuals for type = "LS".
marginal residuals The marginal residuals can be obtained by setting level = "marginal". Only
cholesky residuals These are essentially standardized marginal residuals. To obtain cholesky resid-
"marginal", type = "EB", and standardize =
Note that standardize = "semi" is only implemented for level-1 LS residuals.
Hilden-Minton, J. (1995) Multilevel diagnostics for mixed and hierarchical linear models. Univer-sity of California Los Angeles.
Houseman, E. A., Ryan, L. M., & Coull, B. A. (2004) Cholesky Residuals for Assessing Normal Er-rors in a Linear Model With Correlated Outcomes. Journal of the American Statistical Association,99(466), 383–394.
data(sleepstudy, package = "lme4")
fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
all.equal(HLMresid(object = fm1, level = 1, type = "EB"), resid(fm1)) ## EB
r1LS <- HLMresid(object = fm1, level = 1, type = "LS") ## raw LS resids
r1LS.std <- HLMresid(object = fm1, level = 1, type = "LS", standardize = TRUE) ## std. LS resids
all.equal(r2EB <- HLMresid(object = fm1, level = "Subject", type = "EB"), ranef(fm1)[["Subject"]])
r2EB.std <- HLMresid(object = fm1, level = "Subject", type = "EB", standardize = TRUE)
mr <- HLMresid(object = fm1, level = "marginal")
cholr <- HLMresid(object = fm1, level = "marginal", standardize = TRUE) # Cholesky residuals
This function calculates the leverage of a hierarchical linear model fit by lmer.
the level at which the leverage should be calculated: either 1 for observationlevel leverage or the name of the grouping factor (as defined in flist of the merobject) for group level leverage. leverage assumes that the grouping factors areunique; thus, if IDs are repeated within each unit, unique IDs must be generatedby the user prior to use of leverage.
Demidenko and Stukel (2005) describe leverage for mixed (hierarchical) linear models as being thesum of two components, a leverage associated with the fixed (H1) and a leverage associated withthe random effects (H2) where
as the random effects leverage as it does not rely on the fixed effects.
For individual observations leverage uses the diagonal elements of the above matrices as the mea-sure of leverage. For higher-level units, leverage uses the mean trace of the above matrices asso-ciated with each higher-level unit.
leverage returns a data frame with the following columns:
overall The overall leverage, i.e. H = H1 + H2. fixef The leverage corresponding to the fixed effects. ranef The leverage corresponding to the random effects proposed by Demidenko and Stukel (2005). ranef.uc The (unconfounded) leverage corresponding to the random effects proposed by Nobre
Demidenko, E., & Stukel, T. A. (2005) Influence analysis for linear mixed-effects models. Statisticsin Medicine, 24(6), 893–909.
Nobre, J. S., & Singer, J. M. (2011) Leverage analysis for linear mixed models. Journal of AppliedStatistics, 38(5), 1063–1072.
fm <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
lev2 <- leverage(fm, level = "Subject")
This function calculates least squares (LS) residuals found by fitting separate LS regression modelsto each case. For examples see the documentation for HLMresid.
which residuals should be extracted: 1 for case-level residuals or the name ofa grouping factor (as defined in flist of the mer object) for between-groupresiduals.
optional argument giving the data frame used for LS residuals. This is usedmainly when dealing with simulations.
if TRUE the standardized level-1 residuals will also be returned (if level =
if "semi" then the semi-standardized level-1 residuals will be returned.
Hilden-Minton, J. (1995) Multilevel diagnostics for mixed and hierarchical linear models. Univer-sity of California Los Angeles.
These functions calculate measures of the change in the fixed effects estimates based on the delete-tion of an observation, or group of observations, for a hierarchical linear model fit using lmer.
variable used to define the group for which cases will be deleted. If group = NULL,then individual cases will be deleted.
index of individual cases to be deleted. To delete specific observations the rownumber must be specified. To delete higher level units the group ID and groupparameter must be specified. If delete
Both Cook’s distance and MDFFITS measure the change in the fixed effects estimates based on thedeletion of a subset of observations. The key difference between the two diagnostics is that Cook’sdistance uses the covariance matrix for the fixed effects from the original model while MDFFITSuses the covariance matrix from the deleted model.
Both functions return a numeric vector (or single value if delete has been specified) with attribute
beta_cdd giving the difference between the full and deleted parameter estimates.
Because MDFFITS requires the calculation of the covariance matrix for the fixed effects for everymodel, it will be slower.
Christensen, R., Pearson, L., & Johnson, W. (1992) Case-deletion diagnostics for mixed models. Technometrics, 34, 38–45.
Schabenberger, O. (2004) Mixed Model Influence Diagnostics, in Proceedings of the Twenty-NinthSAS Users Group International Conference, SAS Users Group International.
ss <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
# Cook s distance for individual observations
ss.cd.subject <- cooks.distance(ss, group = "Subject")
fm <- lmer(normexam ~ standLRT * schavg + (standLRT | school), Exam)
# Cook s distance for individual observations
cd.school <- cooks.distance(fm, group = "school")
# Cook s distance when school 1 is deleted
cd.school1 <- cooks.distance(fm, group = "school", delete = 1)
ss.m.subject <- mdffits(ss, group = "Subject")
m.school <- mdffits(fm, group = "school")
Radon measurements of 919 owner-occupied homes in 85 counties of Minnesota.
A data frame with 919 observations on the following 5 variables:
log.radon Radon measurement (in log pCi/L, i.e., log picoCurie per liter)
basement Indicator for the level of the home at which the radon measurement was taken - 0 =
uranium Average county-level soil uranium content.
Price, P. N., Nero, A. V. and Gelman, A. (1996) Bayesian prediction of mean indoor radon concen-trations for Minnesota counties. Health Physics. 71(6), 922–936.
Gelman, A. and Hill, J. (2007) Data analysis using regression and multilevel/hierarchical models. Cambridge University Press.
Calculate s-dimensional rotated random effects
This function calculates reduced dimensional rotated random effects. The rotation reduces theinfluence of the residuals from other levels of the model so that distributional assessment of theresulting random effects is possible.
a matrix defining which combination of random effects are of interest.
the dimension of the subspace of interest.
if .varimax = TRUE than the raw varimax rotation will be applied to the result-ing rotation.
This function calculates the relative variance change (RVC) of hierarchical linear models fit vialmer.
variable used to define the group for which cases will be deleted. If group = NULL,then individual cases will be deleted.
index of individual cases to be deleted. To delete specific observations the rownumber must be specified. To delete higher level units the group ID and groupparameter must be specified. If delete
If delete = NULL a matrix with columns corresponding to the variance components of the modeland rows corresponding to the deleted observation/group is returned.
If delete is specified then a named vector is returned.
The residual variance is named sigma2 and the other variance componenets are named D** wherethe trailing digits give the position in the covariance matrix of the random effects.
Dillane, D. (2005) Deletion Diagnostics for the Linear Mixed Model. Ph.D. thesis, Trinity CollegeDublin
This function extracts the variance components from a mixed/hierarchical linear model fit usinglmer.
a fitted model object of class mer or lmerMod.
A named vector is returned. sigma2 denotes the residual variance. The other variance componentsare names D** where the trailing digits specify the of that variance component in the covariancematrix of the random effects.
data(sleepstudy, package = "lme4")
fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
Data on the labor-market experience of male high school dropouts.
A data frame with 6402 observations on the following 15 variables.
id respondent id - a factor with 888 levels.
lnw natural log of wages expressed in 1990 dollars.
exper years of experience in the work force
ged equals 1 if respondent has obtained a GED as of the time of survey, 0 otherwise
postexp labor force participation since obtaining a GED (in years) - before a GED is earned postexp
= 0, and on the day a GED is earned postexp = 0
black factor - equals 1 if subject is black, 0 otherwise
hispanic factor - equals 1 if subject is hispanic, 0 otherwise
hgc highest grade completed - takes integers 6 through 12
uerate local area unemployment rate for that year
These data are originally from the 1979 National Longitudinal Survey on Youth (NLSY79) that canbe found here
Singer and Willett (2003) used these data for examples in chapter (insert info. here) and the datasets used can be found on the UCLA Statistical Computing website:
Additionally the data were discussed by Cook and Swayne (2003) and the data can be found on theGGobi website:
Singer, J. D. and Willett, J. B. (2003), Applied Longitudinal Data Analysis: Modeling Change andEvent Occurence, New York: Oxford University Press.
Cook, D. and Swayne, D. F. (2007), Interactive and Dynamic Graphics for Data Analysis with Rand GGobi, Springer.
lmer(lnw ~ exper + (exper | id), data = wages)

been derived from various natural products (5,10,13,19,20). egg solids and a mixture of mustard oil and capsaicin (1,14,15). Other repellents haveactivity of varying degrees, particularly denatonium benzoate (1,21), putrescent wholecan be summarized from the literature cited as follows: marketing of natural and synthetic products (Tcrops has become an increasingly important problem (4,6,16,17

DIRECCION GENERAL DE REGULACION, VIGILANCIA Y CONTROL DE LA SALUD DEPARTAMENTO DE REGULACIÓN Y CONTROL DE PRODUCTOS FARMACÉUTICOS Y AFINES 3ra. calle final 2-10 Colonia Valles de Vista Hermosa Zona 15 VENTANILLA DE SERVICIOS DEL MINISTERIO DE SALUD 5ta av. 13-27 zona 9, tel. 236-299-80 DEPARTAMENTO DE REGULACION Y CONTROL DE PRODUCTOS Que la Constitución Política de la República de Gua