Compute an Anova Table - Generic function

DESCRIPTION:
Produces an object of class "anova", which inherits from "data.frame".

This function is generic (see Methods); method functions can be written to handle specific classes of data. Classes which already have methods for this function include: gam, gamlist, glm, glmlist, lm, lmlist, loess, survreg, survreglist.


USAGE:
anova(object, ...)

REQUIRED ARGUMENTS:
object:
a model object, such as those produced by lm, glm, aov, loess, survreg, etc.

OPTIONAL ARGUMENTS:
...:
some methods may have additional arguments. In particular, many have a test argument with choices like: "none", "F", "Chi", "Cp".

VALUE:
an anova object. This class of objects inherits from the class "data frame", and consequently suitable methods exist for printing, subsetting, etc. An additional "heading" attribute is a character vector that is printed at the top of the table.

DETAILS:
If called with a single object as an argument, anova produces a table with rows corresponding to each of the terms in the object, plus an additional row for the residuals. The method for aov objects is similar to summary.

When two or more objects are used in the call, a similar table is produced showing the effects of the pairwise differences between the models, considered sequentially from first to last.


REFERENCES:
Chambers, J.M., and Hastie, T.J. (1991). Statistical Models in S, pp. 210-213.

SEE ALSO:
aov (to perform analysis of variance modeling), glm , summary.aov .

EXAMPLES:
# create a sample glm object
glm.object <- glm(Kyphosis ~ bs(Start, 5) + Number, family = binomial,
                  data = kyphosis)
anova(glm.object)

# produces the following output: Analysis of Deviance Table

Binomial model

Response: Kyphosis

Terms added sequentially (first to last) Df Deviance Resid. Df Resid. Dev NULL 80 83.23447 bs(Start, 5) 5 23.52054 75 59.71394 Number 1 1.71619 74 57.99775

# create two more sample objects from ethanol dataset: attach(ethanol) gas.null <- loess(NOx ~ E, span = 1, data = gas) gas.alternative <- loess(NOx ~ E, span = 2/3, data = gas)

anova(gas.null, gas.alternative)

# produces the following output: Model 1: loess(formula = NOx ~ E, data = gas, span = 1) Model 2: loess(formula = NOx ~ E, data = gas, span = 2/3) Analysis of Variance Table Enp RSS Test F Value Pr(F) 1 3.5 4.8489 1 vs 2 10.14 0.0008601 2 5.5 1.7769