[R] Anova and unbalanced designs

Skotara nils.skotara at uni-hamburg.de
Fri Jan 23 18:15:37 CET 2009


Dear R-list!

My question is related to an Anova including within and between subject 
factors and unequal group sizes.
Here is a minimal example of what I did:

library(car)
within1 <- c(1,2,3,4,5,6,4,5,3,2); within2 <- c(3,4,3,4,3,4,3,4,5,4)
values <- data.frame(w1 = within1, w2 = within2)
values <- as.matrix(values)
between <- factor(c(rep(1,4), rep(2,6)))
betweenanova <- lm(values ~ between)
with <- expand.grid(within = factor(1:2))
withinanova <- Anova(betweenanova, idata=with, idesign= 
~as.factor(within), type = "III" )

I do not know if this is the appropriate method to deal with unbalanced 
designs.

I observed, that SPSS calculates everything identically except the main 
effect of the within factor, here, the SSQ and F-value are very different
If selecting the option "show means", the means for the levels of the 
within factor in SPSS are the same as:
mean(c(mean(values$w1[1:4]),mean(values$w1[5:10]))) and
mean(c(mean(values$w2[1:4]),mean(values$w2[5:10]))).
In other words, they are calculated as if both groups would have the 
same size.

I wonder if this is a good solution and if so, how could I do the same 
thing in R?
However, I think if this is treated in SPSS as if the group sizes are 
identical,
then why not the interaction, which yields to the same result as using 
Anova()?

Many thanks in advance for your time and help!




More information about the R-help mailing list