Learn R Programming

msaenet (version 2.1)

msaenet: Multi-Step Adaptive Elastic-Net

Description

Multi-Step Adaptive Elastic-Net

Usage

msaenet(x, y, family = c("gaussian", "binomial", "poisson", "multinomial", "cox", "mgaussian"), init = c("enet", "ridge"), nsteps = 2L, nfolds = 5L, alphas = seq(0.05, 0.95, 0.05), gamma = 1, rule = c("lambda.min", "lambda.1se"), seed = 1001, parallel = FALSE, verbose = FALSE)

Arguments

x
Data matrix.
y
Response vector.
family
Response type.
init
Type of the penalty used in the initial estimation step. Can be "enet" or "ridge". See glmnet for details.
nsteps
How many adaptive estimation steps? At least 2. We assume adaptive elastic-net has only 1 adaptive estimation step.
nfolds
Fold numbers of cross-validation.
alphas
Vector of candidate alphas to use in cv.glmnet.
gamma
Scaling factor for adaptive weights: weights = coefs^(-gamma).
rule
Model selection criterion, "lambda.min" or "lambda.1se". See cv.glmnet for details.
seed
Two random seeds for cross-validation fold division in two estimation steps.
parallel
Logical. Enable parallel parameter tuning or not, default is FALSE. To enable parallel tuning, load the doParallel package and run registerDoParallel() with the number of CPU cores before calling this function.
verbose
Should we print out the estimation progress?

Value

List of coefficients beta and glmnet model object model.

References

Nan Xiao and Qing-Song Xu. (2015). Multi-step adaptive elastic-net: reducing false positives in high-dimensional variable selection. Journal of Statistical Computation and Simulation 85(18), 3755--3765.

Examples

Run this code
dat = msaenet.sim.gaussian(n = 150, p = 500, rho = 0.6,
                           coef = rep(1, 5), snr = 2, p.train = 0.7,
                           seed = 1001)

msaenet.fit = msaenet(dat$x.tr, dat$y.tr,
                      alphas = seq(0.2, 0.8, 0.2),
                      nsteps = 3L, seed = 1003)

print(msaenet.fit)
msaenet.nzv(msaenet.fit)
msaenet.fp(msaenet.fit, 1:5)
msaenet.tp(msaenet.fit, 1:5)
msaenet.pred = predict(msaenet.fit, dat$x.te)
msaenet.rmse(dat$y.te, msaenet.pred)
plot(msaenet.fit)

Run the code above in your browser using DataLab