[R-sig-ME] lmer model specification for nested random effects

Federico Calboli f.calboli at imperial.ac.uk
Thu Dec 9 17:37:58 CET 2010


> Is this what Douglas Bates call "implicit nesting"? If so, the recommendation is to create a new variable

I am not sure about implicit, but I'd argue that Id is nested within site. Whether you need a new variable is difficult to say without seeing the data: in my experience, if for instance you have 30 individuals and 3 sites, coding the individuals as 1 to 30 (and changing that to factor btw) is "absolutely" unique and should be enough, while if your id are coded 1:10 for each site, your coding is "locally" unique only and a new variable is required.
> data<- within(data, {siteid<- factor(site:id)}
> And the model specification...
> fm1<- lmer(y ~ x1 + x2 + (1|siteid), data)
> which seems to be identical to
> fm2<- lmer(y ~ x1 + x2 + (1|site:id)), data)
> What is the difference between the specifications above and
> fm3<- lmer(y ~ x1 + x2 + (1|id) + (1|site), data)
> I get identical results from models fm1 and fm2, but slightly different 
> results from fm3.

I am not 100% sure, but my guess is that in fm1 you only have the (newly coded) ids as random variable, while in fm2/fm3 you have both site and id as random. The differences between fm2/fm3 are most likely to the fact you coded your individuals in a "locally" unique way, rather than in a "absolutely" unique way. Having said that, I am perplexed why fm1 and fm2 should give the same results. 



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