[R] Difference in ANOVA results - R vs. JMP/Minitab
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Nov 20 08:41:02 CET 2003
On Wed, 19 Nov 2003, Nirmal Govind wrote:
> Thanks for your reply John.
>
> > this works). Applied to a linear-model object, summary() produces
> > coefficients, etc. (as mentioned), while anova() produces a (sequential)
> > ANOVA table. This seems apparent to me from the output.
>
> What I'm having trouble with is understanding the difference between
> aov() and lm() [since it seems like if I do a summary() after fitting
> using aov(), the output is the same as doing anova() after an lm()].
> Now, the outputs from aov() and lm() are different - the siginificant
> effects are different. I think this may have to do with how these
> functions treat the data - i.e. whether the function considers the data
> as being in coded or uncoded units. Is this correct? From what I could
> tell, aov() will code the data automatically and then present the ANOVA
> table whereas lm() does not code the data. This pretty much explains
> everything so far..
And all of that is explained in the reference on the aov help page.
Please do stop speculating and start reading.
> There's one problem though - how do I get the coefficients that are
> calculated from the data after they are coded by aov()? The problem here
> is that my factor levels are 0 and 1 instead of the usual -1 and 1...
> if I run coefficients() after a aov() fit or an lm() fit, I get the same
> coefficients... these coeffs. don't seem right (I compared with the
> coefficients from Minitab and JMP -both give coefficients after coding
> the data into a -1, 1 form).. I could of course modify my data and
> change all the 0 levels to -1 but is there a way in R to get
> coefficients that correspond to coded data?
AoV has nothing to do with coefficients. There is dummy.coef to get
uncoded coefficients, and there is options(contrasts=) to set the coding.
> > More generally, it probably makes sense to read introductory material
> > about R -- such as the introductory manual that comes with the software
>
> Yes, I have read some of these (and maybe I should read more :-))...
> thanks for the pointer.. on the same note, is there any reference that
> talks about how lm() and aov() treat data - coded vs. uncoded etc...
Yes, you should read a lot more. Chapter 6 of Venables & Ripley (2002)
and chapter 5 of Chambers & Hastie (1991) would be a good start.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list