add1
Compute Models by Adding One Term
Description
Returns information on models that include one more term than the given object.
This function is an S Version 3 generic. (See Methods.)
Method functions can be written to handle specific
S Version 3 classes of data. Classes that
have methods for this function include
lm, glm and mlm.
The default method is described here.
Usage
add1(object, scope, ...)
## Default S3 method:
add1(object, scope, scale = 0, test = c("none", "Chisq"), k = 2, ...)
Arguments
object |
a fitted model. It must be of a class such that formula(object) extracts its
formula and extractAIC(object) computes the number of estimated parameters
and its AIC statistic.
|
scope |
a description of the range of new terms to add. Generally scope is either a formula
or a character vector of term labels. If it is a formula, it should include all the terms in
the original model (or a dot, which represents them) as well as the terms to add. All terms
that do not violate marginality rules are added. (For example, x:y are added only if
both x and y are in the original model).
|
... |
other arguments depend on the method used.
|
Details
The main default method is add1.default, which produces
an anova object. Other kinds of models could use different methods for
summarizing the additional fits and, possibly, different classes of objects to represent
the result.
Other methods are add1.lm, add1.glm and add1.mlm.
Value
returns an anova object containing at least the number of degrees of freedom in the
test fit and the AIC for the fit. There can be other columns, depending on the class of the
object and the test requested.
References
Chambers, J. M. and Hastie, T .J. (Eds.) 1992. Statistical Models in S. Pacific Grove, CA.: Wadsworth & Brooks/Cole. Chapter 4.
See Also
Examples
fit <- lm(Fuel ~ Weight, data=Sdatasets::fuel.frame)
add1(fit, ~ . + Disp.)