[R-sig-ME] Fwd: help with a cross-classified random effects model code in R.
bates at stat.wisc.edu
Wed Sep 3 16:32:50 CEST 2008
On Wed, Sep 3, 2008 at 7:52 AM, Daniel Ezra Johnson
<danielezrajohnson at gmail.com> wrote:
> Am I right that if the primary schools were nested within the
> secondary schools, the model would still be fit with the exact same
The short answer is "Yes".
The somewhat longer answer is "Yes, as long as you have coded the
primary schools so that each distinct school has a distinct label".
If you can't imagine why someone would do something other than code
the distinct schools with distinct labels then you should stop reading
now. The rest of the discussion is about why a peculiar but
commonplace practice of coding something like the primary schools
using implicitly nested factors could trip you up.
The only time that the distinction between nested and non-nested is
important is when the "inner" factor is coded using implicit nesting.
Suppose that the primary schools were nested within the secondary
schools and instead of coding the 148 primary schools as a factor
having 148 levels they were coded as a factor with, say, 20 levels
with the implicit understanding that primary school 1 feeding
secondary school 1 is different from primary school 1 feeding
secondary school 2. It is a peculiar and error-prone way of doing
things but it is also widely used. In that case all that is necessary
is to create a primary school factor as the interaction of the
secondary school and the "primary within secondary" factor.
> On Wed, Sep 3, 2008 at 1:44 PM, Douglas Bates <bates at stat.wisc.edu> wrote:
>> On Wed, Sep 3, 2008 at 7:14 AM, Stijn Ruiter <s.ruiter at maw.ru.nl> wrote:
>>> Dear Dr. Bates,
>>> You replied to a question by Violet(Shu) Xu on how to estimate
>>> cross-classified (XC) models. In the DIGEST version however, no example
>>> code is provided.
>>> In general, how do we estimate XC models using lme4?
>>> Is the following example for a null model for some dependent variable Y
>>> for pupils who attended specific primary and secondary schools correct?
>>> Or does lmer then estimate a nested model?
>> That will estimate the model with crossed random effects.
More information about the R-sig-mixed-models