Dear Alex, First, the call to lm() is superfluous; you'd get the same output from summary(aov(Y~X+Method,data=hypnotic.induction)). Second, it's not common to use aov() in this manner, since the function is really intended for balanced ANOVAs. More common would be something like
model <- lm(Y~X+Method,data=hypnotic.induction) summary(model) anova(model) This would give you both the regression coefficients for the model and the ANOVA table. Finally, aov() and anova() produce "sequential" sums of squares, which is why the order of the terms matters. Thus the first ordering gives you the sum of squares for X "ignoring" Method and for Method "after" X; the second gives you the sum of squares for Method "ignoring" X and for X "after" Method. What one typically wants is the sum of squares for each term after the other(s). A convenient way to get this is via the Anova() function in the car package. I hope this helps, John -------------------------------- John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -------------------------------- > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Alexander Keedy > Sent: Sunday, October 07, 2007 2:37 PM > To: r-help@r-project.org > Subject: [R] Question about aov > > Hello R gurus, > > I am a beginner with R. I am doing an ANCOVA analysis > using 'aov,' and need some help understanding how 'aov' > works. I have a dataset (taken from > http://faculty.vassar.edu/lowry/ch17pt2.html) looking at > hypnotic induction. The variable 'X' is a measure of how > susceptible the subject is to being hypnotized, the variable > 'Y' is how well the subject was hypnotized in the experiment, > and the variable 'Method' is the method of hypnosis used in > the experiment. > > If I use the following code, I get the correct analysis (F = 16): > > ANCOVA=aov(lm(Y~X+Method,data=hypnotic.induction)) > summary(ANCOVA); > > But if I switch the order of independent variables to: > > ANCOVA=aov(lm(Y~Method+X,data=hypnotic.induction)) > summary(ANCOVA) > > I get a very different result (F = 0.8). > > I assume it has something to do with the order in which the > variables are entered into the regression? In 'aov' is there > something 'special' about the first independent variable > entered into the formula? It would be greatly appreciated if > anyone could shed some light on these results? > > Thanks! > > Alex Keedy > > > --------------------------------- > > [[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. > ______________________________________________ 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.