[R] lmer function

Douglas Bates bates at stat.wisc.edu
Mon May 14 21:43:12 CEST 2007


On 5/14/07, Iasonas Lamprianou <lamprianou at yahoo.com> wrote:
> Does anyone know if the lmer function of lme4 works fine for unbalanced designs? I have the examination results of 1000 pupils on three subjects, one score every term. So, I have three scores for English (one for every term), three scores for maths etc. However, not everybody was examined in maths, not everybody was examined in English etc, but everybody was in effect examined on four subjects. I also have information abouit the school. Would this model hive the right results for the variance components?
>
> mod_3_f  <- lmer(SCORE ~ GENDER + (1 |ID ) + (1 | TERM) + (1 | SUBJECT)  , Dataset)
>
> Linear mixed-effects model fit by REML
> Formula: SCORE ~ GENDER + (1 | ID) + (1 | TERM) + (1 | SUBJECT)
>    Data: Dataset
>     AIC    BIC  logLik MLdeviance REMLdeviance
>  247882 247926 -123936     247871       247872
> Random effects:
>  Groups   Name        Variance Std.Dev.
>  ID       (Intercept) 5.97288  2.44395
>  TERM     (Intercept) 5.10307  2.25900
>  SUBJECT  (Intercept) 0.25943  0.50934
>  Residual             4.41673  2.10160
> number of obs: 53978, groups: ID, 5695; TERM, 4; SUBJECT, 4
> Fixed effects:
>                Estimate Std. Error t value
> (Intercept)    14.30352    1.15870   12.34
> GENDER[T.Male] -1.01776    0.06885  -14.78
> Correlation of Fixed Effects:
> Warning in x$symbolic.cor : $ operator not defined for this S4 class, returning NULL

What version of the lme4 package are you using?  (Use sessionInfo() to
check.)  I think the bug that causes that warning has been fixed in
the most recent version.

>             (Intr)
> GENDER[T.M] -0.023

> How do I interpert the results?

Do you really want to treat SUBJECT as a random effect?  I think it
would be more common to treat it as a fixed effect.  If I understand
you correctly there are only two levels of SUBJECT and these are
repeatable levels. If that is the case one could model SUBJECT as a
fixed effect or consider its interaction within student with the term
(SUBJECT|ID).

It would make sense to regard the pair of responses in maths and
English for each student in each term as a multivariate response but,
at present, that model cannot be fit with lmer.

I would also question whether you want the TERM to be modeled with a
random effect.



More information about the R-help mailing list