When you use the 'general linear model' analysis in SPSS, the first result is a table with all terms with F-tests and significance values for all IV's. It uses http://joyx.joensuu.fi/~ek/anova/sstypes.txt SS Type III , which has the advantage that the order in which the variables are added to the model does not matter, and therefore it is relatively objective. I would like to reproduce this output in R. However, when using anova(glm.object, test="F"), the F test shows "Terms added sequentially (first to last)". Because of this, the F values and p values of the terms depend on the sequence in which they were added. Eg: an anova() of glm(a~b+c) will give other results than glm(a~c+b). How can I specify the SS type of an anova in R, so that i can reproduce the exact results as that i got in SPSS? -- View this message in context: http://www.nabble.com/set-type-of-SS-in-anova%28%29-tp18287076p18287076.html Sent from the R help mailing list archive at Nabble.com.
drop1() in R meets both your objection and that to 'Type III'. If you really want the so-called Type III, look at function Anova() in package car. But also consider library(fortunes); fortune(54); fortune((55); fortune(56) On Fri, 4 Jul 2008, jeroenooms wrote:> > When you use the 'general linear model' analysis in SPSS, the first result is > a table with all terms with F-tests and significance values for all IV's. It > uses http://joyx.joensuu.fi/~ek/anova/sstypes.txt SS Type III , which has > the advantage that the order in which the variables are added to the model > does not matter, and therefore it is relatively objective.No, as the terms may well have a natural hierachy in which case the order does matter.> I would like to reproduce this output in R. However, when using > anova(glm.object, test="F"), the F test shows "Terms added sequentially > (first to last)". Because of this, the F values and p values of the terms > depend on the sequence in which they were added. Eg: an anova() of > glm(a~b+c) will give other results than glm(a~c+b).Hmm: glm() is used for generalized linear models, and there sums of squares are only appropriate for those models where lm() is more appropriate.> How can I specify the SS type of an anova in R, so that i can reproduce the > exact results as that i got in SPSS?-- 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
Dear j.c.l.omms, The Anova() function in the car package can compute so-called "type-II" and "type-III" tests. When there are terms in the model that are marginal to others (such as main effects marginal to interactions), type-III tests are of questionable interest and have to be formulated carefully to test sensible hypotheses. As well, since glm() with no family argument fits a linear model with normal errors, it would be more usual in R to use lm(). Regards, John ------------------------------ John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]On> Behalf Of jeroenooms > Sent: July-04-08 6:37 PM > To: r-help at r-project.org > Subject: [R] set type of SS in anova() > > > When you use the 'general linear model' analysis in SPSS, the first resultis> a table with all terms with F-tests and significance values for all IV's.It> uses http://joyx.joensuu.fi/~ek/anova/sstypes.txt SS Type III , which has > the advantage that the order in which the variables are added to the model > does not matter, and therefore it is relatively objective. > > I would like to reproduce this output in R. However, when using > anova(glm.object, test="F"), the F test shows "Terms added sequentially > (first to last)". Because of this, the F values and p values of the terms > depend on the sequence in which they were added. Eg: an anova() of > glm(a~b+c) will give other results than glm(a~c+b). > > How can I specify the SS type of an anova in R, so that i can reproducethe> exact results as that i got in SPSS? > -- > View this message in context: http://www.nabble.com/set-type-of-SS-in- > anova%28%29-tp18287076p18287076.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.