[R] cross-classified random factors in lme without blocking

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Sat Nov 15 19:29:26 CET 2003



Gordon Smyth wrote:

> Many thanks for help from Peter Dalgaard, Douglas Bates and Bill 
> Venables. As a result of their help, here is a working example of using 
> lme to fit an additive random effects model. The model here is 
> effectively y~a+b with a and b random:
> 
> y <- rnorm(12)
> a <- gl(4,1,12)
> b <- gl(3,4,12)
> u <- gl(1,1,12)
> library(nlme)
> fm <- lme(y~1,random=list(u=pdBlocked(list(pdIdent(~a-1),pdIdent(~b-1)))))
> summary(fm)
> 
> I still can't see though how to extract the three variance components 
> (for a and b and for the residual) from the fitted object 'fm'.
> 
> Thanks
> Gordon
> 

Would this work for you? It still needs some parsing to extract sigma_a 
and sigma_b, but that should be simple.

v <- as.matrix(fm$modelStruct$reStruct$u)
c(sqrt(diag(v)), Residual = 1) * fm$sigma

Regards,
Sundar




More information about the R-help mailing list