Choose a model by AIC in a Stepwise Algorithm
Select a formula-based model by AIC.
1 2 3
an object representing a model of an appropriate class (mainly
defines the range of models examined in the stepwise search.
This should be either a single formula, or a list containing
used in the definition of the AIC statistic for selecting the models,
currently only for
the mode of stepwise search, can be one of
if positive, information is printed during the running of
a filter function whose input is a fitted model object and the
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.
the multiple of the number of degrees of freedom used for the penalty.
any additional arguments to
repeatedly; it will work for any method for which they work, and that
is determined by having a valid method for
When the additive constant can be chosen so that AIC is equal to
Mallows' Cp, this is done and the tables are labelled
The set of models searched is determined by the
The right-hand-side of its
lower component is always included
in the model, and right-hand-side of the model is included in the
upper component. If
scope is a single formula, it
upper component, and the
lower model is
scope is missing, the initial model is used as the
Models specified by
scope can be templates to update
object as used by
update.formula. So using
. in a
scope formula means ‘what is
already there’, with
.^2 indicating all interactions of
There is a potential problem in using
glm fits with a
scale, as in that case the deviance is not simply
related to the maximized log-likelihood. The
"glm" method for
extractAIC makes the
appropriate adjustment for a
gaussian family, but may need to be
amended for other cases. (The
families have fixed
scale by default and do not correspond
to a particular maximum-likelihood problem for variable
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. The
"Resid. Dev" column of the analysis of deviance table refers
to a constant minus twice the maximized log likelihood: it will be a
deviance only in cases where a saturated model is well-defined
The model fitting must apply the models to the same dataset. This
may be a problem if there are missing values and R's default of
na.action = na.omit is used. We suggest you remove the
missing values first.
Calls to the function
nobs are used to check that the
number of observations involved in the fitting process remains unchanged.
This function differs considerably from the function in S, which uses a number of approximations and does not in general compute the correct AIC.
This is a minimal implementation. Use
in package MASS for a wider range of object classes.
B. D. Ripley:
step is a slightly simplified version of
stepAIC in package MASS (Venables &
Ripley, 2002 and earlier editions).
The idea of a
step function follows that described in Hastie &
Pregibon (1992); but the implementation in R is more general.
Hastie, T. J. and Pregibon, D. (1992) Generalized linear models. Chapter 6 of Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole.
Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. New York: Springer (4th ed).
stepAIC in MASS,
1 2 3 4 5 6 7 8
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.