What does it mean to use anova
to compare models? For example, if I have two models
$$
\text{model}_1 \colon y = b_0 + b_1 x_1 + b_2 x_2
$$
and
$$
\text{model}_2 : y = b_0 + b_1 x_1 + b_2 x_2 + b_3 x_3
$$
and I use anova(model1, model2)
in R
, then is it the same as testing the null hypothesis $b_3 = 0$? If not, then what hypothesis exactly is getting tested here? And if yes, then why not simply use the summary of the lm
function to test whether $b_3 = 0$, i.e. what is the whole point of using anova
then?
-
1$\begingroup$ ANOVA compares the SS of the Residuals using the F-test. $\endgroup$– user2974951Dec 5, 2018 at 7:48
1 Answer
The anova method for linear model objects in R is doing the usual F test comparing sum of squares of residuals (SSR), assuming nested models. (It will give an output also in the non-nested case, but that is less useful).
In your example, this is equivalent to a t-test of the hypothesis $b_3=0$, but is more general than that, so can be used in cases where there is no equivalent t-test. An example using your example, say you are interested in some possible effect of variable $x_3$, but you are not sure the effect is linear, so you represent the possible effect in your model with a quadratic polynomial, to represent some curvature. That is:
$$
\text{model}_3 : y = b_0 + b_1 x_1 + b_2 x_2 + b_3 x_3 + b_4 x_3^2
$$
and now you can use anova(model, model3)
.
As a generalization, anova
can also be called on generalized linear model (glm) objects, in that case it calculates an (approximation of) a likelihood ratio test, with the same interpretation as above.