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

Ralf Goertz R_Goertz at web.de
Wed Oct 17 12:00:18 CEST 2007

```John Fox, Dienstag, 16. Oktober 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()

Dear John,

I am looking forward to your having a chance. There is one thing that I
would like to request, though. Greenhouse-Geisser and Huyn-Feldt eps
sphericity test? I know this can be done with mauchly.test() but it
would be nice to have it in the summary of Anova().

However, there is one more thing. Look at the following data

> c1<-c(-6.0,-10.3,-2.9,-8.3,-10.0,5.3,-7.7,-0.8,9.1,-6.2)
> mat<-matrix(c(c1,c1),10,2)
> mat
[,1]  [,2]
[1,]  -6.0  -6.0
[2,] -10.3 -10.3
[3,]  -2.9  -2.9
[4,]  -8.3  -8.3
[5,] -10.0 -10.0
[6,]   5.3   5.3
[7,]  -7.7  -7.7
[8,]  -0.8  -0.8
[9,]   9.1   9.1
[10,]  -6.2  -6.2

> bf<-ordered(rep(1:2,5))
> bf
[1] 1 2 1 2 1 2 1 2 1 2
Levels: 1 < 2

Since the two columns of mat are equal:

> t.test(mat[,1],mat[,2],paired=T)

Paired t-test

data:  mat[, 1] and mat[, 2]
t = NaN, df = 9, p-value = NA
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
NaN NaN
sample estimates:
mean of the differences
0

I would assume to either get a warning or a F-value of 0 for the
repeated factor zeit but actually:

> Anova(lm(mat~bf),idata=data.frame(zeit=ordered(1:2)),idesign=~zeit)

Type II Repeated Measures MANOVA Tests: Pillai test statistic
Df test stat approx F num Df den Df Pr(>F)
bf       1    0.0020   0.0163      1      8 0.9016
zeit     1    0.2924   3.3059      1      8 0.1065
bf:zeit  1    0.0028   0.0221      1      8 0.8854

whereas

> anova.mlm(lm(mat~bf),X=~1,idata=data.frame(zeit=ordered(1:2)))

Error in anova.mlm(...) :
residuals have rank 1 < 2

This is quite dangerous. In a real data situation I accidentally used
the same column twice and I got a significant effect for the factor
zeit! I hope it wouldn't be too hard to fix this. too.

Ralf

```