[R-sig-ME] gls/lme/lmer Likelihood

Douglas Bates bates at stat.wisc.edu
Fri Jul 13 21:56:20 CEST 2007

On 7/13/07, Andrzej Galecki <agalecki at umich.edu> wrote:
> Hello,

> logLik function appears to return gls/lme/lmer log-likelihood evaluated for a
> model at:

> 1. the set of  estimated coefficients
>   and
> 2. for the data set, to which the model was fitted.

> I am wondering whether there is a simple/elegant way to return the
> log-likelihood for the same model evaluated at:

> 1. a given set of parameter values _other_ than the estimated coefficients
>  and

I can answer regarding lmer.  I have forgotten the details of exactly
how the log-likelihood evaluation is done in lme and gls.  All I
remember is that it is complicated.

The lmer function does not incorporate all the parameters from the
model in the evaluation of the log-likelihood when optimizing the
parameter estimates.  It minimizes a profiled deviance with respect to
a reduced set of parameters, which I call $\theta$, that determine the
relative variance-covariance matrix of the random effects.  The model
itself depends on $\beta$, the fixed-effects parameters, $\theta$ and
$\sigma^2$, the scalar variance of the conditional distribution of Y
given B.

If it happens that you want to evaluate the profiled log-likelihood
for different values of $\theta$ then the task is easy.  Look at the R
code in the Sweave file Implementation.Rnw that generates the
Implementation.pdf vignette.  However, if you want to choose arbitrary
values of $\beta$, $\theta$ and $\sigma^2$ then evaluate the
log-likelihood for them, you are better off going back to the formula
for the log-likelihood in the "Computational methods for mixed models"
vignette.  If you are doing that I would recommend getting the
development version of the code from the SVN site
https://svn.r-project.org/R-packages/branches/gappy-lmer/ because that
is the version of the code described in the vignette.  (It is a
development version and there are lots of things broken in it but the
likelihood evaluation does work.)

To evaluate the log-likelihood for different data you need to replace
the slots XytXy and ZtXy then force a likelihood evaluation.  Look at
the code in the lmer function (gappy version) to see how those
matrices are defined.

Once I get this version running and validated I will be open to the
idea of defining functions for evaluation at arbitrary values of the
parameters and for, say, entire matrices of responses.  Designing such
functions is more difficult that it seems and I would prefer to devote
my efforts to getting the other parts working right now.

The details of exactly how the evaluation takes place are described in
the vignette "Computational methods for mixed models" that is part of
recent versions of the lme4 package.  (That vignette is not yet
finished.  Once I have a completed version I will release it as a
technical report.)It uses a reduced set of parameters that I write as
> 2. for a different data set ?
> Respectfully,
> Andrzej
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

More information about the R-sig-mixed-models mailing list