anova.lm
Anova Table for Linear Model Objects

Description

This is a method for the generic anova function for objects of class lm. For the general behavior of this function, see anova.

Usage

anova.lm(object, ..., test = "F")

Arguments

object an lm object.
... more lm objects. Each model should have the same data argument and the same response variable and should include all the predictor terms found in the previous model in the sequence (i.e., the models are nested).
test the test to be performed. Choices are "F" (the default), "Chisq", and "Cp", and "none". This argument is only used when more than one model is supplied; when only one model is specified F tests are done.
Value
returns an anova object, which is a data.frame with an attribute header used when printing the results. When only one model is supplied, the value includes one row for each term in the expanded formula, except the intercept, plus a row for the residuals. When multiple models are supplied there will be one row per model.
The column names in the single-model case include "Df" (degrees of freedom attributed to each term), "Sum Sq" (sum of squared residuals attributed to each term), and "Mean Sq" ("Sum Sq"/"Df"). For the multiple-model case the column names include "Res.Df" (residual degrees of freedom for each model), "RSS" (residual sum of squares for each model), and "Sum of Sq" (sum of squared residuals accounted for by each model).
The remaining columns depend on the test statistic chosen. They may be "F" and "Pr(>F)", or "P(>|Chi|)" (with no column for the Chisq statistic itself), or "Cp" (with no column for a probability), or none at all.
See Also
lm, anova, and, for printing, print.anova.
Examples
smallModel <- lm(Fuel ~ Weight, data=Sdatasets::fuel.frame)
bigModel <- lm(Fuel ~ Weight + Disp., data=Sdatasets::fuel.frame)
biggerModel <- lm(Fuel ~ Weight + Disp. + Type, data=Sdatasets::fuel.frame)
anova(biggerModel)
anova(smallModel, bigModel, biggerModel, test="Chisq")
Package stats version 6.1.1-7
Package Index