Learn R Programming

chemometrics (version 0.5)

stepwise: Stepwise regression

Description

Stepwise regression, starting from the empty model, with scope to the full model

Usage

stepwise(formula, data, k, startM, maxTime = 1800, direction = "both", writeFile = FALSE,
   resname = "stepres00", maxsteps = 500, ...)

Arguments

formula
formula, like y~X, i.e., dependent~response variables
data
data frame to be analyzed
k
sensible values are log(nrow(x)) for BIC or 2 for AIC; if not provided -> BIC
startM
optional, the starting model
maxTime
maximal time to be used for algorithm
direction
either "forward" or "backward" or "both"
writeFile
if TRUE results are stored in the file "resname"
resname
filename where results are stored, only if writeFile is TRUE
maxsteps
maximum number of steps
...
additional plot arguments

Value

  • usedTimetime that has been used for algorithm
  • bicBIC values for different models
  • modelsmatrix with no. of models rows and no. of variables columns, and 0/1 entried defining the models

Details

This function is similar to the function step for stepwise regression. It is especially designed for cases where the number of regressor variables is much higher than the number of objects. The formula for the full model (scope) is automatically generated.

References

K. Varmuza and P. Filzmoser: Introduction to Multivariate Statistical Analysis in Chemometrics. CRC Press, Boca Raton, FL, 2009.

See Also

step

Examples

Run this code
data(yarn)
res=stepwise(density~NIR,data=yarn,maxsteps=2) # increase maxsteps to get a good solution

Run the code above in your browser using DataLab