[R] how to run a mixed design ANOVA with repeated measures

Gilbert G gilbertoinuk at googlemail.com
Tue Sep 11 14:30:36 CEST 2007


Hi, I would like to run an ANOVA with repeated measures with both a
between subjects variable and within subjects (repeated measures)
variables.  I know how to do this when I have equal numbers of
subjects in both groups (i.e., balanced design).  That has been very
well documented by Baron, for example, see:

http://cran.r-project.org/doc/contrib/Baron-rpsych.pdf

On page 34 of this document, section 6.8.5, Baron & Li example
wonderfully how to run a 'balanced' ANOVA with one between  and two
within subject varialbes (6.8.5 Example 5: Stevens pp. 468 – 474 (one
between, two within)).

The R code in their example is:

summary(aov(effect  ̃ gp * drug * dose + Error(subj/(dose+drug)), data=Ela.uni))

The between subjects variable is gp, whereas drug and dose are within
subject variables.

Now, my question is, how would I do this very same analysis if there
were *different* numbers of subjects in the groups (that is,
'unbalanced')?  Clearly, the 'aov' function is not appropriate for
this!   (help(aov) says: 'aov' is designed for balanced designs, and
the results can be hard to interpret without balance)

I have found suggestions that this problem might be solved with the
'lme' function of the 'nlme' library, but it is entirely unclear to me
how and I could not find an answer anywhere in the r forums.

Thank you so much for your help.



More information about the R-help mailing list