Jason R. Finley wrote:> Hello,
> I have spent a good deal of time searching for an answer to this but
> have come up empty-handed; I apologize if I missed something that is
> common knowledge.
>
> I am trying to figure out how to get an ANOVA table that shows the
> sum of squares. degrees of freedom, etc, for the full model versus
> the error (aka residuals).
>
> Here is an example of the kind of table I'd like to get:
>
> Analysis of Variance
> Source DF SS MS F P
> Regression 1 8654.7 8654.7 102.35 0.000
> Error 75 6342.1 84.6
> Total 76 14996.8
>
> This kind of table is prevalent throughout my statistics textbook,
> and can apparently be easily obtained in other statistical software
> tools. I'm not saying this as a gripe, but just as evidence that
I'm
> not trying to do something obviously bizarre.
>
>
> Here is an example of the only kind of ANOVA table for a single
> linear model that I've been able to get using R:
>
> > regression9 <- lm(y ~ x1 + x2 + x3, data=data9)
> > anova.lm(regression9)
> Analysis of Variance Table
>
> Response: y
> Df Sum Sq Mean Sq F value Pr(>F)
> x1 1 8275.4 8275.4 81.8026 2.059e-11 ***
> x2 1 480.9 480.9 4.7539 0.03489 *
> x3 1 364.2 364.2 3.5997 0.06468 .
> Residuals 42 4248.8 101.2
> ---
> Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
>
>
> Is there a way to get an ANOVA table with the full linear regression
> model considered as a whole rather than broken down into each
> additional predictor variable? In other words, is there a way to get
> the former kind of table?
>
The logical thing to do would be (please avoid calling methods like
anova.lm directly)
# following example(anova.lm):
> anova(update(fit,~1),fit)
Analysis of Variance Table
Model 1: sr ~ 1
Model 2: sr ~ pop15 + pop75 + dpi + ddpi
Res.Df RSS Df Sum of Sq F Pr(>F)
1 49 983.63
2 45 650.71 4 332.92 5.7557 0.0007904 ***
If you really want the column of MS, you have a little extra work to do.
Notice also that the F test is part of the standard summary(fit)
> Again, apologies if I'm missing something basic.
> thanks very much,
> ~jason
>
>
> PS - I am on Mac OSX 10.4.8 using R 2.4.1 GUI 1.18 (4038)
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Jason R. Finley
> Graduate Student, Department of Psychology
> Cognitive Division
> University of Illinois, Urbana-Champaign
>
> uniace at mac.com
> jrfinley at uiuc.edu
> http://www.jasonfinley.com/
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>