[R] nested ANOVA using lme

David Semmens d.semmens at pgrad.unimelb.edu.au
Wed Aug 9 11:03:49 CEST 2006

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:


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 


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.

David Semmens.

More information about the R-help mailing list