.fit.group_lasso | R Documentation |
tidyfit
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
.
## S3 method for class 'group_lasso'
.fit(self, data = NULL)
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). |
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.
A fitted 'tidyFit' class model.
Johann Pfitzinger
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.
.fit.lasso
, .fit.blasso
, .fit.adalasso
and m
methods
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.