Fast question:is the design well balanced ? Cause if not, it might be because R's aov goes with SS type 1, while SPSS goes with SS type 3. For more info on this search for discussions with: "car", Anova, SS type III, and repeated measures Tal On Sun, Mar 1, 2009 at 11:13 AM, René Mayer wrote: > dear all, > > i'm trying to reproduce an spss-anova in R. > It is an 2x3x3 repeated measures desingn with repeated contrasts. > In R i've coded a contrast matrix for all factors and made a > split in the aov summary - but I can't get the repeated interaction > contrasts. > > The output from SPSS looks like this: > > TaskSw * CongNow * CongBefore: SS df Mean Square F Sig. > 1 vs. 2 1 vs. 2 1 vs. 2 13944,50 1 13944,50 0.37 0.56 > 2 vs. 3 4278,12 1 4278,12 0.31 0.59 > 2 vs. 3 1 vs. 2 7140,12 1 7140,12 0.17 0.68 > 2 vs. 3 53301,131 1 53301,13 1.38 0.27 > > > The output from R looks like this: > > Error: Subj:TaskSw:CongNow:CongBefore > > Df Sum Sq Mean Sq F value Pr(>F) > 4 18823 4706 1.8804 0.1417 > rep vs. se.con vs. inc.con vs. inc 1 > inc vs. neu. 1 > con vs. inc.inc vs. neu 1 > inc vs. neu. 1 > Residuals 28 70069 2502 > > > > I've pasted the R and SPSS code I uesd. thanks in advance. Rene > > R code: > # read in data > > TaskSwitch <- factor(rep(c(0:1), 72), > levels=c(0,1), > labels=c("Repetition","Switch")) > CongruenceNow <- factor(rep(c(0,0,1,1,2,2), 24), > levels=c(0,1,2), > > labels=c("Congruent","Incongruent","Neutral")) > CongruenceBefore <- factor(rep(c(0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2), 8), > levels=c(0,1,2), > > labels=c("Congruent","Incongruent","Neutral")) > # Subjects > Subjects <- factor(rep(c(1:8), each = 18)) > # RT = Response Time > RT <- > c(648,682,798,765,707,677,676,698,712,770,702,683,635,716,748,703,737, > > 657,1047,1140,992,1088,925,967,1022,1105,884,1103,930,1046,1034,1032, > > 948,956,987,993,753,782,837,923,820,846,835,884,778,873,774,760,848, > > 824,788,864,969,833,662,683,848,903,731,755,778,748,792,913,707,721, > > 736,766,771,898,874,801,762,824,956,865,864,908,828,877,804,1096,864, > > 878,799,833,883,1005,863,824,691,666,698,791,712,778,731,743,749,781, > > 717,769,732,730,703,771,743,709,470,489,546,574,541,523,536,556,532, > > 510,543,557,531,554,532,573,528,514,842,785,851,932,888,920,856,840, > 1010,877,784,901,845,923,798,907,903,758) > > m <- data.frame(RT, TaskSwitch,CongruenceNow,CongruenceBefore,Subjects) > > > # defining repeated contrasts for all factors > conCN = matrix(c(1,0, > -1,1, > 0,-1), nrow = 3, ncol = 2, byrow = TRUE) > contrasts(m$CongruenceNow) <- conCN > > conTS = matrix(c(1, > -1), nrow = 2, ncol = 1, byrow = TRUE) > contrasts(m$TaskSwitch) <- conTS > > conCB = matrix(c(1,0, > -1,1, > 0,-1), nrow = 3, ncol = 2, byrow = TRUE) > contrasts(m$CongruenceBefore) <- conCB > > # ANOVA > > fit <- aov(RT ~ TaskSwitch*CongruenceNow*CongruenceBefore + > Error(Subjects/(TaskSwitch*CongruenceNow*CongruenceBefore)), data = m) > > summary(fit) > > summary(fit, split = list(CongruenceNow = list("con vs. inc" = 1, > "inc vs. neu" = 2), > CongruenceBefore= list("con vs. inc" = 1, > "inc vs. neu" = 2), > TaskSwitch = list("rep vs. se" = 1))) > > > # export to spss > require(foreign) > codefile<-tempfile() > write.foreign(m, paste("C:/m.sav",sep = ''), codefile,package="SPSS") > > SPSS: > ###### BEGIN: SPSS code > ########################################################################### > # GET DATA > # /TYPE=TXT /FILE='C:\m.sav' /DELCASE=LINE /DELIMITERS="," > /ARRANGEMENT=DELIMITED > # /FIRSTCASE=1/IMPORTCASE=ALL > # /VARIABLES= > # RT F4.0 TaskSwitch F1.0 CongruenceNow F1.0 CongruenceBefore F1.0 > Subjects F1.0. > # CACHE. > # EXECUTE. > # DATASET NAME DataSet1 WINDOW=FRONT. > # > # SORT CASES BY Subjects TaskSwitch CongruenceNow CongruenceBefore . > # CASESTOVARS > # /ID= Subjects > # /INDEX=TaskSwitch CongruenceNow CongruenceBefore > # /GROUPBY=VARIABLE. > # > # GLM RT.1.1.1 RT.1.1.2 RT.1.1.3 RT.1.2.1 RT.1.2.2 RT.1.2.3 RT.1.3.1 > RT.1.3.2 RT.1.3.3 RT.2.1.1 > # RT.2.1.2 RT.2.1.3 RT.2.2.1 RT.2.2.2 RT.2.2.3 RT.2.3.1 RT.2.3.2 > RT.2.3.3 > # /WSFACTOR=TaskSwitch 2 Repeated CongruenceNow 3 Repeated > CongruenceBefore 3 Repeated > # /METHOD=SSTYPE(3) > # /PRINT=DESCRIPTIVE OPOWER TEST(SSCP) > # /CRITERIA=ALPHA(.05) > # /WSDESIGN=TaskSwitch CongruenceNow CongruenceBefore > TaskSwitch*CongruenceNow > # TaskSwitch*CongruenceBefore CongruenceNow*CongruenceBefore > # TaskSwitch*CongruenceNow*CongruenceBefore. > ###### END: SPSS code > ########################################################################### > > > > > -- > Dr. rer. nat. Dipl.-Psych. René Mayer > > Dresden University of Technology > Department of Psychology > Zellescher Weg 17 > D-01062 Dresden > > Tel.: +49-351-4633-4568 > > Email: mayer@psychologie.tu-dresden.de > > > > > > > -- > Dr. rer. nat. Dipl.-Psych. René Mayer > > Dresden University of Technology > Department of Psychology > Zellescher Weg 17 > D-01062 Dresden > > Tel.: +49-351-4633-4568 > > Email: mayer@psychologie.tu-dresden.de > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- ---------------------------------------------- My contact information: Tal Galili Phone number: 972-50-3373767 FaceBook: Tal Galili My Blogs: www.talgalili.com www.biostatistics.co.il [[alternative HTML version deleted]]