ridge_pro | R Documentation |
Trains a Cox proportional hazards model with Ridge regularization
using glmnet
.
ridge_pro(X, y_surv, tune = FALSE)
X |
A data frame of features. |
y_surv |
A |
tune |
Logical, whether to perform hyperparameter tuning (currently simplified/ignored
for direct |
A list of class "train" containing the trained glmnet
model object,
names of features used in training, and model type. The returned object
also includes fitted_scores
(linear predictor), y_surv
, and best_lambda
.
set.seed(42)
n_samples <- 50
n_features <- 10
X_data <- as.data.frame(matrix(rnorm(n_samples * n_features), ncol = n_features))
Y_surv_obj <- survival::Surv(
time = runif(n_samples, 100, 1000),
event = sample(0:1, n_samples, replace = TRUE)
)
# Train the model
ridge_model <- ridge_pro(X_data, Y_surv_obj)
print(ridge_model$finalModel)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.