fit <- glmnet(x, y, trace.it = TRUE)
#> |=================================== | 65%21 Miscellaneous features
This chapter currently houses small features of glmnet that I’m not sure where to put (or even to include).
- Section 4.2 of Friedman et al. (2010)?
21.1 The intercept argument
The intercept argument allows the user to decide if an intercept should be included in the model or not (it is never penalized). The default is intercept = TRUE. If intercept = FALSE the intercept is forced to be zero.
21.2 The trace.it argument
In large data settings, it may take some time to fit the entire sequence of elastic net models. glmnet and cv.glmnet come equipped with a progress bar which can be displayed with the argument trace.it = TRUE. This gives the user a sense of how model fitting is progressing.
fit <- cv.glmnet(x, y, trace.it = TRUE)
#> Training
#> |======================================================| 100%
#> Fold: 1/10
#> |======================================================| 100%
#> Fold: 2/10
#> |======================================================| 100%
#> Fold: 3/10
#> |============================= | 54%If you want glmnet and cv.glmnet to always print the progress bar, this can be achieved (for a session) via a call to glmnet.control with the itrace argument:
glmnet.control(itrace = 1)To reset this behavior (no progress bar), set itrace = 0:
glmnet.control(itrace = 0)21.3 The bigGlm function
The glmnet package provides a convenience function bigGlm for fitting a single unpenalized GLM but allowing all the options of glmnet. In particular, the user can set upper and/or lower bounds on the coefficients, and can provide the x matrix in sparse matrix format: options that are not available for the stats::glm function.