[R] Why can repeated measures anova with within & between subjects design not be done if group sizes are unbalanced?

Gilbert G gilbertoinuk at googlemail.com
Sun Nov 4 17:34:40 CET 2007


Dear R people:

I wish to switch from SPSS to R, but there is one particular type of
ANOVA design that cannot be done in R.  Or more likely, it can be
done, but it is nowhere documented.

The problem is typical for psychologists:
You have a repeated measures design with different groups of subjects.
 Now, this can be done with the aov command, but the number of
subjects in both groups must be equal (i.e., balanced design).  SPSS
allows for unbalanced designs as well.

If you are still with me, let me just give you an example of what R
can and cannot do so far.  Imagine I have a 2x2 within subjects design
and I have 2 groups (e.g., group healthy and patients, which is stored
in MyGroup).  And imagine I measure reaction time RT in four
conditions, say, in a color condition (red vs green) and in a shape
condition (square vs circle).

Now, in R you would have something like, as anybody who does balanced
repeated measures anova's might know:

aov( RT ~ color * shape * MyGroup + Error( Subjects/( color*shape) )

In spss you would have something like this (of course with the data
organized slightly differently :

GLM
x1 x2 x3 x4 BY MyGroup
 /WSFACTOR = color 2 Polynomial shape 2 Polynomial
 /METHOD = SSTYPE(3)
 /CRITERIA = ALPHA(.05)
 /WSDESIGN = color shape color*shape
 /DESIGN = VAR00001 .

Ok, the question is.  If the group sizes are different (say 10 people
in one group and 12 people in the other group) R is going to give the
wrong answer.  Of course that is not R's fault.

BUT MY QUESTION IS: HOW TO GET THE UNBALANCED REPEATED MEASURES ANOVA RIGHT?

Thanks for the answer!



More information about the R-help mailing list