Add Terms to a Linear Model Object

DESCRIPTION:

add1.lm is used to investigate a Linear Model Object by adding to it, in turn, each of an number of specified terms.

USAGE:

add1.lm(object, scope, scale, keep, x = NULL) 

REQUIRED ARGUMENTS:

object
an lm object, or any object that inherits from class lm. In particular, a glm object is also appropriate for a chi-squaredanalysis based on the score-test.
scope
a formula object describing the terms to be added. This argument is required, and is parsed to produce a set of terms that may be added to the model on their own without breaking the hierarchy rules. The scope can also be a character vector of term labels. Any "." in scope is interpreted relative to the formula implied by the object argument.

OPTIONAL ARGUMENTS:

scale
the multiplier of the dfterm in the Cp statistic. If not supplied, scale is estimated by the residual variance of object, or else in the case of a glm object the dispersion parameter.
keep
a character vector of names of components that should be saved for each augmented model. Only names from the set "coefficients", "fitted.values", "residuals", "x.residuals", "effects", "R" are allowed. If keep is TRUE, the complete set is implied. Use "x.residuals" to get the X matrix corresponding to a given term, adjusted for all the terms in the model object. The other components are as in object. The default behavior is not to keep anything.
x
a model matrix that includes all the terms in object as well as all those to be added. This is an optional argument, used, for example, by step.glm, and saves recomputing the model matrix every time.

VALUE:

if keep is missing, an anova object corresponding to each superset model implied by object and scope.
otherwise, a list with components:
anova
an anova object corresponding to each superset model implied by object and scope.
keep
a matrix of mode "list", with a column for each superset model, and a row for each component kept.

DETAILS:

Using the "R" component of object, as well as the corresponding qr object, each of the superset models corresponding to object plus a term as specified in scope are fitted. An anova object is constructed, consisting of the term labels, the degrees of freedom, the residual sum of squares, and the Cp statistic for each superset model.
add1 handles weighted lm objects, in particular glm objects. The weighted residual sum of squares is a Pearson chi-square statistic based on the weights of the model object, and a one-step iteration towards the superset model. This results in a score testfor the inclusion of each term. The function add1 is used as a primitive in step.glm.
This function is a method for the generic function for class lm. It can be invoked by calling for an object x of the appropriate class, or directly by calling regardless of the class of the object.

REFERENCES:

Chambers, J.M., and Hastie, T.J. (1991). Statistical Models in S, 125 and 233--238

SEE ALSO:

, , , , , , .

EXAMPLES:

attach(catalyst) 
fit1<- aov(Yield ~ Temp + Cat + Conc) 
add1(fit1, ~ .^2)  
# consider all interactions of terms in lm.object for inclusion 
attach(kyphosis) 
kyph.glm <- glm(Kyphosis ~ poly(Age, 2) + (Number > 5) * Start, 
                family = binomial) 
add1(kyph.glm, ~ . - Age + poly(Age, 2)+ log(Age) + sqrt(Age)) 
# try some candidate transformations for Age.