Extract Random Effects
A generic function to extract, and optionally accumulate, the random effects.
ranef(object, ...) ## S3 method for class 'lmer': ranef(object, postVar, \dots) ## S3 method for class 'lmer2': ranef(object, postVar, \dots)
- an object of a class from which random effects estimates can be extracted.
- an optional logical argument indicating if the
conditional variance covariance matrices, also called the
posterior variances, of the random effects should be included. Default is
- some methods for this generic function require additional arguments.
If grouping factor i has k levels and j random effects per level the ith
component of the list returned by
ranef is a data frame with k
rows and j columns. If
"postVar" attribute is an array of dimension j by j by k. The
kth face of this array is a positive definite symmetric j by j
matrix. If there is only one grouping factor in the model the
variance-covariance matrix for the entire random effects vector,
conditional on the estimates of the model parameters and on the data
will be block diagonal and this j by j matrix is the kth diagonal block.
With multiple grouping factors the faces of the
attributes are still the diagonal blocks of this conditional
variance-covariance matrix but the matrix itself is no longer block
- A list of data frames, one for each grouping factor for the random
effects. The number of rows in the data frame is the number of levels
of the grouping factor. The number of columns is the dimension of the
random effect associated with each level of the factor.
TRUEeach of the data frames has an attribute called
"postVar"which is a three-dimensional array with symmetric faces.
To produce a
qqmath to the result of
postVar = TRUE.
fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy) fm2 <- lmer(Reaction ~ Days + (1|Subject) + (0+Days|Subject), sleepstudy) ranef(fm1) str(rr1 <- ranef(fm1, postVar = TRUE)) qqmath(rr1) str(ranef(fm2, postVar = TRUE))