stepcox_pro | R Documentation |
Trains a Cox proportional hazards model and performs backward
stepwise selection using MASS::stepAIC
to select important features.
stepcox_pro(X, y_surv, tune = FALSE)
X |
A data frame of features. |
y_surv |
A |
tune |
Logical, whether to perform hyperparameter tuning (currently ignored). |
A list of class "train" containing the trained coxph
model object
after stepwise selection, names of features used in training, and model type.
The returned object also includes fitted_scores
(linear predictor) and y_surv
.
set.seed(42)
n_samples <- 50
n_features <- 5
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
stepcox_model <- stepcox_pro(X_data, Y_surv_obj)
print(stepcox_model$finalModel)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.