predict.surv_explainer {survex} | R Documentation |
Model Predictions for Survival Models
Description
This function allows for calculating model prediction in a unified way.
Usage
## S3 method for class 'surv_explainer'
predict(object, newdata = NULL, output_type = "survival", times = NULL, ...)
Arguments
object |
an explainer object - model preprocessed by the |
newdata |
data used for the prediction |
output_type |
character, either |
times |
a numeric vector of times for the survival and cumulative hazard function predictions to be evaluated at. If |
... |
other arguments, currently ignored |
Value
A vector or matrix containing the prediction.
Examples
library(survival)
library(survex)
cph <- coxph(Surv(time, status) ~ ., data = veteran, model = TRUE, x = TRUE, y = TRUE)
rsf_ranger <- ranger::ranger(Surv(time, status) ~ .,
data = veteran,
respect.unordered.factors = TRUE,
num.trees = 100,
mtry = 3,
max.depth = 5
)
cph_exp <- explain(cph)
rsf_ranger_exp <- explain(rsf_ranger,
data = veteran[, -c(3, 4)],
y = Surv(veteran$time, veteran$status)
)
predict(cph_exp, veteran[1, ], output_type = "survival")[, 1:10]
predict(cph_exp, veteran[1, ], output_type = "risk")
predict(rsf_ranger_exp, veteran[1, ], output_type = "chf")[, 1:10]
[Package survex version 1.2.0 Index]