These functions calculate measures of the change in the fixed effects
estimates based on the deletetion of an observation, or group of
observations, for a hierarchical linear model fit using lmer.
Usage
## Default S3 method:
mdffits(object, ...)
## S3 method for class 'mer'
cooks.distance(model, group = NULL, delete = NULL, ...)
## S3 method for class 'lmerMod'
cooks.distance(model, group = NULL, delete = NULL, ...)
## S3 method for class 'lme'
cooks.distance(model, group = NULL, delete = NULL, ...)
## S3 method for class 'mer'
mdffits(object, group = NULL, delete = NULL, ...)
## S3 method for class 'lmerMod'
mdffits(object, group = NULL, delete = NULL, ...)
## S3 method for class 'lme'
mdffits(object, group = NULL, delete = NULL, ...)
Arguments
object
fitted object of class mer or lmerMod
...
do not use
model
fitted model of class mer or lmerMod
group
variable used to define the group for which cases will be
deleted. If group = NULL, 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.
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) with attribute beta_cdd giving
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.
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
library(lme4)
data(sleepstudy, package = 'lme4')
ss <- 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, group = "Subject")
## Not run:
data(Exam, package = 'mlmRev')
fm <- 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, group = "school")
# Cook's distance when school 1 is deleted
cd.school1 <- cooks.distance(fm, group = "school", delete = 1)
## End(Not run)
# MDFFITS for individual observations
ss.m1 <- mdffits(ss)
# MDFFITS for each Subject
ss.m.subject <- mdffits(ss, group = "Subject")
## Not run:
# MDFFITS for individual observations
m1 <- mdffits(fm)
# MDFFITS for each school
m.school <- mdffits(fm, group = "school")
## End(Not run)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(HLMdiag)
Attaching package: 'HLMdiag'
The following object is masked from 'package:stats':
covratio
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/HLMdiag/cooks.distance.Rd_%03d_medium.png", width=480, height=480)
> ### Name: mdffits.default
> ### Title: Influence on fixed effects of HLMs
> ### Aliases: cooks.distance cooks.distance.lme cooks.distance.lmerMod
> ### cooks.distance.mer mdffits mdffits.default mdffits.lme
> ### mdffits.lmerMod mdffits.mer
> ### Keywords: models regression
>
> ### ** Examples
>
> library(lme4)
Loading required package: Matrix
> data(sleepstudy, package = 'lme4')
> ss <- 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, group = "Subject")
>
> ## Not run:
> ##D data(Exam, package = 'mlmRev')
> ##D fm <- lmer(normexam ~ standLRT * schavg + (standLRT | school), Exam)
> ##D
> ##D # Cook's distance for individual observations
> ##D cd.lev1 <- cooks.distance(fm)
> ##D
> ##D # Cook's distance for each school
> ##D cd.school <- cooks.distance(fm, group = "school")
> ##D
> ##D # Cook's distance when school 1 is deleted
> ##D cd.school1 <- cooks.distance(fm, group = "school", delete = 1)
> ##D
> ## End(Not run)
> # MDFFITS for individual observations
> ss.m1 <- mdffits(ss)
>
> # MDFFITS for each Subject
> ss.m.subject <- mdffits(ss, group = "Subject")
>
> ## Not run:
> ##D
> ##D # MDFFITS for individual observations
> ##D m1 <- mdffits(fm)
> ##D
> ##D # MDFFITS for each school
> ##D m.school <- mdffits(fm, group = "school")
> ## End(Not run)
>
>
>
>
>
> dev.off()
null device
1
>