[R] Re: anova grouping of factors in lme4 / lmer

William Valdar valdar at well.ox.ac.uk
Fri Feb 25 13:45:51 CET 2005


Hi. Yesterday a revised version of lme4 came out that makes my question 
unnecessary. I was using the latest version available from my mirror 
(which was 6 days old rather than 1 day old).

Please disregard my earlier posting. Thanks.

William

On Fri, 25 Feb 2005, William Valdar wrote:

> Hi. I'm using lmer() from the lme4 package (version 0.8-3) and I can't get
> anova() to group variables properly. I'm fitting the mixed model
>
> Response ~ Weight + Experimenter + (1|SUBJECT.NAME) + (1|Date.StudyDay)
>
> where Weight is numeric and Experimenter is a factor, ie,
>
>> str(data.df)
> `data.frame':	4266 obs. of  5 variables:
> $ SUBJECT.NAME : Factor w/ 2133 levels "A0480","A0..",..: 1 1 2 2 ...
> $ Response     : num  -0.490  0.145  1.992 -0.391  0.917 ...
> $ Date.StudyDay: Factor w/ 161 levels "16","22","24",..: 24 24  ...
> $ Experimenter : Factor w/ 7 levels "amyt","carmena",..: 5 5 1 1 3 3 ...
> $ Weight       : num  25.3 25.3 16.7 16.7 28.2 28.2 27.1 27.1 ...
>
> The model fits fine but when I call anova() to see the effect of the
> Experimenter factor, I get a sequential anova table where factor
> levels are fit one at a time, ie,
>
>> anova(lmer(Response ~ Weight + Experimenter
> +        + (1 | SUBJECT.NAME) + (1 | Date.StudyDay),
> +        data=data.df))
> Analysis of Variance Table
>                     Df  Sum Sq Mean Sq  Denom F value    Pr(>F)
> Weight                1    10.8    10.8 4242.0 14.4457 0.0001463 ***
> Experimentercarmena   1     0.5     0.5 4242.0  0.6708 0.4128136
> Experimentercnunez    1     4.8     4.8 4242.0  6.5042 0.0107969 *
> Experimenterlsolberg  1     0.4     0.4 4242.0  0.5910 0.4420783
> Experimenterpeterb    1 0.01430 0.01430 4242.0  0.0192 0.8898029
> Experimenterpolinka   1     0.2     0.2 4242.0  0.2290 0.6322775
> Experimenterstuart    1     0.9     0.9 4242.0  1.2505 0.2635116
>
> ... rather than what I want, which is a sequential anova table where the
> levels are grouped, eg [using lme()],
>
>> anova(lme(Response ~ Weight + Experimenter, random = ~ 1 | SUBJECT.NAME,
> +       data=data.df))
> Analysis of Variance Table
>             Df Sum Sq Mean Sq  Denom F value    Pr(>F)
> Weight        1    9.5     9.5 4242.0 12.7213 0.0003655 ***
> Experimenter  6    8.5     1.4 4242.0  1.9067 0.0759496 .
>
> Does anyone know how to make anova() group properly with lmer objects?
>
> Many thanks,
>
> William
>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> Dr William Valdar               ++44 (0)1865 287 717
> Wellcome Trust Centre           valdar at well.ox.ac.uk
> for Human Genetics, Oxford      www.well.ox.ac.uk/~valdar
>
>

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Dr William Valdar               ++44 (0)1865 287 717
Wellcome Trust Centre           valdar at well.ox.ac.uk
for Human Genetics, Oxford      www.well.ox.ac.uk/~valdar




More information about the R-help mailing list