Dear Tamre, You didn't include your data, nor show the error produced with Anova() in car by idesign = ~Shoe*Region. Your data appear to have the same structure as the O'Brien-Kaiser example in ?Anova, but without the between-subject design. I have no trouble producing a two-way within-subject ANOVA for the O'Brien-Kaiser data, including the interaction:
---------- snip ---------- > phase <- factor(rep(c("pretest", "posttest", "followup"), c(5, 5, 5)), + levels=c("pretest", "posttest", "followup")) > hour <- ordered(rep(1:5, 3)) > idata <- data.frame(phase, hour) > idata phase hour 1 pretest 1 2 pretest 2 3 pretest 3 4 pretest 4 5 pretest 5 6 posttest 1 7 posttest 2 8 posttest 3 9 posttest 4 10 posttest 5 11 followup 1 12 followup 2 13 followup 3 14 followup 4 15 followup 5 > > mod.ok <- lm(cbind(pre.1, pre.2, pre.3, pre.4, pre.5, + post.1, post.2, post.3, post.4, post.5, + fup.1, fup.2, fup.3, fup.4, fup.5) ~ 1, + data=OBrienKaiser) > summary(Anova(mod.ok, idata=idata, idesign=~phase*hour, type="III"), multivariate=FALSE) Univariate Type III Repeated-Measures ANOVA Assuming Sphericity SS num Df Error SS den Df F Pr(>F) (Intercept) 7260.0 1 603.33 15 180.4972 9.100e-10 *** phase 167.5 2 169.17 30 14.8522 3.286e-05 *** hour 106.3 4 73.71 60 21.6309 4.360e-11 *** phase:hour 11.1 8 122.92 120 1.3525 0.2245 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 . . . ---------- snip ---------- So what's the problem? Best, John > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Tamre Cardoso > Sent: March-04-12 9:15 PM > To: r-help@r-project.org > Subject: [R] new to repeated measures anova in R > > Data set up as one observation/subject looks like (with a total of 10 > subjects) Two treatments: shoe type with 3 categories and region with 8 > categories ==> 24 "treatment" columns > > Subject PHallux PMidToes PLatToe PMTH1 PMidMTH PLatMTH PMidfoot > PRearfoot LHallux LMidToes LLatToe LMTH1 LMidMTH LLatMTH LMidfoot > LRearfoot DHallux DMidToes DLatToe DMTH1 DMidMTH DLatMTH DMidfoot > DRearfoot > 1 203.230 169.970 75.090 208.420 168.860 129.150 > 104.840 209.960 200.005 88.880 30.820 315.535 105.445 > 72.265 88.195 211.280 198.970 113.525 65.640 > 237.175 148.790 86.105 69.830 222.230 > > R Code: > > library(car) > pressure=read.csv("Shoe_data.csv",header=TRUE,sep=",") > datin.model=cbind(pressure[,2],pressure[,3],pressure[,4],pressure[,5],p > ressure[,6],pressure[,7],pressure[,8],pressure[,9],pressure[,10],pressu > re[,11],pressure[,12],pressure[,13], > > pressure[,14],pressure[,15],pressure[,16],pressure[,17],pressure[, > 18],pressure[,19],pressure[,20],pressure[,21],pressure[,22],pressure[,2 > 3],pressure[,24],pressure[,25]) > multmodel=lm(datin.model ~ 1) > Shoe <- factor(c(rep("P",8),rep("L",8),rep("D",8))) > Region <- > factor(rep(c("Hallux","MidToes","LatToe","MTH1","MidMTH","LatMTH","MidF > oot","Rearfoot"),3)) > fact.idata <- data.frame(Shoe,Region) > pressure.aov = Anova(multmodel, idata=fact.idata, idesign = ~Shoe + > Region, type="III") > > > summary(pressure.aov,multivariate=F) > Univariate Type III Repeated-Measures ANOVA Assuming Sphericity > > SS num Df Error SS den Df F Pr(>F) > (Intercept) 6275173 1 192361 9 293.5961 3.535e-08 *** > Shoe 2340 2 11839 18 1.7786 0.1973 > Region 748644 7 299408 63 22.5037 6.181e-15 *** > --- > Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 > > > Mauchly Tests for Sphericity > > Test statistic p-value > Shoe 0.72437 0.275329 > Region 0.00032 0.006714 > > > Greenhouse-Geisser and Huynh-Feldt Corrections for Departure from > Sphericity > > GG eps Pr(>F[GG]) > Shoe 0.78393 0.2065 > Region 0.37482 8.391e-07 *** > --- > Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 > > HF eps Pr(>F[HF]) > Shoe 0.92023 0.2008 > Region 0.54302 5.227e-09 *** > --- > Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 > > Everything runs fine, except that Anova will not allow idesign = > ~Shoe*Region > > So to look for interaction I set up a long format data set with columns > Subject, Pressure, Shoe, Region--df now has 240 rows > > Then I ran: > > pressure.alt.df=read.csv("ShoeDataAltFormat.csv",header=TRUE,sep=",") > > pressure.aovalt=aov(Pressure~(Shoe*Region)+Error(Subject/(Shoe*Region)) > ,data=pressure.alt.df) > > > summary(pressure.aovalt) > > Error: Subject > Df Sum Sq Mean Sq F value Pr(>F) > Residuals 1 2346.6 2346.6 > > Error: Subject:Shoe > Df Sum Sq Mean Sq > Shoe 2 3248 1624.0 > > Error: Subject:Region > Df Sum Sq Mean Sq > Region 7 606772 86682 > > Error: Subject:Shoe:Region > Df Sum Sq Mean Sq > Shoe:Region 14 34345 2453.2 > > Error: Within > Df Sum Sq Mean Sq F value Pr(>F) > Shoe 2 35 17.5 0.0063 0.9937 > Region 7 152734 21819.2 7.8272 2.469e-08 *** > Shoe:Region 14 15479 1105.6 0.3966 0.9747 > Residuals 192 535219 2787.6 > --- > Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 > > QUESTIONS: > > 1) Why does the Anova function not allow Shoe*Region? > 2) Does the use of aov provide a correct test for Shoe:Region > Interaction? > 3) The main effect for Shoe from Anova has a denominator df=18; > shouldn't that correspond to one of the error terms from aov? > 4) Is the Anova p-value of 0.1973 for the main effect of Shoe the > correct test > > Any help trying to understand exactly what is happening in Anova versus > aov is greatly appreciated. Looking at interaction plots, there does > not appear to be a lot going on except for two regions with relatively > (compared to other regions) different means for at least one Shoe type > within the Region. > > Thank you, > Tamre > [[alternative HTML version deleted]] ______________________________________________ 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.