case_delete.mer: Case Deletion for 'mer'/'lmerMod' objects

Description Usage Arguments Value Author(s) References Examples

View source: R/case_delete.R

Description

This function is used to iteratively delete groups corresponding to the levels of a hierarchical linear model. It uses lmer() to fit the models for each deleted case (i.e. uses brute force). To investigate numerous levels of the model, the function will need to be called multiple times, specifying the group (level) of interest each time.

Usage

 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
## Default S3 method:
case_delete(model, ...)

## S3 method for class 'mer'
case_delete(
  model,
  level = 1,
  type = c("both", "fixef", "varcomp"),
  delete = NULL,
  ...
)

## S3 method for class 'lmerMod'
case_delete(
  model,
  level = 1,
  type = c("both", "fixef", "varcomp"),
  delete = NULL,
  ...
)

## S3 method for class 'lme'
case_delete(
  model,
  level = 1,
  type = c("both", "fixef", "varcomp"),
  delete = NULL,
  ...
)

Arguments

model

the original hierarchical model fit using lmer()

...

do not use

level

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

type

the part of the model for which you are obtaining deletion diagnostics: the fixed effects ("fixef"), variance components ("varcomp"), or "both" (default).

delete

numeric index of individual cases to be deleted. If the level parameter is specified, delete may also take the form of a character vector consisting of group names as they appear in flist. It is possible to set level and delete individual cases from different groups using delete, so numeric indices should be double checked to confirm that they encompass entire groups. If delete = NULL then all cases are iteratively deleted.

Value

a list with the following components:

fixef.original

the original fixed effects estimates

ranef.original

the original predicted random effects

vcov.original

the original variance-covariance matrix for the fixed effects

varcomp.original

the original estimated variance components

fixef.delete

a list of the fixed effects estimated after case deletion

ranef.delete

a list of the random effects predicted after case deletion

vcov.delete

a list of the variance-covariance matrices for the fixed effects obtained after case deletion

fitted.delete

a list of the fitted values obtained after case deletion

varcomp.delete

a list of the estimated variance components obtained after case deletion

Author(s)

Adam Loy loyad01@gmail.com

References

Christensen, R., Pearson, L.M., and 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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
data(sleepstudy, package = 'lme4')
fm <- lme4::lmer(Reaction ~ Days + (Days|Subject), sleepstudy)

# Deleting every Subject
fmDel <- case_delete(model = fm, level = "Subject", type = "both")

# Deleting only subject 308
del308 <- case_delete(model = fm, level = "Subject", type = "both", delete = 308)

# Deleting a subset of subjects
delSubset <- case_delete(model = fm, level = "Subject", type = "both", delete = 308:310)

HLMdiag documentation built on May 2, 2021, 9:06 a.m.