[R-sig-ME] Nesting notation for lmer

McMahon, Sean mcmahons at si.edu
Tue Feb 23 18:48:38 CET 2010


I have seen online a few different approaches to creating formulas with nested random effects in lmer(), as well as indication that the program automatically interprets nesting based on indicator variables.  What is the final word on how to construct a three-level model that is nested?

I'm not including real variables in the hope that this is straightforward enough to propose a simple template.

For a simple random intercept model where an individual is nested within a group variable level1 which is in turn nested within a community variable level2 , would a simple, nested model be:

lmer(y ~ 1 + (1 | level1) + (1 | level2) )  # this would assume that the program can intuit nestedness

lmer(y ~ 1 + (1 |level2 : level1) + (1 | level2) )  # I've seen examples of this, but cannot get it to run with my data

lmer(y ~ 1 + (1 | level1) + (level1 | level2) )  #  this runs, but with slightly different results from the first example, but I don't feel confident that it is correct.

Thanks for help on this,

Sean




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