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.
anova(object, ...)
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.
# 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