Last chance! 50% off unlimited learning
Sale ends in
"anova"(object, ...)
"anova"(object, ..., scale = 0, test = "F")
lm
, usually, a result of a
call to lm
."F"
, "Chisq"
or "Cp"
,
with partial matching allowed, or NULL
for no test."anova"
inheriting from class "data.frame"
.
na.action = na.omit
is used,
and anova.lmlist
will detect this with an error.The table will contain F statistics (and P values) comparing the mean square for the row to the residual mean square.
If more than one object is specified, the table has a row for the residual degrees of freedom and sum of squares for each model. For all but the first model, the change in degrees of freedom and sum of squares 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.
Optionally the table can include test statistics. Normally the
F statistic is most appropriate, which compares the mean square for a
row to the residual sum of squares for the largest model considered.
If scale
is specified chi-squared tests can be used. Mallows'
$Cp$ statistic is the residual sum of squares plus twice the
estimate of $sigma^2$ times the residual degrees of freedom.
lm
, anova
. drop1
for
so-called ‘type II’ anova where each term is dropped one at a
time respecting their hierarchy.
## sequential table
fit <- lm(sr ~ ., data = LifeCycleSavings)
anova(fit)
## same effect via separate models
fit0 <- lm(sr ~ 1, data = LifeCycleSavings)
fit1 <- update(fit0, . ~ . + pop15)
fit2 <- update(fit1, . ~ . + pop75)
fit3 <- update(fit2, . ~ . + dpi)
fit4 <- update(fit3, . ~ . + ddpi)
anova(fit0, fit1, fit2, fit3, fit4, test = "F")
anova(fit4, fit2, fit0, test = "F") # unconventional order
Run the code above in your browser using DataLab