add1.lm
Add a Single Term to a Linear Model

Description

Investigates a linear model object by adding to it, independently, each of a number of specified terms.

Usage


## S3 method for class 'lm':
add1(object, scope, scale = 0, test = c("none", "Chisq",
    "F"), x = NULL, k = 2, ...)
## S3 method for class 'glm':
add1(object, scope, scale = 0, test = c("none", "Chisq",
    "F"), x = NULL, k = 2, ...)

Arguments

object an lm or glm object, or any object that inherits from one of those classes.
scope either a formula object or a character vector describing the terms to try adding to the model.
  • If scope is a formula object, it should include the terms used in the original model, plus terms that might be added. (You can use a dot as shorthand for all the terms in the original model.) New terms in the formula that do not break marginality rules are added to the model. (For example, x:y are not added unless both x and y are terms in the original model).
  • If scope is a character vector, then the terms in it will be added to model.
scale a scale estimate given to extractAIC to use in computing the AIC. If not supplied, scale is estimated by the residual variance of object, or else, in the case of a glm object, the dispersion parameter.
test a character string. One of "none", "Chisq", or "F", specifying which test statistic to include in result.
x a model matrix that includes all the terms in object as well as all those to be added.

This is an optional argument and can save recomputing the model matrix every time.

k a coefficient given to extractAIC to use as the coefficient of the degrees of freedom when computing the AIC.
... other arguments are silently ignored.

Details

These functions are methods for the generic function add1. They are non-visible methods and can be invoked only by calling add1 for an object x of the appropriate class.
Value
returns an anova object corresponding to each superset model implied by object and scope. It always contains the columns Df and AIC. Other columns depend on the specifics of the model and the requested test statistic.
References
Chambers, J.M., and Hastie, T.J. (1991). Statistical Models in S, 125 and 233--238
Chambers, J. M. (1992) Linear models. Chapter 4 of Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole.
See Also
anova, drop1, glm.object, lm.object, step, step.glm.
Examples
fit1 <- lm(yield ~ variety + site + year, data=Sdatasets::barley)
add1(fit1, ~.^2) # investigate adding each 2-way interaction term
Package stats version 6.0.0-69
Package Index