Description Usage Arguments Details Value Author(s) See Also Examples
Select a formula-based model
1 2 3 |
object |
an object representing a model of an appropriate class. This is used as the initial model in the stepwise search. |
scope |
defines the range of models examined in the stepwise search. This should be either a single formula, or a list containing components 'upper' and 'lower', both formulae. See the details for how to specify the formulae and how they are used. |
expand |
logical. If TRUE and |
scale |
used in the definition of the AIC statistic for selecting the models, currently only for 'lm', 'aov' and 'glm' models. The default value, '0', indicates the scale should be estimated: see 'extractAIC'. |
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 positive, information is printed during the running of 'step'. Larger values may give more detailed information. |
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. |
k |
the multiple of the number of degrees of freedom used for the
penalty. Only |
... |
any additional arguments to 'extractAIC'. |
The set of models searched is determined by the 'scope' argument. The right-hand-side of its 'lower' component must be included in the model, and right-hand-side of the model is included in the 'upper' component. If 'scope' is a single formula, it specifies the 'upper' component, and the 'lower' model is empty. If 'scope' is missing, the initial model is used as the 'upper' model.
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 existing terms.
Missing values lead to a reduced dataset:
step.regr
works on the dataset that includes all variables
appearing in scope
and then drops all lines containing
missing values (by applying na.omit
).
The result is the model re-fitted to the dataset with only
the variables used in the final model.
This may lead to an increased number of rows.
This differs from the behavior of step
of package
stats
.
[from step
of package stats
:]
There is a potential problem in using 'glm' fits with a variable
'scale', as in that case the deviance is not simply related to the
maximized log-likelihood. The '"glm"' method for function
'extractAIC' makes the appropriate adjustment for a 'gaussian'
family, but may need to be amended for other cases. (The
'binomial' and 'poisson' families have fixed 'scale' by default
and do not correspond to a particular maximum-likelihood problem
for variable 'scale'.)
The selected model is returned, with up to two additional components. There is an
anova |
steps taken in the search, |
keep |
if the |
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 (thus
excluding 'lm', 'aov' and 'survreg' fits, for example).
Werner A, Stahel
step
in package stats
, stepAIC
in package
MASS
, add1.regr
, drop1.regr
1 2 3 4 5 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.