These functions calculate measures of the change in the fixed effects estimates based on the deletion of an observation, or group of observations, for a hierarchical linear model fit using lmer.

# S3 method for default
mdffits(object, ...)

# S3 method for mer
cooks.distance(model, level = 1, delete = NULL, ...)

# S3 method for lmerMod
cooks.distance(model, level = 1, delete = NULL, include.attr = FALSE, ...)

# S3 method for lme
cooks.distance(model, level = 1, delete = NULL, include.attr = FALSE, ...)

# S3 method for mer
mdffits(object, level = 1, delete = NULL, ...)

# S3 method for lmerMod
mdffits(object, level = 1, delete = NULL, include.attr = FALSE, ...)

# S3 method for lme
mdffits(object, level = 1, delete = NULL, include.attr = FALSE, ...)

Arguments

object

fitted object of class mer or lmerMod

...

do not use

model

fitted model of class mer or lmerMod

level

variable used to define the group for which cases will be deleted. If level = 1 (default), then individual cases will be deleted.

delete

index of individual cases to be deleted. To delete specific observations the row number must be specified. To delete higher level units the group ID and group parameter must be specified. If delete = NULL then all cases are iteratively deleted.

include.attr

logical value determining whether the difference between the full and deleted parameter estimates should be included. If FALSE (default), a numeric vector of Cook's distance or MDFFITS is returned. If TRUE, a tibble with the Cook's distance or MDFFITS values in the first column and the parameter differences in the remaining columns is returned.

Value

Both functions return a numeric vector (or single value if delete has been specified) as the default. If include.attr = TRUE, then a tibble is returned. The first column consists of the Cook's distance or MDFFITS values, and the later columns capture the difference between the full and deleted parameter estimates.

Details

Both Cook's distance and MDFFITS measure the change in the fixed effects estimates based on the deletion of a subset of observations. The key difference between the two diagnostics is that Cook's distance uses the covariance matrix for the fixed effects from the original model while MDFFITS uses the covariance matrix from the deleted model.

Note

Because MDFFITS requires the calculation of the covariance matrix for the fixed effects for every model, it will be slower.

References

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-Ninth SAS Users Group International Conference, SAS Users Group International.

See also

Author

Adam Loy loyad01@gmail.com

Examples

data(sleepstudy, package = 'lme4') ss <- lme4::lmer(Reaction ~ Days + (Days | Subject), sleepstudy) # Cook's distance for individual observations ss.cd.lev1 <- cooks.distance(ss) # Cook's distance for each Subject ss.cd.subject <- cooks.distance(ss, level = "Subject") if (FALSE) { data(Exam, package = 'mlmRev') fm <- lme4::lmer(normexam ~ standLRT * schavg + (standLRT | school), Exam) # Cook's distance for individual observations cd.lev1 <- cooks.distance(fm) # Cook's distance for each school cd.school <- cooks.distance(fm, level = "school") # Cook's distance when school 1 is deleted cd.school1 <- cooks.distance(fm, level = "school", delete = 1) } # MDFFITS for individual observations ss.m1 <- mdffits(ss) # MDFFITS for each Subject ss.m.subject <- mdffits(ss, level = "Subject") if (FALSE) { # MDFFITS for individual observations m1 <- mdffits(fm) # MDFFITS for each school m.school <- mdffits(fm, level = "school") }