elastic.funs {conformalInference.multi} | R Documentation |
Elastic Net, Lasso, Ridge Regression Training and Prediction Functions
Description
Construct training and prediction functions for the elastic net, the lasso,
or ridge regression, based on the glmnet
package, over a
sequence of (given or internally computed) lambda values.
Usage
elastic.funs(
gamma = 0.5,
standardize = TRUE,
intercept = TRUE,
lambda = NULL,
nlambda = 50,
lambda.min.ratio = 1e-04,
cv.rule = c("min", "1se")
)
lasso.funs(
standardize = TRUE,
intercept = TRUE,
lambda = NULL,
nlambda = 50,
lambda.min.ratio = 1e-04,
cv.rule = c("min", "1se")
)
ridge.funs(
standardize = TRUE,
intercept = TRUE,
lambda = NULL,
nlambda = 50,
lambda.min.ratio = 1e-04,
cv.rule = c("min", "1se")
)
Arguments
gamma |
Mixing parameter (between 0 and 1) for the elastic net, where 0 corresponds to ridge regression, and 1 to the lasso. Default is 0.5. |
standardize , intercept |
Should the data be standardized, and should an intercept be included? Default for both is TRUE. |
lambda |
Sequence of lambda values over which training is performed. This must be in decreasing order, and — this argument should be used with caution! When used, it is usually best to grab the sequence constructed by one initial call to glmnet (see examples). Default is NULL, which means that the nlambda, lambda.min.ratio arguments will define the lambda sequence (see next). |
nlambda |
Number of lambda values over which training is performed. In particular, the lambda sequence is defined by nlambda log-spaced values between lambda.max and lambda.min.ratio * lambda.max, where lambda.max is the smallest value of lambda at which the solution has all zero components, and lambda.min.ratio is a small fraction (see next). Default is 50. |
lambda.min.ratio |
Small fraction that gets used in conjunction with nlambda to specify a lambda sequence (see above). Default is 1e-4. |
cv.rule |
If the cv argument is TRUE, then cv.rule determines which rule should be used for the predict function, either "min" (the usual rule) or "1se" (the one-standard-error rule). See the glmnet help files for details. Default is "min". |
Details
This function is based on the packages glmnet
.
Notice that Cross Validation to select the best lambda value is compulsory!
The functions lasso.funs and ridge.funs are convenience
functions, they simply call elastic.funs with gamma = 1 and gamma = 0,
respectively.
Value
A list with three components: train.fun, predict.fun, active.fun. The third function is designed to take the output of train.fun, and reports which features are active for each fitted model contained in this output.