in lme() you need to specify the random-effects with a formula passed to the 'random' argument, e.g., something like
fit <- lme(Diam ~ Env + Site, random = ~ 1 | Env / Site, data = environ) summary(fit) I hope it helps. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: "David Semmens" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Wednesday, August 09, 2006 11:03 AM Subject: [R] nested ANOVA using lme >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. > > ______________________________________________ > [email protected] 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. > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm ______________________________________________ [email protected] 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.
