fit_lasso: Fit a (group) Lasso logistic regression classifier

View source: R/31_pre_processing_functions.R

fit_lassoR Documentation

Fit a (group) Lasso logistic regression classifier

Description

Performs Lasso or group Lasso logistic regression to distinguish between two groups of samples.

Usage

fit_lasso(
  control_train,
  treat_train,
  lambda_type = c("lambda.min", "lambda.1se"),
  classifier_method = c("lasso", "group_lasso"),
  group = NULL
)

Arguments

control_train

A matrix or data frame for the control group. Rows are samples, columns are features.

treat_train

A matrix or data frame for the treatment group. Rows are samples, columns are features.

lambda_type

Character. Type of lambda to use from cross-validation. Options are "lambda.min" (default) and "lambda.1se".

classifier_method

Character. Choice of classifier. "lasso" (default) or "group_lasso".

group

Optional grouping vector for group_lasso, same length as the number of columns in the input data.

Details

The function fits a logistic regression using either glmnet for Lasso or grpreg for group Lasso. Coefficients are soft-thresholded by the maximum coefficient times n^(-1/3) where n is the effective sample size.

Value

A numeric vector of estimated regression coefficients (excluding intercept), thresholded for small values.

Examples

## Not run: 
X1 <- matrix(rnorm(100), nrow = 10)
X2 <- matrix(rnorm(100), nrow = 10)
fit_lasso(X1, X2, classifier_method = "lasso")

## End(Not run)


HMC documentation built on June 8, 2025, 10:32 a.m.

Related to fit_lasso in HMC...