step.lmRob: Build a Model in a Stepwise Fashion

Description Usage Arguments Details Value See Also Examples

View source: R/step.lmRob.q

Description

Performs stepwise model selection on a robustly fitted linear model. Presently only the backward stepwise procedure is implemented.

Usage

1
2
3
step.lmRob(object, scope, scale,
           direction = c("both", "backward", "forward"),
           trace = TRUE, keep = NULL, steps = 1000, fast = FALSE, ...)

Arguments

object

an lmRob object.

scope

either a formula or a list with elements lower and upper each of which is a formula. The terms in the right-hand-side of lower are always included in the model and the additional terms in the right-hand-side of upper are the candidates for inclusion/exclusion from the model. If a single formula is given, it is taken to be upper and lower is set to the empty model. The . operator is interpreted in the context of the formula in object.

scale

a single numeric value containing a residual scale estimate. If missing, the scale estimate in object is used.

direction

a character value specifying the mode of stepwise search. The possibilities are "both", "backward", and "forward", with a default of "backward". Presently only "backward" stepwise searches are implemented.

trace

a logical value. If TRUE, information is printed during stepwise search.

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

an integer value specifying 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.

fast

a logical value. If TRUE the robust initial estimate (used when fitting each of the reduced models) is replaced by a weighted least squares estimate using the robust weights computed for the current fit. Note: the fast algorithm does not work in this version of the Robust Library.

...

additional arguments required by the generic step function.

Details

Presently only backward stepwise selection is supported. During each step the Robust Final Prediction Error (as computed by the function lmRob.RFPE) is calculated for the current model and for each sub-model achievable by deleting a single term. The function then either steps to the sub-model with the lowest Robust Final Prediction Error or, if the current model has the lowest Robust Final Prediction Error, terminates. The scale estimate from object is used to compute the Robust Final Prediction Error throughout the procedure unless the scale argument is provided in which case the user specified value is used.

Value

the model with the lowest Robust Final Prediction Error encountered during the stepwise procedure is returned. Additionally, an anova element corresponding to the steps taken in the search is appended to the returned object. If a keep function was provided then the kept values can be found in the keep element of the returned object.

See Also

lmRob, lmRob.RFPE, drop1.lmRob.

Examples

1
2
3
4
5
6
7
8
9
data(stack.dat)
stack.rob <- lmRob(Loss ~ ., data = stack.dat)

## The default behavior is to try dropping all terms ##
step.lmRob(stack.rob)

## Keep Water.Temp in the model ##
my.scope <- list(lower = . ~ Water.Temp, upper = . ~ .)
step.lmRob(stack.rob, scope = my.scope)

Example output

Loading required package: fit.models
Start:  RFPE= 16.032 
 Loss ~ Air.Flow + Water.Temp + Acid.Conc. 


Single term deletions

Model:
Loss ~ Air.Flow + Water.Temp + Acid.Conc.

scale:  1.837073 

           Df   RFPE
<none>        16.032
Air.Flow    1 36.213
Water.Temp  1 20.829
Acid.Conc.  1 16.049

Call:
lmRob(formula = Loss ~ ., data = stack.dat)

Coefficients:
(Intercept)     Air.Flow   Water.Temp   Acid.Conc.  
  -37.65246      0.79769      0.57734     -0.06706  

Start:  RFPE= 16.032 
 Loss ~ Air.Flow + Water.Temp + Acid.Conc. 


Single term deletions

Model:
Loss ~ Air.Flow + Water.Temp + Acid.Conc.

scale:  1.837073 

           Df   RFPE
<none>        16.032
Air.Flow    1 36.213
Acid.Conc.  1 16.049

Call:
lmRob(formula = Loss ~ ., data = stack.dat)

Coefficients:
(Intercept)     Air.Flow   Water.Temp   Acid.Conc.  
  -37.65246      0.79769      0.57734     -0.06706  

robust documentation built on May 2, 2019, 5:20 p.m.

Related to step.lmRob in robust...