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
.
# Default S3 method
mdffits(model, ...)
# S3 method for class 'mer'
cooks.distance(model, level = 1, delete = NULL, ...)
# S3 method for class 'lmerMod'
cooks.distance(model, level = 1, delete = NULL, include.attr = FALSE, ...)
# S3 method for class 'lme'
cooks.distance(model, level = 1, delete = NULL, include.attr = FALSE, ...)
# S3 method for class 'mer'
mdffits(object, level = 1, delete = NULL, ...)
# S3 method for class 'lmerMod'
mdffits(model, level = 1, delete = NULL, include.attr = FALSE, ...)
# S3 method for class 'lme'
mdffits(model, level = 1, delete = NULL, include.attr = FALSE, ...)
fitted model of class mer
or lmerMod
do not use
variable used to define the group for which cases will be
deleted. If level = 1
(default), then individual cases will be deleted.
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.
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.
fitted object of class mer
or lmerMod
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.
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.
Because MDFFITS requires the calculation of the covariance matrix for the fixed effects for every model, 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-Ninth SAS Users Group International Conference, SAS Users Group International.
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) { # \dontrun{
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) { # \dontrun{
# MDFFITS for individual observations
m1 <- mdffits(fm)
# MDFFITS for each school
m.school <- mdffits(fm, level = "school")
} # }