mem.getcomp: Extract per-observation components for fixed and random...

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

View source: R/memtools.R

Description

Assuming a mixed-effects model of form y_fit = Xb + Zu + e, where X is the model matrix for fixed effects, Z is the model matrix for random effects, and b and u are the fixed and random effects respectively, this function returns these components per each fitted value y. These may be useful for model inference and/or diagnostic purposes.

Usage

1

Arguments

fit

A fitted mixed-effects model generated either through the lme4 or the nlme package.

Details

Notice that per-observation model error is e = Xb + Zu - y_observation. Similarly, the components Xb and Zu are extracted.

Value

The function returns per-observation model fit components for a mixed-effects model. The return fields are

Xb

Fixed effects component Xb

Zu

Random effects component Zu

XbZu

Full model fit by summing the above two Xb+Zu

e

Model error e

y

Original observations y

Author(s)

Teemu Daniel Laajala <teelaa@utu.fi>

See Also

mem.plotran mem.plotresid

Examples

1
2
3
4
5
6
7
8
data(vcaplong)

exdat <- vcaplong[vcaplong[,"Group"] %in% c("Vehicle", "ARN"),]

library(lme4)
f1 <- lmer(log2PSA ~ 1 + DrugWeek + DrugWeek:ARN + (1 + DrugWeek|ID), data = exdat)

mem.getcomp(f1)

hamlet documentation built on May 1, 2019, 8:40 p.m.