Skip to contents

Convenience wrapper for LASSO regression (L1 regularization) using glmnet with cross-validation. Equivalent to run_glmnet with alpha = 1.

Usage

run_lasso(X, y, family = gaussian(), standardize = TRUE, nfolds = 10)

Arguments

X

Design matrix of predictors (n × p).

y

Response vector or survival object.

family

Response family. Can be gaussian(), binomial(), poisson(), Gamma(), or "cox" for Cox regression.

standardize

Logical. Should variables be standardized? Default TRUE.

nfolds

Number of cross-validation folds. Default 10.

Value

A list containing the same components as run_glmnet.

Details

LASSO (Least Absolute Shrinkage and Selection Operator) performs both regularization and variable selection by setting some coefficients to exactly zero. This function provides a convenient interface specifically for LASSO regression.

Examples

if (FALSE) { # \dontrun{
# Simulate sparse data
set.seed(123)
n <- 100; p <- 50
X <- matrix(rnorm(n * p), n, p)
y <- X[,1:3] %*% c(1, -1, 0.5) + rnorm(n)

# Run LASSO
lasso_result <- run_lasso(X, y)
print(lasso_result$selected)
} # }