[R] nested ANOVA using lme

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.be
Wed Aug 9 11:24:42 CEST 2006


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" <d.semmens at pgrad.unimelb.edu.au>
To: <r-help at stat.math.ethz.ch>
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.
>
> ______________________________________________
> R-help at 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.
> 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



More information about the R-help mailing list