Repeated measures ANOVA - different resutls for SPSS versus R

浪子不回头ぞ 提交于 2020-01-06 02:32:08

问题


I am trying to run a repeated - measures ANOVA using R and compared it to the SPSS output and results differ a lot! Maybe I make a mistake somewhere, but I cannot figure it out So some sample data: id is the subject. Every subject makes one rating for three items (res_1, res_2 and res_3). I want to compare an overall effect of item.

id<-c(1,2,3,4,5,6)
res_1<-c(1,1,1,2,2,1)
res_2<-c(4,5,2,4,4,3)
res_3<-c(4,5,6,3,6,6)
## wide format for spss
table<-as.data.frame(cbind(id, res_1, res_2, res_3))
## reshape to long format
library(reshape2)
table<-melt(table, id.vars="id")
colnames(table)<-c("id", "item", "rating")
aov.out = aov(rating ~ item+ Error(id/item), data=table) 
summary(aov.out)

And here is my SPSS code (from wide format data)

GLM item_1 item_2 item_3
/WSFACTOR=factor1 3 Polynomial 
/METHOD=SSTYPE(3)
/PRINT=DESCRIPTIVE 
/CRITERIA=ALPHA(.05)
/WSDESIGN=factor1.

The results I get from R: p value 0.0526 (error:within) and SPSS: p value 0.003 (test of within subject effect)

Does anyone have a suggestion that may explain the difference? If I do a non-parametric Friedmann test, I get the same results in SPSS and R. Actually, when looking at my data, the summary(aov.out) is the same as SPSS's "test of within subjects contrast" (but I learned to look at the test of within subjects effect).

Thanks!


回答1:


There's a lot of stuff out there; I am a bit surprised that your google for 'spss versus R anova' did not bring you to links explaining about the difference in sums-of-squares between SPSS (type-III) and R (type-I) as well as difference in how contrasts are handled.

These are the top two results that I found: http://myowelt.blogspot.ca/2008/05/obtaining-same-anova-results-in-r-as-in.html and https://stats.stackexchange.com/questions/40958/testing-anova-hypothesis-with-contrasts-in-r-and-spss



来源:https://stackoverflow.com/questions/29365167/repeated-measures-anova-different-resutls-for-spss-versus-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!