[R-sig-ME] complex cross classified model
Douglas Bates
bates at stat.wisc.edu
Fri Oct 2 14:04:03 CEST 2009
On Thu, Oct 1, 2009 at 3:49 PM, Sven De Maeyer <sven.demaeyer at ua.ac.be> wrote:
> Hi all,
>
> I'm analysing data with the following structure:828 students nested within
> 138 schools. Every student supplied 13 items (wright/wrong). The data set
> contains 13 lines for every student. I consider a random effect for items as
> well. The model was set-up as follows, with the resulting output are
> presented at the bottom. My question now is whether setting-up the model
> like this implies that ITEM and IDSTUD are crossed and IDSTUD's are nested
> within SCHOOLS. Or do I make a mistake here?
>
>> Model1<-lmer(SCORE~1+(1|IDSCHOOL)+(1|IDSCHOOL:IDSTUD)+(1|ITEM),data=Items,
>> family=binomial)
>> summary(Model1)
> Generalized linear mixed model fit using Laplace
> Formula: SCORE ~ 1 + (1 | IDSCHOOL) + (1 | IDSCHOOL:IDSTUD) + (1 | ITEM)
> Data: Items
> Family: binomial(logit link)
> AIC BIC logLik deviance
> 10761 10790 -5376 10753
> Random effects:
> Groups Name Variance Std.Dev.
> IDSCHOOL:IDSTUD (Intercept) 0.772882 0.87914
> IDSCHOOL (Intercept) 0.076846 0.27721
> ITEM (Intercept) 1.727892 1.31449
> number of obs: 10764, groups: IDSCHOOL:IDSTUD, 828; IDSCHOOL, 138; ITEM, 13
>
> Estimated scale (compare to 1 ) 0.9272256
>
> Fixed effects:
> Estimate Std. Error z value Pr(>|z|)
> (Intercept) 0.8852 0.3676 2.408 0.0160 *
> ---
That model specification seems fine to me. If the student labels are
828 unique labels (that is, if it is not the case that different
schools can each have a student with the same IDSTUD) then the
specification (1|IDSCHOOL:IDSTUD) could be shortened to (1|IDSTUD).
However, specifying (1|IDSCHOOL:IDSTUD) is not harmful in any way and
is safer so I would stay with that.
When random effects are associated with different factors, lmer does
not distinguish between nested and non-nested factors. It just uses
the factors as they are specified. In fact, the calculations are
identical for nested or non-nested. The only thing that happens with
nested factors is that some of the model structures are simpler but
that is a side-effect, not an assumed property.
I think I am running the risk of over-explaining, a common fault of
mine. The short answer is that you have got it right.
More information about the R-sig-mixed-models
mailing list