dot-fit.group_lasso: Grouped Lasso regression and classification for 'tidyfit'

.fit.group_lassoR Documentation

Grouped Lasso regression and classification for tidyfit

Description

Fits a linear regression or classification with a grouped L1 penalty on a 'tidyFit' R6 class. The function can be used with regress and classify.

Usage

## S3 method for class 'group_lasso'
.fit(self, data = NULL)

Arguments

self

a 'tidyFit' R6 class.

data

a data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr).

Details

Hyperparameters:

  • lambda (L1 penalty)

Important method arguments (passed to m)

The Group Lasso regression is estimated using gglasso::gglasso. The 'group' argument is a named vector passed directly to m() (see examples). See ?gglasso for more details. Only binomial classification is possible. Weights are ignored for classification.

Implementation

Features are standardized by default with coefficients transformed to the original scale.

If no hyperparameter grid is passed (is.null(control$lambda)), dials::grid_regular() is used to determine a sensible default grid. The grid size is 100. Note that the grid selection tools provided by gglasso::gglasso cannot be used (e.g. dfmax). This is to guarantee identical grids across groups in the tibble.

Value

A fitted 'tidyFit' class model.

Author(s)

Johann Pfitzinger

References

Yang Y, Zou H, Bhatnagar S (2020). gglasso: Group Lasso Penalized Learning Using a Unified BMD Algorithm. R package version 1.5, https://CRAN.R-project.org/package=gglasso.

See Also

.fit.lasso, .fit.blasso, .fit.adalasso and m methods

Examples

# Load data
data <- tidyfit::Factor_Industry_Returns

groups <- setNames(c(1, 2, 2, 3, 3, 1), c("Mkt-RF", "SMB", "HML", "RMW", "CMA", "RF"))

# Stand-alone function
fit <- m("group_lasso", Return ~ ., data, lambda = 0.5, group = groups)
fit

# Within 'regress' function
fit <- regress(data, Return ~ ., m("group_lasso", lambda = c(0.1, 0.5), group = groups),
               .mask = c("Date", "Industry"))
coef(fit)


tidyfit documentation built on April 4, 2025, 4:38 a.m.