Solved – Mixed Model Type-III Sums of Squares- R vs SPSS

mixed modelrspsssums-of-squares

The age old question of comparing sums of squares (SS) between programs has reared its ugly head again.

I am trying to replicate output in SPSS, that was computed using Type 3 Sums of Squares, in R.

I understand that with multiple regressions, there are several ways to get Type 3 SS in R (to match Type 3 output from SPSS).

However, I am running a mixed model using aov (which uses Type 1 SS) and even when I try all the "usual" fixes," my estimates don't match the Type 3 SS output from SPSS.

First of all, when I run the SPSS syntax using "/METHOD=SSTYPE(1)" the results match those I get using this code:

  mymodel<-aov(data=longdat,  DV ~ 1 + Task + Cue + Compatibility + Cue:Task + Compatibility:Task + Cue:Compatibility + Cue:Compatibility:Task + Error(subject/Cue/Compatibility/Cue*Compatibility))
  summary(mymodel)

So I know the analyses are the same when they use Type 1 SS.

However, when I use:

 options(contrasts = c("contr.sum","contr.poly"))
 tt<-lm(DV ~ 1 + Task + Cue + Compatibility + Cue:Task  + Compatibility:Task + Cue:Compatibility + Cue:Compatibility:Task + 1/subject/Cue/Compatibility    /(Cue*Compatibility), data=longdat)
 drop1(tt, ~., test="F")

The results do not match the SPSS Type 3 output.

In attempts to get matching output, I have also tried the Anova function (which can give Type 3 SS)

  Anova(mymodel, type=3, test.statistic="F") 

but I get this error "Error in terms.formula(formula, data = data) : 'data' argument is of the wrong type."

I have also tried using lmer.

Can someone help me get Type 3 Sums of Squares for a mixed model in R?

Thank you!

Best Answer

I think the simplest thing to do will be to simply use the functions mixed and aov.car from the package afex. Please note that to calculate the degrees of freedom these functions use the Kenward-Rogers approximation. Other functions (or other software in general) might use Satterthwaite approximations. A very interesting discussion on Type-III sums was done in this site and is available: here.

Related Question