Build a Model in a Stepwise Fashion - Generic Function

DESCRIPTION:
Performs stepwise model selection.

This function is generic (see Methods); method functions can be written to handle specific classes of data. Classes which already have methods for this function include: gam, glm.


USAGE:
step(object, scope, scale, direction, trace = T, keep, steps)

REQUIRED ARGUMENTS:
object:
an object representing a model of an appropriate class. This is used as the initial model in the stepwise search.

OPTIONAL ARGUMENTS:
scope:
defines the range of models examined in the stepwise search.
scale:
used in the definition of the AIC statistic for selecting the models.
direction:
the mode of stepwise search, can be one of "both", "backward", or "forward", with a default of "both". If the scope argument is missing, the default for direction is "backward".
trace:
if TRUE, information is printed during the running of step(). This is a good choice in general, since step() can take some time for large models.
keep:
a filter function whose input is a fitted model object and the associated AIC statistic, and whose output is arbitrary. Typically keep will select a subset of the components of the object and return them. The default is not to keep anything.
steps:
the maximum number of steps to be considered. The default is 1000 (essentially as many as required). It is typically used to stop the process early.

VALUE:
the stepwise-selected model is returned, with up to two additional components. There is an "anova" component corresponding to the steps taken in the search, as well as a "keep" component if the keep= argument was supplied in the call.

DETAILS:
A series of models is generated sequentially, where each model differs from its neighbors by a single term. The step methods differ in the way they construct this sequence: both in the way the set of candidates are generated for each step, and in the way the candidates are evaluated for selection.

SEE ALSO:
add1 , drop1 , gam , glm , Kyphosis , Methods , step.gam , step.glm , stepwise .

EXAMPLES:
# create a sample glm object
glm.object <- glm(Kyphosis ~ Age + Start + Number,
                  family = binomial, data = kyphosis)

step(glm.object) step(glm.object, list(upper = ~.^2, lower = ~ Age))

step(gam.object, scope=list( "Age" = ~ 1 + Age + log(Age), "BP" = ~ 1 + BP + poly(BP, 2) + s(BP), "Chol" = ~ s(Chol, df = 4) + s(Chol, df = 7) )