# [R] type II and III Sum square whit empty cells

John Fox jfox at mcmaster.ca
Tue Apr 11 19:31:05 CEST 2006

Dear Mario,

When there are empty cells, some of the usual contrasts defining
interactions (and possibly even main effects) can't be estimated, and one
should be especially careful about what hypotheses are being tested. There's
a good introduction to these problems (in my opinion) by Searle, Speed, and
Henderson in The American Statistician, Vol. 35, No. 1. (Feb., 1981), pp.
16-33. The issues are sufficiently complex that I thought it inadvisable to
provide an automatic solution.

For the data pattern that you give, you could test the hypothesis of no
interaction via anova(lm(y ~ a + b), lm(y ~ a*b)). If the interaction seems
negligible, you could test the main effects via Anova(lm(y ~ a + b),
error=lm(y ~ a*b)).

I hope this helps,
John

--------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
905-525-9140x23604
http://socserv.mcmaster.ca/jfox
--------------------------------

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Mario Morales
> Sent: Tuesday, April 11, 2006 12:05 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] type II and III Sum square whit empty cells
>
> Dear all
>
> I need to run an anova from a factorial model
>
> y_{ijk}=\alpha_i+\beta_j+(\alpha\beta)_{ij}+e_{ijk}
>
> and calculate type II and III sums of square, but I have an
> empty cells, so anova function from package car fail. (I believe)
>
>
> y<-c(7,13,6,10,8,11,8,3,7,5,65)
>
> a<-as.factor(c(1,1,2,2,3,3,3,1,1,1,2))
>
> b<-as.factor( c(rep(1,7),rep(2,4)) )
>
> table(b,a) # cell (2,3) is empty
>
> mod<-lm(y~ a+b+a:b)
>
> library(car)
>
> Anova(mod,type="II")  # don't work
>
> How can I calculate type II and III sum of square whit empty cell?
>
> Thanks a lot
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help