[R] 2 lme questions
Chuck Cleland
ccleland at optonline.net
Tue Apr 6 11:20:22 CEST 2004
Spencer Graves wrote:
> The "print" method and the "summary" command display the STANDARD
> DEVIATIONS (not the variances) on the screen (or in a sink file).
> However, when I do attributes(lme(...)) and
> attributes(summary(lme(...))), I don't see anything I can use.
> Fortunately, the "interval" function produces a list, from which the
> variance estimates can be extracted. Consider the following example:
> DF <- data.frame(group=c(1,1,2,2), y=c(1, 2, 11, 12))
> library(nlme)
> fit <- lme(y~1, random=~1|group, DF)
>
> Linear mixed-effects model fit by REML
> Data: DF
> Log-restricted-likelihood: -6.559401
> Fixed: y ~ 1
> (Intercept)
> 6.5
>
> Random effects:
> Formula: ~1 | group
> (Intercept) Residual
> StdDev: 7.053597 0.7070954
>
> Number of Observations: 4
> Number of Groups: 2
> > lme.int <- intervals(fit)
> > lme.int$reStruct^2
> Error in lme.int$reStruct^2 : non-numeric argument to binary operator
>
> > lme.int$reStruct$group^2
> lower est. upper
> sd((Intercept)) 3.06859 49.75323 806.6845
> > lme.int$sigma^2
> lower est. upper
> 0.0704255 0.4999839 3.5496217
> attr(,"label")
> [1] "Within-group standard error:"
>
> There may be a better way; if there is, I hope someone will
> enlighten us all. If not, at least this works in R 1.8.1
How about VarCorr(fit) ?
See ?VarCorr
--
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894
More information about the R-help
mailing list