2 x 2 ANOVA, between subjects variables


ds = dataset you are currently using.

DV = dependent variable of interest

IV = independent variable of interest

XYXY = dummy name for a variable, matrix, or data frame into which you are moving information.

Balanced Design


XYXY<-aov(DV ~ IV1 * IV2, data=ds)



Unbalanced Design

I'm going to approach the unbalanced design from the SPSS perspective. I understand some don't agree with this. But if you're so above the SPSS approach, I'm not sure what you're doing here.

The problem: R defaults to type 1 sum of squares, which can give wildly varying answers, depending on the order in which variables are entered.

The solution: (1) Default contrasts that R runs need to be changed. (2) The "Anova()" function from the "car" package, which allows you to specify type III sum of squares.


XYXY <- aov(DV ~ IV1 * IV2,
            contrasts=list(IV1 = 'contr.sum', IV2 = 'contr.sum'),
            data = ds)


Anova(XYXY, type = 3)