mem.getcomp: Extract per-observation components for fixed and random effects of a mixed-effects model
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
mem.getcomp(fit)
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
Arguments
fit
A fitted mixed-effects model generated either through the lme4 or the nlme package.
Author
Teemu Daniel Laajala <teelaa@utu.fi>
Details
Notice that per-observation model error is e = Xb + Zu - y_observation. Similarly, the components Xb and Zu are extracted.