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

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`

.

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, ...)
``` |

`object` |
fitted object of class |

`...` |
do not use |

`model` |
fitted model of class |

`level` |
variable used to define the group for which cases will be
deleted. If |

`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 |

`include.attr` |
logical value determining whether the difference between
the full and deleted parameter estimates should be included. If |

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.

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.

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

Adam Loy loyad01@gmail.com

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.

`leverage.mer`

,
`covratio.mer`

, `covtrace.mer`

, `rvc.mer`

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)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.