# [R] library(car): Anova and repeated measures without between subjects factors

John Fox jfox at mcmaster.ca
Tue Oct 16 21:04:51 CEST 2007

```Dear Ralf,

Unfortunately, Anova.mlm(), and indeed Anova() more generally, won't
handle a model with only a constant. As you point out, this isn't
reasonable for repeated-measures ANOVA, where it should be possible to
have only within-subjects factors. When I have a chance, I'll see what
I can do to fix the problem -- my guess is that it shouldn't be too
hard.

Thanks for pointing out this limitation in Anova.mlm()

John

On Tue, 16 Oct 2007 17:20:07 +0200
Ralf Goertz <R_Goertz at web.de> wrote:
> Hi,
>
> sorry if this is explained somewhere but I didn't find anything.
>
> How can I use "Anova" from the car package to test a modell without
> between subject's factors? Suppose I have the following data
>
>    mat.1 mat.2 mat.3 di ex
> 1     85    85    88  1  1
> 2     90    92    93  1  1
> 3     97    97    94  1  1
> 4     80    82    83  1  1
> 5     91    92    91  1  1
> 6     83    83    84  2  1
> 7     87    88    90  2  1
> 8     92    94    95  2  1
> 9     97    99    96  2  1
> 10   100    97   100  2  1
> 11    86    86    84  1  2
> 12    93   103   104  1  2
> 13    90    92    93  1  2
> 14    95    96   100  1  2
> 15    89    96    95  1  2
> 16    84    86    89  2  2
> 17   103   109    90  2  2
> 18    92    96   101  2  2
> 19    97    98   100  2  2
> 20   102   104   103  2  2
> 21    93    98   110  1  3
> 22    98   104   112  1  3
> 23    98   105    99  1  3
> 24    87   132   120  1  3
> 25    94   110   116  1  3
> 26    95   126   143  2  3
> 27   100   126   140  2  3
> 28   103   124   140  2  3
> 29    94   135   130  2  3
> 30    99   111   150  2  3
>
> Using
>
> >
>
Anova(lm(mat~di*ex,data=data),idata=data.frame(zeit=ordered(1:3)),idesign=~zeit)
>
> Type II Repeated Measures MANOVA Tests: Pillai test statistic
>            Df test stat approx F num Df den Df    Pr(>F)
> di          1     0.377   14.524      1     24 0.0008483 ***
> ex          2     0.800   47.915      2     24 4.166e-09 ***
> di:ex       2     0.281    4.695      2     24 0.0190230 *
> zeit        1     0.782   41.209      2     23 2.491e-08 ***
> di:zeit     1     0.252    3.865      2     23 0.0357258 *
> ex:zeit     2     0.836    8.611      4     48 2.538e-05 ***
> di:ex:zeit  2     0.518    4.189      4     48 0.0054586 **
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> works as expected. But every once in a while I have a model without
> between subject's factors. So I thought of
>
> >
>
Anova(lm(mat~1,data=data),idata=data.frame(zeit=factor(1:3)),idesign=~zeit)
> Fehler in L %*% B : nicht passende Argumente
>
> (Error in L %*% B : non matching arguments)
>
> On the other hand using anova.mlm I get
>
> >
>
anova.mlm(lm(mat~1,data),idata=data.frame(zeit=factor(1:3)),X=~1,test="Spherical")
> Analysis of Variance Table
>
>
> Contrasts orthogonal to
> ~1
>
> Greenhouse-Geisser epsilon: 0.7464
> Huynh-Feldt epsilon:        0.7777
>
>             Df      F num Df den Df     Pr(>F)     G-G Pr     H-F Pr
> (Intercept)  1 11.767      2     58 5.1375e-05 3.1183e-04 2.4939e-04
> Residuals   29
>
>
> How can achieve this with Anova?
>
>
> Thanks in advance,
>
> Ralf
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

--------------------------------
John Fox, Professor
Department of Sociology
McMaster University