| .fit.adalasso | R Documentation |
tidyfitFits an adaptive Lasso regression or classification on a 'tidyFit' R6 class. The function can be used with regress and classify.
## S3 method for class 'adalasso'
.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)
lambda_ridge (L2 penalty (default = 0.01) used in the first step to determine the penalty factor)
Important method arguments (passed to m)
The adaptive Lasso is a weighted implementation of the Lasso algorithm, with covariate-specific weights obtained using an initial regression fit (in this case, a ridge regression with lambda = lambda_ridge, where lambda_ridge can be passed as an argument). The adaptive Lasso is computed using the glmnet::glmnet function. See ?glmnet for more details. For classification pass family = "binomial" to ... in m or use classify.
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 glmnet::glmnet cannot be used (e.g. dfmax). This is to guarantee identical grids across groups in the tibble.
A fitted 'tidyFit' class model.
Johann Pfitzinger
Zou, H. (2006). The Adaptive Lasso and Its Oracle Properties. Journal of the American Statistical Association, 101(476), 1418-1429.
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 https://www.jstatsoft.org/v33/i01/.
.fit.lasso, .fit.enet, .fit.ridge and m methods
# Load data
data <- tidyfit::Factor_Industry_Returns
# Stand-alone function
fit <- m("adalasso", Return ~ ., data, lambda = 0.5)
fit
# Within 'regress' function
fit <- regress(data, Return ~ ., m("adalasso", lambda = c(0.1, 0.5)),
.mask = c("Date", "Industry"))
coef(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.