[R] unbalanced effects in aov

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Sep 18 18:38:37 CEST 2007


On Fri, 14 Sep 2007, Brooke LaFlamme wrote:

> Hi, I have been having some trouble using aov to do an anova, probably 
> because I'm not understanding how to use this function correctly. For 
> some reason it always tells me that "Estimated effects may be 
> unbalanced", though I'm not sure what this means. Is the formula I am 
> using written incorrectly? Below is the code I am using along with the 
> data:

[...]

> I am treating all the variables as factors (except for response, obviously).
>
> formula<-response~species+line%in%species+replicate%in%line+sex%in%species+plate
> model<-aov(formula, data=my.data)
>
> This is the output:
>
>> model
> Call:
>   aov(formula = formula, data = my.data)
>
> Terms:
>                     species        plate species:line line:replicate
> Sum of Squares  0.0026469288 0.0000945202 0.0003320255   0.0002008000
> Deg. of Freedom            2           11           27             10
>                 species:sex    Residuals
> Sum of Squares  0.0001383116 0.0006315465
> Deg. of Freedom            3           66
>
> Residual standard error: 0.003093362
> Estimated effects may be unbalanced
>
> Any help would be greatly appreciated as the R help documentation for 
> aov does not address this issue.

For the benefit of those who are unable to appreciate 
fortunes::fortune("WTFM"), the help page actually says

      'aov' is designed for balanced designs, and the results can be
      hard to interpret without balance: beware that missing values in
      the response(s) will likely lose the balance.  If there are two or
      more error strata, the methods used are statistically inefficient
      without balance, and it may be better to use 'lme'.

      Balance can be checked with the 'replications' function.

So let's do as it suggests:

> replications(formula, data=my.data)
$species
[1] 40

$plate
plate
  1  2  3  4  5  6  7  8  9 10 11 12
11 11 11 10  9 11 10 11 10 11  9  6

$`species:line`
[1] 4

$`line:replicate`
[1] 6

$`species:sex`
[1] 20

and the problem will be clear to those who have read ?replications.

-- 
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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list