[R] Question about aov
jfox at mcmaster.ca
Mon Oct 8 00:07:55 CEST 2007
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)
This would give you both the regression coefficients for the model and the
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 Fox, Professor
Department of Sociology
Canada L8S 4M4
> -----Original Message-----
> From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] On Behalf Of Alexander Keedy
> Sent: Sunday, October 07, 2007 2:37 PM
> To: r-help at 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):
> But if I switch the order of independent variables to:
> 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?
> Alex Keedy
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help