Learn R Programming

chemometrics (version 1.4.4)

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, maxsteps = 500, ...)

Value

usedTime

time that has been used for algorithm

bic

BIC values for different models

models

matrix with no. of models rows and no. of variables columns, and 0/1 entries defining the models

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; provide a binary vector

maxTime

maximal time to be used for algorithm

direction

either "forward" or "backward" or "both"

writeFile

if TRUE results are shown on the screen

maxsteps

maximum number of steps

...

additional plot arguments

Author

Leonhard Seyfang and (marginally) Peter Filzmoser <P.Filzmoser@tuwien.ac.at>

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

Examples

Run this code
data(NIR)
X <- NIR$xNIR[1:30,]      # first 30 observations - for illustration
y <- NIR$yGlcEtOH[1:30,1] # only variable Glucose
NIR.Glc <- data.frame(X=X, y=y)
res <- stepwise(y~.,data=NIR.Glc,maxsteps=2)   

Run the code above in your browser using DataLab