Hi:

The answer to your question is yes, *if* the classes have unique
identifiers. Prof. Bates' point was that using something like classes 1, 2,
3, 4 in School A and 1, 2, 3, 4, 5 in School B would create problems if you
specified
                                         (1 | school) + (1 | class)
because 1, 2, 3, 4 occur in both schools A and B. How is the software
supposed to 'know' that the values in class are nested within school?  In
this situation, you would have to use 1 | school/class to achieve the model
you expect  because of the way the nested factor was specified in the data
frame.

This has everything to do with setting up the columns of the model matrix
for random effects correctly: in the case of (1 | school) + (1 | class), the
random effects model matrix creates one set of columns for schools and
'cbinds' another set of columns for class. In the example described above,
there would be  7 columns of indicator variables (**), two for schools and
five for classes. Under the random specification (1 | School/class), there
would be 11 columns: two for schools and nine for classes: four for classes
in school A  and five for classes in school B. Different model matrices,
different answers.

OTOH, if you recode the classes in the data frame to be A1, A2, A3, A4, B1,
B2, B3, B4, B5, there is no confusion - A1 is uniquely identified with
school A, B3 is uniquely identified with school B, etc. When the classes (or
the levels of any nested factor, in general) are uniquely labeled, then
either of the two specifications of random effects can be used and will
yield the same results because they produce the same random effects model
matrix - in the above example, of 11 columns in each case. By uniquely
identifying classes, the model matrix is the same whether you specify (1 |
school) + (1 | class) [two schools + nine classes] or (1 | school/class) [2
schools, four classes for school A, five classes for school B].  In either
case, you get [S1 S2 | A1 A2 ...B4 B5] as the columns of the random effects
model matrix Z.

(**) I'm using the 'non-full rank' version of the random effects model
matrix to qualitatively illustrate the distinction between the two random
effects specifications in lmer(). The software actually uses a much more
computationally efficient reparameterization of the above idea.

HTH,
Dennis

On Fri, Nov 12, 2010 at 2:28 PM, Kay Cecil Cichini
<Kay.Cichini@uibk.ac.at>wrote:

> dear mr. bates,
>
> many thanks for answering to my mail.
> "1|school/class" is the same as "1|school + 1|class", isn't it? - this
> would be the second model i mentioned.
>
> yours,
> kay cichini
>
>
>
> Zitat von Douglas Bates <bates@stat.wisc.edu>:
>
>  On Fri, Nov 12, 2010 at 5:09 AM, Kay Cecil Cichini
>> <Kay.Cichini@uibk.ac.at> wrote:
>>
>>> dear listers,
>>>
>>> i'd very much appreciate help with setting up the right parameterization
>>> for
>>> the following design:
>>> 4 regions, in each region 3 to 12 schools, at each school 2-4 classes and
>>> each class tested before and after intervention, yielding a bimomial
>>> outcome
>>> (pupils that passed / not passed a test).
>>>
>>> i'm interested in differences between before and after (factor =
>>> "interv")
>>> intervention outcomes (X = passed, n = passed + not passed) and in the
>>> interaction region * interv.
>>>
>>> i tried with:
>>> glmer (cbind(X, n - X) ~ region * interv + (region | school / class),
>>> family
>>> = binomial)
>>>
>>
>> This model is generating an interaction between the fixed-effects
>> factor "region" and the random-effects factor "school", which doesn't
>> make sense because each school occurs within only one region.
>>
>> The simplest way to establish the desired structure is to create the
>> region, school and class factors so they follow the "each distinct
>> structure corresponds to a distinct level of the factor" rule.  For
>> example, if you call the regions "A", "B", "C" and "D" and you call
>> the schools "A01", ... "A10", "B01", ..., "B06", "C01", ..., "C12" and
>> you call the classes "A01a", "A01b", "A01c", ..., "C12d" then you can
>> specify the model very easily as
>>
>> glmer(cbind(X, n - X) ~ region * interv + (1|school) + (1|class),
>> family = binomial)
>>
>> Most of the confusion about model specification comes from the
>> unfortunate practice of labeling the schools as "01", ..., "12"
>> without taking into account that school 1 in region A is not
>> associated in any way with school 1 in region C.  In other words, all
>> you need to do is to disambiguate the names of the schools and the
>> classrooms.
>>
>>
>>  and with:
>>> glmer (cbind(X, n - X) ~ region * interv + (1 | school / class), family =
>>> binomial)
>>>
>>>
>>> i'd be happy about comments on the parameterization or any ideas.
>>>
>>> yours,
>>> kay
>>>
>>> _______________________________________________
>>> R-sig-mixed-models@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>>>
>>>
>>
> _______________________________________________
> R-sig-mixed-models@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>

	[[alternative HTML version deleted]]


