scope
argument that can be
added to or dropped from the model, fit those models and compute a
table of the changes in fit.
add1(object, scope, ...)
"add1"(object, scope, scale = 0, test = c("none", "Chisq"), k = 2, trace = FALSE, ...)
"add1"(object, scope, scale = 0, test = c("none", "Chisq", "F"), x = NULL, k = 2, ...)
"add1"(object, scope, scale = 0, test = c("none", "Rao", "LRT", "Chisq", "F"), x = NULL, k = 2, ...)
drop1(object, scope, ...)
"drop1"(object, scope, scale = 0, test = c("none", "Chisq"), k = 2, trace = FALSE, ...)
"drop1"(object, scope, scale = 0, all.cols = TRUE, test = c("none", "Chisq", "F"), k = 2, ...)
"drop1"(object, scope, scale = 0, test = c("none", "Rao", "LRT", "Chisq", "F"), k = 2, ...)
0
or NULL
.lm
and
aov
models or perhaps for glm
fits with
estimated dispersion.
The $Chisq$ test can be an exact test
(lm
models with known scale) or a likelihood-ratio test or a
test of the reduction in scaled deviance depending on the method.
For glm
fits, you can also choose "LRT"
and
"Rao"
for likelihood ratio tests and Rao's efficient score test.
The former is synonymous with "Chisq"
(although both have
an asymptotic chi-square distribution).
Values can be abbreviated.
TRUE
, print out progress reports.add1
is to be called
repeatedly. Warning: no checks are done on its validity.FALSE
then non-estimable columns are dropped, but the result
is not usually statistically meaningful."anova"
summarizing the differences in fit
between the models.
na.action = na.omit
, but
this may give biased results. Only use these functions with data
containing missing values with great care. The default methods make calls to the function nobs
to
check that the number of observations involved in the fitting process
remained unchanged.drop1
methods, a missing scope
is taken to be all
terms in the model. The hierarchy is respected when considering terms
to be added or dropped: all main effects contained in a second-order
interaction must remain, and so on. In a scope
formula .
means what is already there.
The methods for lm
and glm
are more
efficient in that they do not recompute the model matrix and call the
fit
methods directly.
The default output table gives AIC, defined as minus twice log
likelihood plus $2p$ where $p$ is the rank of the model (the
number of effective parameters). This is only defined up to an
additive constant (like log-likelihoods). For linear Gaussian models
with fixed scale, the constant is chosen to give Mallows' $Cp$,
$RSS/scale + 2p - n$. Where $Cp$ is used,
the column is labelled as Cp
rather than AIC
.
The F tests for the "glm"
methods are based on analysis of
deviance tests, so if the dispersion is estimated it is based on the
residual deviance, unlike the F tests of anova.glm
.
step
, aov
, lm
,
extractAIC
, anova
require(graphics); require(utils)
## following example(swiss)
lm1 <- lm(Fertility ~ ., data = swiss)
add1(lm1, ~ I(Education^2) + .^2)
drop1(lm1, test = "F") # So called 'type II' anova
## following example(glm)
drop1(glm.D93, test = "Chisq")
drop1(glm.D93, test = "F")
add1(glm.D93, scope = ~outcome*treatment, test = "Rao") ## Pearson Chi-square
Run the code above in your browser using DataLab