[R-sig-ME] lme: random effect nested within fixed effect

Federico Calboli f.calboli at imperial.ac.uk
Tue Apr 6 23:01:32 CEST 2010


On 6 Apr 2010, at 19:45, Itay Mayrose wrote:

> Hi all,
> 
> This should be a somewhat trivial question but I am new to R and I am a bit
> puzzled with the lme syntax.
> 
> I would like to test for growth difference between three types of plants.
> For each plant type I randomly sampled four populations and for each
> population several individuals.
> 
> First, I used lme where type is the fixed effect and population is random
> nested within type, but I am not sure which of the three options the correct
> syntax is:
> 
> (1)
> 
> z1 <- lme(growth ~ type, random = ~ 1 | population, data =
> times,method="ML")

depending how you coded population the above is fine. If your have, for instance, type : A, B, C, then populations coded as 1,2,3 in each type, the syntax above will NOT work.

BUT

If you have type A, B, C, then population as 1,2,3,4,5,6 (ideally as.factor(population)), or as A1, A2, A3, B1, B2...C3, the syntax above will work as if by magic, because I have tried it many times and lme --and lmer I presume, is smart enought to see that since population A1 is only found in conjunction with type A, population is nested in type. Prof Bates can possibly give the details of why it is so, I think it's due to variance components, but I suspect you might not need the fine stats details at this point.

HTH

Federico






> 
> (2)
> 
> z1 <- lme(growth ~ type, random = ~ 1 | type/population, data =
> times,method="ML")
> 
> (3)
> 
> z1 <- lme(growth ~ type, random = ~ type | population, data =
> times,method="ML")
> 
> 
> 
> I am using the ML method because I would like to contrast this model against
> a NULL model where growth does not depend on plant type (assuming the first
> syntax is correct):
> 
> z0 <- lme(growth ~ 1, random = ~ type | population, data =
> times,method="ML")
> 
> anova(z0,z1)
> 
> 
> 
> Thanks!
> Khilik
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

--
Federico C. F. Calboli
Department of Epidemiology and Biostatistics
Imperial College, St. Mary's Campus
Norfolk Place, London W2 1PG

Tel +44 (0)20 75941602   Fax +44 (0)20 75943193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] gmail.com




More information about the R-sig-mixed-models mailing list