lasso_cv  R Documentation 
cv.glmnet
Fit a first crossvalidation on lasso regression and return selected covariates.
Can deal with very large sparse data matrices.
Intended for binary reponse only (option family = "binomial"
is forced).
Depends on the cv.glmnet
function from the package glmnet
.
lasso_cv(x, y, nfolds = 5, foldid = NULL, betaPos = TRUE, ...)
x 
Input matrix, of dimension nobs x nvars. Each row is an observation
vector. Can be in sparse matrix format (inherit from class

y 
Binary response variable, numeric. 
nfolds 
Number of folds  default is 5. Although 
foldid 
An optional vector of values between 1 and 
betaPos 
Should the covariates selected by the procedure be positively
associated with the outcome ? Default is 
... 
Other arguments that can be passed to 
An object with S3 class "log.lasso"
.
beta 
Numeric vector of regression coefficients in the lasso.
In 
selected_variables 
Character vector, names of variable(s) selected with the
lassocv approach.
If 
Emeline Courtois
Maintainer: Emeline Courtois
emeline.courtois@inserm.fr
set.seed(15)
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)
lcv < lasso_cv(x = drugs, y = ae, nfolds = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.