Learn R Programming

HLMdiag (version 0.5.0)

leverage.default: Leverage for HLMs

Description

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

Usage

# S3 method for default
leverage(object, ...)

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

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

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

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

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.

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

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataLab