Skip to content
Prev 2352 / 20628 Next

specifying custom random-effects structures

On Sun, May 24, 2009 at 5:46 PM, Roger Levy <rlevy at ling.ucsd.edu> wrote:
I view the variance-covariance structures available in the lme4
package as being related to random-effects terms in the model matrix.
A random-effects term is of the form (LMexpr | GrpFac).  The
expression on the right of the vertical bar is evaluated as a factor,
which I call the grouping factor.  The expression on the left is
evaluated as a linear model expression.  The number of columns in the
model matrix corresponding to this expression is the number of random
effects per level of the grouping factor.

The basic rules for the unconditional variance-covariance of the
random effects are:
  random effects generated from different random-effects terms are independent
  random effects corresponding to different levels of the grouping
factor are independent
  the vector of random effects for a given level of the grouping
factor have a general positive semidefinite symmetric
variance-covariance, which is common to all the levels of the grouping
factor.

In future versions of lme4 I plan to allow for extensions of the
unconditional variance-covariance structures.  If you look at the
development version in the branches/allcoef section of the SVN archive
at R-forge you will see that there is a virtual class called the
reCovFac (random-effects covariance factor) class.  If an actual class
is defined to extend reCovFac and certain methods (getPars, setPars,
getBounds, getLambda) are defined for the actual class then it can be
used instead of the default ST class.
In its current implementation, no, the lme4 package does not allow
general modeling of the unconditional variance-covariance structure of
the random effects.  I doubt that it will, just because I find it
difficult to understand the model in that way.  Generalizing the model
is not just a matter of adding hooks - you also need to decide what
can go wrong in the generalized structure.  I have said that the most
valuable character trait for programmers is unbounded pessimism
because you spend so much of your time trying to decide how things
could fail to work.  In early designs of the nlme package when we
created a pdMat subclass to represent positive definite matrices that
were not matrices I knew we were in trouble.

You can try to extend the reCovFac class but doing so in a consistent
way is not always easy.