leverage.mer: Leverage for HLMs

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

View source: R/influence_functions.R

Description

This function calculates the leverage of a hierarchical linear model fit by lmer.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Default S3 method:
leverage(object, ...)

## S3 method for class 'mer'
leverage(object, level = 1, ...)

## S3 method for class 'lmerMod'
leverage(object, level = 1, ...)

## S3 method for class 'lme'
leverage(object, level = 1, ...)

Arguments

object

fitted object of class mer of lmerMod

...

do not use

level

the level at which the leverage should be calculated: either 1 for observation level leverage (default) or the name of the grouping factor (as defined in flist of the mer object) for group level leverage. leverage assumes that the grouping factors are unique; thus, if IDs are repeated within each unit, unique IDs must be generated by the user prior to use of leverage.

Details

Demidenko and Stukel (2005) describe leverage for mixed (hierarchical) linear models as being the sum of two components, a leverage associated with the fixed (H_1) and a leverage associated with the random effects (H_2) where

H_1 = X (X^\prime V^{-1} X)^{-1} X^\prime V^{-1}

and

H_2 = ZDZ^{\prime} V^{-1} (I - H_1)

Nobre and Singer (2011) propose using

H_2^* = ZDZ^{\prime}

as the random effects leverage as it does not rely on the fixed effects.

For individual observations leverage uses the diagonal elements of the above matrices as the measure of leverage. For higher-level units, leverage uses the mean trace of the above matrices associated with each higher-level unit.

Value

leverage returns a data frame with the following columns:

overall

The overall leverage, i.e. H = H_1 + H_2.

fixef

The leverage corresponding to the fixed effects.

ranef

The leverage corresponding to the random effects proposed by Demidenko and Stukel (2005).

ranef.uc

The (unconfounded) leverage corresponding to the random effects proposed by Nobre and Singer (2011).

Author(s)

Adam Loy loyad01@gmail.com

References

Demidenko, E., & Stukel, T. A. (2005) Influence analysis for linear mixed-effects models. Statistics in Medicine, 24(6), 893–909.

Nobre, J. S., & Singer, J. M. (2011) Leverage analysis for linear mixed models. Journal of Applied Statistics, 38(5), 1063–1072.

See Also

cooks.distance.mer, mdffits.mer, covratio.mer, covtrace.mer, rvc.mer

Examples

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

# Observation level leverage
lev1 <- leverage(fm, level = 1)
head(lev1)

# Group level leverage
lev2 <- leverage(fm, level = "Subject")
head(lev2)

Example output

Attaching package:HLMdiagThe following object is masked frompackage:stats:

    covratio

     overall       fixef      ranef  ranef.uc
1 0.22930404 0.019191919 0.21011212 0.9345897
2 0.16972999 0.013804714 0.15592528 1.0174683
3 0.12682372 0.009764310 0.11705941 1.2074459
4 0.10058520 0.007070707 0.09351449 1.5045226
5 0.09101445 0.005723906 0.08529055 1.9086983
6 0.09811147 0.005723906 0.09238756 2.4199730
   overall      fixef     ranef ranef.uc
1 0.161234 0.01111111 0.1501229 2.592732
2 0.161234 0.01111111 0.1501229 2.592732
3 0.161234 0.01111111 0.1501229 2.592732
4 0.161234 0.01111111 0.1501229 2.592732
5 0.161234 0.01111111 0.1501229 2.592732
6 0.161234 0.01111111 0.1501229 2.592732

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