On Thu, Mar 13, 2008 at 8:43 AM, R Help <rhelp.stats at gmail.com>
wrote:> Hello list,
> I've been reading through the archives and it seems as though, as
> of right now, there is no way to specify the correlation structure in
> lmer. I was wondering if anyone knows if this is going to be
> implemented? I'm using mixed-effects models within a tree structure,
> so I make a lot of calls to lme to get the resulting deviance, and
> lmer2 is almost 5 times faster than lme on my test data, so if it may
> be implemented later I'd be willing to wait, otherwise I might look
> into trying to hack it myself.
I don't have any near-term plans for implementing a separate
correlation argument for the lmer function so I would recommend that
you hack it yourself.
I suggest starting with the development version of the lme4 sources,
available at http://r-forge.r-project.org/projects/lme4/. See the SCM
tab for instructions on how to check out a read-only copy of the svn
archive or go to the R Packages tag for a .tar.gz file of the current
source package.
The way that Jose and I implemented correlation structures for the
nlme package is to form a pre-whitened set of responses and the
corresponding model matrices then use the standard lme representation
on these pre-whitened components to optimize the log-likelihood with
respect to the correlation parameters and the random effects
parameters simultaneously.
You need to work out how to evaluate the log-likelihood (or,
equivalently, the deviance) for the combined set of parameters. The
slides at http://www.stat.wisc.edu/~bates/2008-02-22-Emory.pdf will
give you some idea of what the slots in the "mer" class of objects in
lme4 represent and how they are changed to accommodate changes in the
model. Once the mer object is created most of the work is done in a
set of C functions that are documented at
http://lme4.r-forge.r-project.org/www/doxygen. Be aware that many of
those functions are primarily for extensions to the linear mixed
model, such as generalized linear mixed models and nonlinear mixed
models and even generalized nonlinear mixed models. The ability to
profile out the fixed-effects parameters in the case of linear mixed
models provides a massive simplification in the computational approach
and means that many of the more difficult steps for the other models
can be skipped. Inside the mer_optimize function you will see that
there is one path for linear mixed models and another path for
everything else.
May I suggest that further discussion of this be moved to the
R-SIG-Mixed-Models at R-project.org list, which I have cc:'d on this
reply?