[R] Nested ANOVA models in R

Bill.Venables at csiro.au Bill.Venables at csiro.au
Wed Feb 6 05:58:52 CET 2008


Here is a short example:

> dat <- data.frame(x = rnorm(20), 
		a = rep(letters[1:4], 5), 
		b = rep(letters[1:5], each = 4))
> summary(aov(x ~ a*b, dat))
            Df  Sum Sq Mean Sq
a            3  0.8021  0.2674
b            4  3.7175  0.9294
a:b         12 10.5416  0.8785
> summary(aov(x ~ a/b, dat))
            Df  Sum Sq Mean Sq
a            3  0.8021  0.2674
a:b         16 14.2590  0.8912
>  

So in your nested case you should not get a mean square for 'Female' at
all.  The interaction sum of squares in the nested case is the sum of
the main effect and interaction in the crossed model case, (as are the
degrees of freedom).

Although you think of them as different models, in a mathematical sense
they are equivalent - you just parcel the degrees of freedom and SSQ a
bit differently in the sequential anova.

Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary):  +61 7 3826 7304
Mobile:                         +61 4 8819 4402
Home Phone:                     +61 7 3286 7700
mailto:Bill.Venables at csiro.au
http://www.cmis.csiro.au/bill.venables/ 

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Daniel Bolnick
Sent: Wednesday, 6 February 2008 2:28 PM
To: r-help at r-project.org
Subject: [R] Nested ANOVA models in R

Hi,

I'm trying to work through a Nested ANOVA for the following scenario: 
20 males were used to fertilize eggs of 4 females per male, so that 
female is nested within male (80 females used total). Spine length 
was measured on 11 offspring per family, resulting in 880 
measurements on 80 families.

I used the following two commands:

summary(aov(Spinelength ~ Male*Female))

and
summary(aov(Spinelength ~ Male/Female))

I get the same mean squares either way, which doesn't seem right to 
me. In the former case, the mean square for females should be 
calculated around the overall mean across all females, whereas the 
mean square in the latter case should be calculated using deviations 
from the set of 4 females nested within a given male, right?

Of course, it is more appropriate for me to treat each of these as 
random effects. I know Bates has objections to the SAS-style 
partitioning variances to obtain F statistics and p-values, and I 
have read relevant parts of Pinhero and Bates, but how can a specify 
a nested random effects model that yields p-values for both the males 
(tested against MS for females) and females nested within males?

Thanks,

Dan Bolnick
Section of Integrative Biology
University of Texas at Austin

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list