Description Usage Arguments Details Value Note Examples
A generic function to extract the conditional modes of the random effects from a fitted model object. For linear mixed models the conditional modes of the random effects are also the conditional means.
1 2 3 4 5 6 7 
object 
an object of a class of fitted models with
random effects, typically a

condVar 
an optional logical argument indicating if the conditional variancecovariance matrices of the random effects should be added as an attribute. 
drop 
should components of the return value that would be data frames
with a single column, usually a column called
‘ 
whichel 
character vector of names of grouping factors for which the random effects should be returned. 
postVar 
a (deprecated) synonym for 
x 
a randomeffects object (of class 
main 
include a main title, indicating the grouping factor, on each subplot? 
data 
This argument is required by the 
... 
some methods for these generic functions 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 condVar
is TRUE
the "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 variancecovariance 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
"postVar"
attributes are still the diagonal blocks
of this conditional variancecovariance matrix but the
matrix itself is no longer block diagonal.
An object of class ranef.mer
composed of
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.
If condVar
is TRUE
each of the data frames
has an attribute called "postVar"
which is a
threedimensional array with symmetric faces; each face
contains the variancecovariance matrix for a particular
level of the grouping factor. (The name
of this attribute is a historical artifact,
and may be changed to condVar
at some point in the future.)
When drop
is TRUE
any components that would
be data frames of a single column are converted to named
numeric vectors.
To produce a (list of) “caterpillar plots” of the random
effects apply dotplot
to
the result of a call to ranef
with condVar =
TRUE
; qqmath
will generate
a list of QQ plots.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  require(lattice)
fm1 < lmer(Reaction ~ Days + (DaysSubject), sleepstudy)
fm2 < lmer(Reaction ~ Days + (1Subject) + (0+DaysSubject), sleepstudy)
fm3 < lmer(diameter ~ (1plate) + (1sample), Penicillin)
ranef(fm1)
str(rr1 < ranef(fm1, condVar = TRUE))
dotplot(rr1) ## default
## specify free scales in order to make Day effects more visible
dotplot(rr1,scales = list(x = list(relation = 'free')))[["Subject"]]
if(FALSE) { ## condVar=TRUE is not yet implemented for multiple terms  FIXME
str(ranef(fm2, condVar = TRUE))
}
op < options(digits = 4)
ranef(fm3, drop = TRUE)
options(op)

Loading required package: Matrix
Loading required package: lattice
$Subject
(Intercept) Days
308 2.2585654 9.1989719
309 40.3985770 8.6197032
310 38.9602459 5.4488799
330 23.6904985 4.8143313
331 22.2602027 3.0698946
332 9.0395259 0.2721707
333 16.8404312 0.2236244
334 7.2325792 1.0745761
335 0.3336959 10.7521591
337 34.8903509 8.6282839
349 25.2101104 1.1734143
350 13.0699567 6.6142050
351 4.5778352 3.0152572
352 20.8635925 3.5360133
369 3.2754530 0.8722166
370 25.6128694 4.8224646
371 0.8070397 0.9881551
372 12.3145394 1.2840297
List of 1
$ Subject:'data.frame': 18 obs. of 2 variables:
..$ (Intercept): num [1:18] 2.26 40.4 38.96 23.69 22.26 ...
..$ Days : num [1:18] 9.2 8.62 5.45 4.81 3.07 ...
.. attr(*, "postVar")= num [1:2, 1:2, 1:18] 145.71 21.44 21.44 5.31 145.71 ...
 attr(*, "class")= chr "ranef.mer"
$Subject
$plate
a b c d e f g h
0.80455 0.80455 0.18167 0.33739 0.02595 0.44120 1.37552 0.80455
i j k l m n o p
0.75264 0.75264 0.96027 0.49311 1.42742 0.49311 0.96027 0.02595
q r s t u v w x
0.28548 0.28548 1.37552 0.96027 0.90836 0.28548 0.59692 1.21980
$sample
A B C D E F
2.18706 1.01048 1.93790 0.09689 0.01384 3.00374
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.