blasso: Bootstrap Validation for Quantitative Lasso Regression

View source: R/blasso.R

blassoR Documentation

Bootstrap Validation for Quantitative Lasso Regression

Description

This function performs n glmnet::cv.glmnet(family = c("gaussian", "poisson")) models using bootstrap validation and splitting the input data in train and test at each loop.

Usage

blasso(
  x,
  y,
  loops = 2,
  bootstrap = TRUE,
  alpha = 1,
  nfolds = 10,
  offset = NULL,
  family = "gaussian",
  ntest = NULL,
  seed = 987654321,
  ncores = 2
)

Arguments

x

x matrix as in glmnet.

y

Response variable. Should be numeric a vector.

loops

Number of loops (a glmnet::cv.glmnet model will be performed in each loop).

bootstrap

Logical indicating if bootstrap will be performed or not.

alpha

The elasticnet mixing parameter, with 0 ≤ alpha ≤ 1. alpha = 1 is the lasso penalty, and alpha = 0 the ridge penalty.

nfolds

Number of folds - default is 10. 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.

offset

A vector of length nobs that is included in the linear predictor. See ?glmnet::glmnet()

family

Response type. Quantitative for family = "gaussian" or family = "poisson" (non-negative counts).

ntest

Numeric indicating the percentage of observations that will be used as test set. Default is NULL (no test set).

seed

set.seed() that will be used.

ncores

Number of cores. Each loop will run in one core using the foreach package.

Value

A LassoLoop object with the results.

Author(s)

Pol Castellano-Escuder

References

Jerome Friedman, Trevor Hastie, Robert Tibshirani (2010). Regularization Paths for Generalized Linear Models via Coordinate Descent. Journal of Statistical Software, 33(1), 1-22. URL http://www.jstatsoft.org/v33/i01/.


pcastellanoescuder/lassoloops documentation built on July 25, 2022, 12:42 p.m.