[R] nested ANOVA using lme

From: David Semmens <d.semmens_at_pgrad.unimelb.edu.au>
Date: Wed 09 Aug 2006 - 19:03:49 EST


I have an ANOVA model with 2 factors "Environment" and "Site", "Diameter" is the response variable. Site should be nested within Environment. Site is also a random factor while Environment is fixed. I can do this analysis using the "aov" function by using these commands:

>model<-aov(Diam~Env+Error(Env%in%Site),data=environ)
>summary(model)
>summary(aov(Diam~Env/Site,data=environ))

But the model is unbalanced and I want to calculate estimates of the variance components. In this case the REML approach should give more reliable estimates than the method I have used. But I am unable to work out how to specify a nested factor using the "lme" function. I have tried:

>firstgo<-lme(Diam~Env+Env:Site,data=environ)
>secondgo<-lme(Diam~Env+Env%in%Site,data=environ)
>thirdgo<-lme(Diam~Env+Env/Site,data=environ)

But I keep getting this error:

Error in getGroups.data.frame(dataMix, groups) :

        Invalid formula for groups

If anyone could help me with code for specifying a random nested factor using lme that would be great.

Thanks,
David Semmens.



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed Aug 09 19:08:20 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 09 Aug 2006 - 20:22:51 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.