View source: R/BinomialModel.R
| Enet | R Documentation |
Fits elastic net model with cross-validation to find optimal alpha and lambda. Searches across a grid of alpha values (0 to 1) and lambda values to minimize cross-validation error.
Enet(train.x, train.y, lambdamax, nfold = 10)
train.x |
Training predictors matrix. |
train.y |
Training binary outcomes (0/1 or factor). |
lambdamax |
Maximum lambda value for the grid search. |
nfold |
Number of CV folds. Default is '10'. |
List containing:
Optimal alpha value (0-1)
Optimal lambda value
if (requireNamespace("glmnet", quietly = TRUE)) {
set.seed(123)
train_data <- matrix(rnorm(50 * 5), ncol = 5)
train_outcome <- rbinom(50, 1, 0.5)
result <- Enet(train.x = train_data, train.y = train_outcome, lambdamax = 1, nfold = 5)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.