Skip to content

extracting coefficients from lmer2 model

1 message · Douglas Bates

#
I meant to cc: the list on this reply

---------- Forwarded message ----------
From: Douglas Bates <bates at stat.wisc.edu>
Date: Feb 1, 2007 1:44 PM
Subject: Re: [R-sig-ME] extracting coefficients from lmer2 model
To: Colin Beale <c.beale at macaulay.ac.uk>
On 2/1/07, Colin Beale <c.beale at macaulay.ac.uk> wrote:
I recommend the vignette in the lme4 package that describes the lmer2
representation.

In answer to some of your specific questions:

fixef is straightforward for the mer2 representation

The ranef slot is currently populated when you call for fixef but the
values in that slot are the random effects with the "spherical" prior
density (independent, constant-variance).  These are named b* in the
vignette.   I need to add code to undo the permutation and to undo the
orthogonalization transformation defined by S and T.  It is not
incredibly difficult but I will need some quiet time to consider
exactly what sequence of operations needs to be performed and then to
write and debug the code.

The variance-covariance matrix for the random effects and the fixed
effects can be derived from the inverse of L but do you really want to
create that object?  It has the potential of being very large and very
slow to calculate.  Earlier today there was discussion of the need to
set control = list(niterEM = 0, gradient = FALSE) in a call to lmer
that fits a complicated model to a large data set.  This reason that
the ECME iterations and the gradient calculations are so slow (on the
order of hundreds or thousands of evaluations of the deviance) is
because those calculations require part of the inverse of L.  It's
even simpler than that, all you need to do is to calculate some groups
of columns in the inverse and store some values derived from them.
You don't ever need to store the inverse itself - just these values
that are derived from groups of columns in the inverse.

Calculating the inverse of L won't be a problem for simple models and
small data sets but it will be a problem for multiple, non-nested
grouping factors with many levels.  Furthermore the sparse matrix
methods take care to minimize the amount of storage in L.  That's what
the fill-reducing permutation is designed to do.  However, the inverse
of L can be a mess.

You should consider carefully exactly what you need from that
variance-covariance matrix.  For example, if you are going to evaluate
a quadratic form using this matrix then don't calculate the matrix.
Write the quadratic form using the factorization and solve the system
involving L or L-transpose then collect an inner product.