estfun.lmerMod: Extract Case-wise and Cluster-wise Derivatives for Linear...

View source: R/estfun.lmerMod.R

estfun.lmerModR Documentation

Extract Case-wise and Cluster-wise Derivatives for Linear Mixed Effects Models

Description

A function for extracting the case-wise and cluster-wise derivatives of a linear mixed effects models fitted via lme4. This function returns the case-wise and cluster-wise scores, evaluated at the ML estimates.

Usage

## S3 method for class 'lmerMod'
estfun(x, ...)

Arguments

x

An object of class lmerMod.

...

additional arguments, including level and ranpar (level = 2 and ranpar = "var" are default; see details).

Value

If level = 2, a g by p score matrix, corresponding to g clusters and p parameters. If level = 1, a n by p score matrix, corresponding to n observations and p parameters. For models with multiple clustering variables (three-level models, crossed random effects), an error is thrown if level = 2. If ranpar = "var", the random effects are parameterized as variance/covariance; If ranpar = "sd", the random effects are parameterized as standard deviation/correlation.

References

Wang, T. & Merkle, E. C. (2018). Derivative Computations and Robust Standard Errors for Linear Mixed Effects Models in lme4. Journal of Statistical Software, 87(1), 1-16. doi: 10.18637/jss.v087.c01

Examples

## Not run: 
# The sleepstudy example
lme4fit <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy, REML = FALSE)

# casewise scores
estfun(lme4fit, level = 1, ranpar = "var")

# clusterwise scores
estfun(lme4fit, level = 2, ranpar = "sd")

## End(Not run)

nctingwang/merDeriv documentation built on Aug. 17, 2022, 3:06 p.m.