ranef                  package:lme4                  R Documentation

_E_x_t_r_a_c_t _t_h_e _m_o_d_e_s _o_f _t_h_e _r_a_n_d_o_m _e_f_f_e_c_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     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.

_U_s_a_g_e:

     ranef(object, ...)
     ## S4 method for signature 'mer':
     ranef(object, postVar, drop, ...)

_A_r_g_u_m_e_n_t_s:

  object: an object of a class of fitted models with random effects,
          typically an '"mer"' object.

 postVar: an optional logical argument indicating if the conditional
          variance-covariance matrices, also called the "posterior
          variances", of the random effects should be added as an
          attribute.  Default is 'FALSE'.

    drop: an optional logical argument indicating components of the
          return value that would be data frames with a single column,
          usually a column called ''(Intercept)'', should be returned
          as named vectors.

     ...: some methods for this generic function require additional
          arguments.

_D_e_t_a_i_l_s:

     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' 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
     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
     '"postVar"' attributes are still the diagonal blocks of this
     conditional variance-covariance matrix but the matrix itself is no
     longer block diagonal.

_V_a_l_u_e:

     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 'postVar' is 'TRUE' each of the data frames has an attribute
     called '"postVar"' which is a three-dimensional array with
     symmetric faces.

     When 'drop' is 'TRUE' any components that would be data frames of
     a single column are converted to named numeric vectors.

_N_o_t_e:

     To produce a "caterpillar plot" of the random effects apply
     'qqmath' to the result of a call to 'ranef' with 'postVar = TRUE'.

_E_x_a_m_p_l_e_s:

     fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
     fm2 <- lmer(Reaction ~ Days + (1|Subject) + (0+Days|Subject), sleepstudy)
     fm3 <- lmer(diameter ~ (1|plate) + (1|sample), Penicillin)
     ranef(fm1)
     str(rr1 <- ranef(fm1, postVar = TRUE))
     qqmath(rr1)
     str(ranef(fm2, postVar = TRUE))
     op <- options(digits = 4)
     ranef(fm3, drop = TRUE)
     options(op)

