Provides a formula interface for the 'glmnet' package for elasticnet regression, a method for cross-validating the alpha parameter, and other quality-of-life tools.
This version fixes a bug in the assignment of observations to crossvalidation folds in cva.glmnet
. The impact is most serious for small datasets, where the number of observations per fold is relatively low. If you are using this function, it's highly recommended you update the package.
Some quality-of-life functions to streamline the process of fitting elastic net models with glmnet
, specifically:
glmnet.formula
provides a formula/data frame interface to glmnet
.cv.glmnet.formula
does a similar thing for cv.glmnet
.predict
and coef
for both the above.cva.glmnet
to choose both the alpha and lambda parameters via cross-validation, following the approach described in the help page for cv.glmnet
. Optionally does the cross-validation in parallel.plot
, predict
and coef
for the above.You can install the development version from Github using devtools::install_github
.
install.packages("devtools")
library(devtools)
install_github("hong-revo/glmnetUtils")
library(glmnetUtils)
cva.glmnet
. The impact is most serious for small datasets, where the number of observations per fold is relatively low. If you are using this function, it's highly recommended you update the package.nfolds
argument was not being passed to glmnet::cv.glmnet
.use.model.frame=TRUE
. This works in an additive fashion, ie the formula ~ a + b:c + d*e
is treated as consisting of three terms, a
, b:c
and d*e
each of which is processed independently of the others. A dot in the formula includes all main effect terms, ie ~ . + a:b + f(x)
expands to ~ a + b + x + a:b + f(x)
(assuming a, b and x are the only columns in the data). Note that a formula like ~ (a + b) + (c + d)
will be treated as two terms, a + b
and c + d
.glmnet
/cv.glmnet
object that uses the original matrix/vector interface is now useful.cva.glmnet
.