I was given some SPSS syntax and need to recreate the analyses in R. In SPSS, the analysis is a repeated measures GLM where the outcome variable is measured four times per subject and each subject comes from one of three groups. The goal is to see if there are main effects of time and group and an interaction between time and group. I thought to recreate the analyses in R using mixed-effects modeling and the
This is the original SPSS syntax:
GLM y1 y2 y3 y4 BY group /WSFACTOR = time 4 Polynomial /METHOD = SSTYPE(3) /WSDESIGN = time /DESIGN = group.
This is my attempt in R:
long <- reshape(wide,varying=c("y1","y2","y3","y4"),timevar="time",dir="long",sep="") long$timesq = long$time^2 long$timecubed = long$time^3 m <- lmer(y ~ 1 + time*group + timesq*group + timecubed*group + (1 | subject), data=long) summary(m) anova(m)
The results are pretty similar in terms of which effects are significant. However, the type III sums of squares vary considerably between the SPSS and R results.
SPSS Sums of Squares:
time linear 267.244 time quadratic 45.658 time cubic 18.226 time*group linear 3027.543 time*group quadratic 3462.319 time*group cubic 2148.856 group 13298.301
R Sums of Squares:
time 63.7 timesq 67.2 timecubed 78.0 time*group 3403.7 timesq*group 2690.9 timecubed*group 2246.1 group 3710.3
Any help you can provide to help me understand these differences would be appreciated. Is it possible to recreate the SPSS results exactly? If not, which results would be considered more trustworthy?