Skip to content
Prev 168131 / 398502 Next

Anova and unbalanced designs

Nils Skotara wrote:
This looks like a contrast parametrization issue: If we look at the 
per-group mean within-differences and their SE, we get

 > summary(lm(within1-within2~between - 1))
..
Coefficients:
          Estimate Std. Error t value Pr(>|t|)
between1  -1.0000     0.8165  -1.225    0.256
between2   0.3333     0.6667   0.500    0.631
..
 > table(between)
between
1 2
4 6

Now, the type II F test is based on weighting the two means as you would 
after testing for no interaction

 > (4*-1+6*.3333)^2/(4^2*0.8165^2+6^2*0.6667^2)
[1] 0.1500205

and type III is to weight them as if there had been equal counts

 > (5*-1+5*.3333)^2/(5^2*0.8165^2+5^2*0.6667^2)
[1] 0.400022

However, the result above corresponds to looking at group1 only

 > (-1)^2/(0.8165^2)
[1] 1.499987

It helps if you choose orhtogonal contrast parametrizations:

 > options(contrasts=c("contr.sum","contr.helmert"))
 > betweenanova <- lm(values ~ between)> Anova(betweenanova, idata=with, 
idesign= ~as.factor(within), type = "III" )

Type III Repeated Measures MANOVA Tests: Pillai test statistic
                           Df test stat approx F num Df den Df    Pr(>F)
(Intercept)                1     0.963  209.067      1      8 5.121e-07 ***
between                    1     0.348    4.267      1      8   0.07273 .
as.factor(within)          1     0.048    0.400      1      8   0.54474
between:as.factor(within)  1     0.167    1.600      1      8   0.24150
---
Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1