[R] Accessing the fixed- and random-effects variance-covariance matrices of an nlme model

Douglas Bates bates at stat.wisc.edu
Thu Sep 27 17:00:41 CEST 2007


On 9/26/07, Rob Forsyth <r.j.forsyth at newcastle.ac.uk> wrote:
> I would appreciate confirmation that the function vcov(model.nlme)
> gives the var-cov matrix of the fixed effects in an nlme model.

It gives the approximate variance-covariance matrix for the
fixed-effects parameters in the model.  (Exact variance-covariance
matrices are very difficult to evaluate for nonlinear models and even
more difficult to evaluated for nonlinear mixed-effects models.)

The documentation for the generic function vcov and some of its
methods can be accessed by

?vcov.lme


> Presumably the random-effects var-cov matrix is given by cov(ranef
> (model.nlme)?

No.  The BLUPs of the random effects (actually as Alan James described
the situation, "For a nonlinear model these are just like the BLUPs
(Best Linear Unbiased Predictors) except that they are not linear, and
they're not unbiased, and there is no clear sense in which they are
"best" but, other than that, ...") are not guaranteed to have an
observed variance-covariance matrix that corresponds to the estimate
of the variance-covariance matrix of the random effects.  These
estimates are returned by the VarCorr function.  See ?VarCorr

The implementation of VarCorr in the nlme package is not optimal in
that it returns the result as a character matrix and you need to
covert to a numeric representation if you want to do anything other
than print it out.  I prefer the implementation in the lme4 package
which returns a list of numeric matrices that are formatted by a
specific function (called formatVC but hidden in the lme4 package's
namespace) when needed.



More information about the R-help mailing list