How to use anova for two models comparison?

How should I understand the anova result when comparing two models?

Example:

Res.Df    RSS Df Sum of Sq      F    Pr(>F)
1      9 54.032
2      7  4.632  2      49.4 37.329 0.0001844 ***

The manpage states: "Compute analysis of variance (or deviance) tables for one or more fitted model objects." However, out professor mentioned that it may be employed for model comparison - that's what I intend to do.

Hence I assume I could use anova(model1, model2) and obtain a p-value which tells me whether I should reject the null hypothesis: "the models are the same".

May I state that if the p-value is less then (let's say) 0.05, the models differ significantly?

• In your example, are model1 and model2 nested? That is, do both models have a shared set of predictor variables and the same outcome variable, but one model has one or more additional predictor variables? – EdM May 15 '15 at 15:26
• One is like Y ~ X + X^2 and the second one Y ~ X + X^2 + X^3 – petrbel May 15 '15 at 15:30

Just as an additional note, in case you weren't aware, ANOVA is always equivalent to doing model comparisons. When you are looking at the ANOVA for a single model it gives you the effects for each predictor variable. That is equivalent to doing a model comparison between your full model and a model removing one of the variables. i.e. $Model 1: y=a+bx_1+cx_2+dx_3; Model 2: y=a+bx_1+cx_2$ will give you the sum of squares (type III) and test statistic for $x_3$. Just note that R gives you type I sum of squares. If you need type III, use car::Anova or use anova and keep changing the order of the variables in the model and only take the sum of squares for the last variable.