adapt_cv {adapt4pv}R Documentation

fit an adaptive lasso with adaptive weights derived from lasso-cv


Fit a first lasso regression with cross-validation to determine adaptive weights. Run a cross-validation to determine an optimal lambda. Two options for implementing cross-validation for the adaptive lasso are possible through the type_cv parameter (see bellow). Can deal with very large sparse data matrices. Intended for binary reponse only (option family = "binomial" is forced). The cross-validation criterion used is deviance. Depends on the cv.glmnet function from the package glmnet.


  gamma = 1,
  nfolds = 5,
  foldid = NULL,
  type_cv = "proper",
  betaPos = TRUE,



Input matrix, of dimension nobs x nvars. Each row is an observation vector. Can be in sparse matrix format (inherit from class "sparseMatrix" as in package Matrix).


Binary response variable, numeric.


Tunning parameter to defined the penalty weights. See details below. Default is set to 1.


Number of folds - default is 5. Although nfolds can be as large as the sample size (leave-one-out CV), it is not recommended for large datasets. Smallest value allowable is nfolds=3.


An optional vector of values between 1 and nfolds identifying what fold each observation is in. If supplied, nfolds can be missing.


Character, indicates which implementation of cross-validation is performed for the adaptive lasso: a "naive" one, where adaptive weights obtained on the full data are used, and a "proper" one, where adaptive weights are calculated for each training sets. Could be either "naive" or "proper". Default is "proper".


Should the covariates selected by the procedure be positively associated with the outcome ? Default is TRUE.


Other arguments that can be passed to glmnet from package glmnet other than nfolds, foldid, penalty.factor, standardize, intercept and family.


The adaptive weight for a given covariate i is defined by

w_i = 1/|β^{CV}_i|^γ

where β^{CV}_i is the PENALIZED regression coefficient associated to covariate i obtained with cross-validation.


An object with S3 class "adaptive".


Numeric vector of penalty weights derived from cross-validation. Length equal to nvars.


Character, indicates which criterion is used with the adaptive lasso for variable selection. For adapt_cv function, criterion is "cv".


Numeric vector of regression coefficients in the adaptive lasso. If criterion = "cv" the regression coefficients are PENALIZED, if criterion = "bic" the regression coefficients are UNPENALIZED. Length equal to nvars. Could be NA if adaptive weights are all equal to infinity.


Character vector, names of variable(s) selected with this adaptive approach. If betaPos = TRUE, this set is the covariates with a positive regression coefficient in beta. Else this set is the covariates with a non null regression coefficient in beta. Covariates are ordering according to magnitude of their regression coefficients absolute value in the adaptive lasso.


Emeline Courtois
Maintainer: Emeline Courtois


drugs <- matrix(rbinom(100*20, 1, 0.2), nrow = 100, ncol = 20)
colnames(drugs) <- paste0("drugs",1:ncol(drugs))
ae <- rbinom(100, 1, 0.3)
acv <- adapt_cv(x = drugs, y = ae, nfolds = 5)

[Package adapt4pv version 0.2-1 Index]