For example, using the mtcars
built-in dataset.
A two-model ANOVA:
anova(
lm(mpg ~ 1, data = mtcars),
lm(mpg ~ drat, data = mtcars)
)
Model 1: mpg ~ 1
Model 2: mpg ~ drat
Res.Df RSS Df Sum of Sq F Pr(>F)
1 31 1126.05
2 30 603.57 1 522.48 25.97 1.776e-05 ***
A three-model ANOVA:
anova(
lm(mpg ~ 1, data = mtcars),
lm(mpg ~ drat, data = mtcars),
lm(mpg ~ drat + wt, data = mtcars)
)
Model 1: mpg ~ 1
Model 2: mpg ~ drat
Model 3: mpg ~ drat + wt
Res.Df RSS Df Sum of Sq F Pr(>F)
1 31 1126.05
2 30 603.57 1 522.48 56.276 2.871e-08 ***
3 29 269.24 1 334.33 36.010 1.589e-06 ***
Now, looking at row 2 of each table, you will notice that sum of squares and degrees of freedom are the same as each other, but the $f$ statistic is 25.97 in the first test and 56.276 in the second. Why is this? How is $f$ calculated in both cases?
My understanding of the $f$ statistic is that it's the ratio of two chi-squared RVs, ie $f = \frac{ESS(\gamma_j \mid \gamma_{j-1})/r}{RSS_j/(n-p)}$ (where $r$ is the difference in number of parameters between the two models). However all of these components are the same between the two tests, so I don't understand why $f$ would differ.
anova
(ordrop1
or whatever) are about comparing nested models. $\endgroup$mpg ~ 1
, row 1) and the next ones, which both include numerical predictors (1 regression coeff each). $\endgroup$