Maybe a simple concrete example would help: > tmpdat <- data.frame( One= rep( c('A','B'), each=10 ), + Two=rep( c('C','D'), each=5, length.out=20 ), + mu1 = rep( c(10, 11, 12, 16), each=5 ) ) > > tmpdat$e <- with(tmpdat, ave( rnorm(20), One, Two, FUN=scale ) ) > tmpdat$y <- with(tmpdat, mu1+e) > > # check the means > > tapply( tmpdat$y, tmpdat[,c('One','Two')], mean ) Two One C D A 10 11 B 12 16 > > # now fit the data > > fit <- aov( y ~ One*Two, data=tmpdat ) > > # look at what was measured > > coef(fit) (Intercept) OneB TwoD OneB:TwoD 10 2 1 3 > > # notice: > > (16-12) - (11-10) [1] 3 > > (16-11) - (12-10) [1] 3 > > # another way of thinking > > model.tables(fit) Tables of effects
One One A B -1.75 1.75 Two Two C D -1.25 1.25 One:Two Two One C D A 0.75 -0.75 B -0.75 0.75 > model.tables(fit, 'means') Tables of means Grand mean 12.25 One One A B 10.5 14.0 Two Two C D 11.0 13.5 One:Two Two One C D A 10 11 B 12 16 > > fit2 <- aov( y ~ One + Two, data=tmpdat ) > model.tables(fit2) Tables of effects One One A B -1.75 1.75 Two Two C D -1.25 1.25 > model.tables(fit2, 'means') Tables of means Grand mean 12.25 One One A B 10.5 14.0 Two Two C D 11.0 13.5 > > tmpdat2 <- expand.grid( One=c('A','B'), Two=c('C','D') ) > cbind( tmpdat2, fit=predict(fit, tmpdat2), fit2=predict(fit2, tmpdat2) ) One Two fit fit2 1 A C 10 9.25 2 B C 12 12.75 3 A D 11 11.75 4 B D 16 15.25 > Now go back and replace the 16 with 13 and see how things change. Also, how are you accounting for people in your model? Did you have multiple people? Did each person report more than one outcome? You probably need to include person as some form of random effect to properly account for them. This is really getting to the point where you need a consultant (or several more classes). -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 From: Frodo Jedi [mailto:frodo.j...@yahoo.com] Sent: Thursday, January 06, 2011 2:39 PM To: Greg Snow; r-help@r-project.org Subject: Re: [R] Problem with 2-ways ANOVA interactions Dear Greg, many many thanks, still have a doubt: > Before I wrongly thought that if I do the analysis anova(response ~ > stimulus*condition) I would have got the comparison between > the same stimulus in condition A and in condition AH (e.g. stimulus_1_A, > stimulus_1_AH). > Instad, apparently, the interaction stimulus:condition means that I find the > differences between the stimuli keeping fixed the condition!! > If this is true then doing the anova with the interaction stimulus:condition > is equivalent to do the ONE WAY ANOVA first on > the subset where all the conditions are A and then on the subset where all > the conditions are AH? Right? >>I think you are closer, but not quite there. The test on the interaction >>tests if the difference between A and AH is the same across the different >>stimuli. The main effect for condition >>tests if there is a difference >>between A and AH. So you mean that the interaction compare for example: stimulus1 in condition A with stimulus 2 in condition AH, right? Could you please answer also to my question I did at the end?..that is what at the end I what to know: > So if all before is correct, my final question is: how by means of ANOVA can > I track the significative differences between the stimuli > presented in A and AH condition whitout passing for the t-test? Indeed my > goal was to find in one hand if globally the condition > AH bring to better results than condition A, and on the other hand I needed > to know for which stimuli the condition AH brings > better results than condition A. > Thanks Best regards [[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.