# [R] Unbalanced ANOVA in R?

Prof Brian D Ripley ripley at stats.ox.ac.uk
Fri Mar 8 07:24:27 CET 2002

```On Fri, 8 Mar 2002, Fredrik Karlsson wrote:

> Hi all
>
> I'm trying to complete a textbook example originally designed for SPSS
> in R, and I therefore need to find out how to compute an unbalanced
> ANOVA in R.
>
> I did a search on the mailinglist archives an found a post by Prof.
> Ripley saying one should use the lme function for (among other things)
> unbalanced ANOVAs, but I have not been able to use this object.
> My code gives me an error.. Why is that ?
>
> > aov(lme(DELAY ~ DOSE + TRIALS,data=epinuneq))
> > Error in getGroups.data.frame(dataMix, groups) :
> > 	Invalid formula for groups
>
> Any ideas? How do I get an ANOVA computation that can handle uniqual
> sampe sizes in R?

I said use lme, *not* aov and lme.  Note, though, that the advice applied
to multistrata unbalanced anova, and this appears to be a two-way layout in
one stratum.  You can use aov for that. (You can't use lme unless there are
two or more strata.)  Just be careful how you interpret the output: in SAS
parlance aov gives you `Type I' sums of squares.

The reason why this is more difficult in R is that R unlike SPSS does not
guess which of the many possible interpretations you mean.  We would need
to know a lot more about the actual statistical problem to tell you what
would be a good analysis in R.

Maybe you should look at a textbook designed for use with S/R not SPSS?

--
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```