swReg: Perform forward stagewise regression

Description Usage Arguments Details Value Examples

Description

swReg performs forward stagewise regression.

Usage

1
swReg(X, Y, stepsize = 0.1, standardizeY = TRUE)

Arguments

X

Matrix of predictor variables.

Y

Outcome variable (vector).

stepsize

numeric. Value with which the (un)standardized coefficients are updated in each iteration (a.k.a. epsilon).

standardizeY

logical. Should the response be standardized prior to application of the algorithm? If TRUE, stepsize can be interpreted as a correlation. If sd(Y) > 1, setting standardizeY = FALSE will increase the number of steps needed for convergence.

Details

The function performs incremental forward stagewise regression, as described in Hastie, Tisbhirani & Friedman (2009). Hastie, T., Tibshirani, R., & Friedman, J. (2009). The Elements of Statistical Learning.

Value

The function returns a list with the following elements: unstandardized.coef = bUnstand, standardized.coef = b, iteration = iteration, stepsize = stepsize (epsilon), coef.path = dataframe with standardized coefficient values for each predictor variable, at each stage or iteration of the algorithm data = list with original data (X andY)

Examples

1
2
3
4
5
6
7
8
9
## Example using Boston housing data:
 library(MASS)
 X <- as.matrix(Boston[,-14])
 Y <- Boston$medv
   
 ## Run forward stagewise regression:
 swReg1 <- swReg(X, Y, stepsize = .01)
 swReg2 <- swReg(X, Y, stepsize = .01, standardizeY = FALSE)
   

marjoleinF/swReg documentation built on May 21, 2019, 11:47 a.m.