Skip to content
Prev 14273 / 398502 Next

two way ANOVA with unequal sample sizes

Dear Julien,
At 09:33 PM 16/10/2001 +0200, julien claude wrote:
You've apparently reversed the data columns for gender and bone development.
The problem is that the analysis in Neter et al. uses what are sometimes 
called "type III" sums of squares -- that is, testing each term in the 
model 'after' all others (including main effects 'after' interactions to 
which the main effects are marginal). Some would argue that this *never* 
makes sense, but it *certainly* doesn't make sense if you use 
"contr.treatment" to code contrasts for factors, which is the default in R.

To get the results in Neter, you can use contr.sum or contr.helmert with 
lm, along with the Anova function in the car package:

     > library(car)
     >
     > Anova(lm(growth.rate  ~ gender * bone,
     +     contrasts=list(gender='contr.sum', bone='contr.sum')),
     +     type='III')
     Anova Table (Type III tests)

     Response: growth.rate
                 Sum Sq Df  F value    Pr(>F)
     (Intercept) 34.680  1 213.4154 4.729e-07 ***
     gender       0.120  1   0.7385  0.415160
     bone         4.190  2  12.8914  0.003145 **
     gender:bone  0.075  2   0.2321  0.798034
     Residuals    1.300  8
     ---
     Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
     >
     > Anova(lm(growth.rate  ~ gender * bone,
     +     contrasts=list(gender='contr.helmert', bone='contr.helmert')),
     +     type='III')
     Anova Table (Type III tests)

     Response: growth.rate
                 Sum Sq Df  F value    Pr(>F)
     (Intercept) 34.680  1 213.4154 4.729e-07 ***
     gender       0.120  1   0.7385  0.415160
     bone         4.190  2  12.8914  0.003145 **
     gender:bone  0.075  2   0.2321  0.798034
     Residuals    1.300  8
     ---
     Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
     >

You might think about whether you really prefer this analysis to one that 
obeys marginality (producing what are sometimes called "type II" sums of 
squares). The anova function in R computes so-called "sequential" (or "type 
I") sums of squares which rarely correspond to hypotheses of interest.

How to calculate F-tests in unbalanced Anova models with interactions is a 
subject that seems to produce a lot of heat, so you can expect conflicting 
advice.

I hope that this is useful to you.
  John




-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox
-----------------------------------------------------

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._