[R-sig-ME] lmer model specification for nested random effects
Douglas Bates
bates at stat.wisc.edu
Thu Dec 9 17:40:13 CET 2010
On Thu, Dec 9, 2010 at 10:22 AM, Gustavo Betini <betinig at uoguelph.ca> wrote:
> Hi, all,
> I have a dataset with several individuals from different sites measured
> several times. There are 7 different sites and around 10 individuals
> from each site. My question is:
> Is this what Douglas Bates call "implicit nesting"? If so, the recommendation is to create a new variable
We would need to see the output of
str(data)
to decide. Assuming that there are around 70 individuals in total,
the question is whether the id factor has about 70 levels or about 10
levels. In the second case id is only meaningful within a site and to
produce unique levels for each individual it is necessary to consider
the site:id interaction.
But that is not the way that most researchers would organize the data.
The sensible thing to do is to assign a unique level to each
individual in which case (1|id) is a suitable specification.
> 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.
Because fm3 is a different model.
More information about the R-sig-mixed-models
mailing list