Learn R Programming

stepPenal (version 0.2)

StepPenalL2: Stepwise forward variable selection using penalized regression.

Description

Stepwise forward variable selection based on the combination of L2 and L0 penalties. The optimization is done using the "BFGS" method in stats::optim

Usage

StepPenalL2(Data, lamda, w, standardize = TRUE)

Arguments

Data

should have the following structure: the first column must be the binary response variable y.

lamda

the tuning penalty parameter

w

the weight parameter for the sum (1-w)L0+ wL2

standardize

Logical flag for the predictors' standardization, prior to fitting the model. Default is standardize=TRUE

Value

a list with the shrinked coefficients and the names of the selected variables, i.e those variables with an estimated coefficient different from zero.

Details

lamda and w parameters need to be tuned by cross-Validation using stepPenal::tuneParam

See Also

optim

Examples

Run this code
# NOT RUN {
# use the StepPenal function on a simulated dataset, with given lamda and w.

set.seed(14)
beta    <- c(3, 2, -1.6, -1)
noise   <- 5
simData <- SimData(N=100, beta=beta, noise=noise, corr=TRUE)
# }
# NOT RUN {
before <- Sys.time()
stepPenalL2 <- StepPenalL2(Data=simData, lamda=1.5, w=0.6)
after <- Sys.time()
after-before

(varstepPenal<- stepPenalL2$coeffP)
# }

Run the code above in your browser using DataLab