[R] A question on lme in R

Douglas Bates bates at stat.wisc.edu
Fri Feb 20 19:49:14 CET 2004

Zonghui Hu <zhu at stat.tamu.edu> writes:

> I have a question on using lme on a mixed effects model with nested
> error structure. After applying lme to the data, and put the outcome
> in, say TR.lme. I can extract the fixed effects by
> TR.lme$coef$fixed. However, when I use TR.lme$coef$random.effects, it
> does not give the variance components that I need, but a vector of
> values at each nested level. What I want are the estimated variance
> components that show up with summary(TR.lme), but I can not extract
> them from TR.lme.

It is better to use the extractor functions fixef (or fixed.effects)
and ranef (of random.effects) to extract the estimated coefficients.
You should not depend on a particular internal representation of the
object returned from a model-fitting function.  For example, objects
returned by the version of lme in the lme4 package uses a different
internal representation.

As indicated in the output from
 help(package = "nlme")
the function VarCorr returns the variance and correlation components.

Douglas Bates                            bates at stat.wisc.edu
Statistics Department                    608/262-2598
University of Wisconsin - Madison        http://www.stat.wisc.edu/~bates/

More information about the R-help mailing list