| .fit.ridge | R Documentation |
tidyfitFits a linear regression or classification with L2 penalty on a 'tidyFit' R6 class. The function can be used with regress and classify.
## S3 method for class 'ridge'
.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 (L2 penalty)
Important method arguments (passed to m)
The ridge regression is estimated using glmnet::glmnet with alpha = 0. See ?glmnet for more details. For classification pass family = "binomial" to ... in m or use classify.
Implementation
If the response variable contains more than 2 classes, a multinomial response is used automatically.
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
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.adalasso, .fit.enet and m methods
# Load data
data <- tidyfit::Factor_Industry_Returns
# Stand-alone function
fit <- m("ridge", Return ~ ., data, lambda = 0.5)
fit
# Within 'regress' function
fit <- regress(data, Return ~ ., m("ridge", 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.