anova.glm {base} | R Documentation |
Compute an analysis of deviance table for one or more generalized linear model fits.
## S3 method for class 'glm'
anova(object, ..., dispersion = NULL, test = NULL)
object , ... |
objects of class |
dispersion |
the dispersion parameter for the fitting family.
By default it is obtained from |
test |
a character string, (partially) matching one of |
Specifying a single object gives a sequential analysis of deviance table for that fit. That is, the reductions in the residual deviance as each term of the formula is added in turn are given in as the rows of a table, plus the residual deviances themselves.
If more than one object is specified, the table has a row for the residual degrees of freedom and deviance for each model. For all but the first model, the change in degrees of freedom and deviance is also given. (This only make statistical sense if the models are nested.) It is conventional to list the models from smallest to largest, but this is up to the user.
The table will optionally contain test statistics (and P values)
comparing the reduction in deviance for the row to the residuals.
For models with known dispersion (e.g. binomial and Poisson fits)
the chi-squared test is most appropriate, and for those with
dispersion estimated by moments (e.g. gaussian
,
quasibinomial
and quasipoisson
fits) the F test is
most appropriate. Mallows' C_p
statistic is the residual
deviance plus twice the estimate of \sigma^2
times
the residual degrees of freedom, which is closely related to AIC (and
a multiple of it if the dispersion is known).
An object of class "anova"
inheriting from class "data.frame"
.
The comparison between two or more models by anova
or
anova.glmlist
will only be valid if they
are fitted to the same dataset. This may be a problem if there are
missing values and R's default of na.action = na.omit
is used,
and anova.glmlist
will detect this with an error.
glm
, anova
.
## --- Continuing the Example from ``?glm'':%\code{\link{glm}}:
anova(glm.D93)
anova(glm.D93, test = "Cp")
anova(glm.D93, test = "Chisq")