[R] help on extract variance components from the fitted model by lm
wenqing li
wenqingli at gmail.com
Sat Apr 16 20:38:54 CEST 2005
Hey, all: Do we have a convenient command(s) to extract the variance
components from a fitted model by lm (actually it's a nexted model)?
e.g.: using the following codes we could get MSA,MSB(A) and MSE. How
to get the variance component estimates by command in R rather than
calculations by hand?
A<-as.vector(rep(c(rep(1,5), rep(2,5), rep(3,5), rep(4,5), rep(5,5)),2))
B<-as.vector(rep(c(rep(c(1,2,3,4,5),5)),2))
y<-as.vector(c(15.5,15.2,14.2,14.3,15.8,6.2,7.2,6.6,6.2,5.6,15.4,13.9,13.4,12.5,13.2,10.9,12.5,12.3,11.0,12.3,7.5,6.7,7.2,7.6,6.3,14.9,15.2,14.2,14.3,16.4,7,8.4,7.8,7.6,7.4,14.4,13.3,14.8,14.1,15,11.3,12.7,11.7,12,13.3,6.7,7.3,6,7.6,7.1))
lm1<-lm(y~factor(A)/factor(B))
anova(lm1)
Thanks a lot! And have a good weekend!
Regards,
Wenqing
More information about the R-help
mailing list