#### 2 x 2 ANOVA, between subjects variables

KEY:

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)

summary(XYXY)

_____________________________

## 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)

library(car)

Anova(XYXY, type = 3)

_____________________________