cooks.distance: Influence on fixed effects of HLMs

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

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.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Default S3 method:
mdffits(object, ...)

## 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(object, level = 1, delete = NULL, include.attr = FALSE, ...)

## S3 method for class '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.

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.

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.

Note

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

Author(s)

Adam Loy loyad01@gmail.com

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

leverage.mer, covratio.mer, covtrace.mer, rvc.mer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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")

## Not run: 
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)


## End(Not run)


# MDFFITS  for individual observations
ss.m1 <- mdffits(ss)

# MDFFITS for each Subject
ss.m.subject <- mdffits(ss, level = "Subject")

## Not run:   

# MDFFITS  for individual observations
m1 <- mdffits(fm)

# MDFFITS for each school
m.school <- mdffits(fm, level = "school")

## End(Not run)

aloy/HLMdiag documentation built on May 4, 2021, 10:50 a.m.