transform_to_stepfunction {survex} | R Documentation |
Transform Fixed Point Prediction into a Stepfunction
Description
Some models return the survival function or cumulative hazard function prediction at the times of events present in the training data set. This is a convenient utility to allow the prediction to be evaluated at any time.
Usage
transform_to_stepfunction(
predict_function,
eval_times = NULL,
...,
type = NULL,
prediction_element = NULL,
times_element = NULL
)
Arguments
predict_function |
a function making the prediction based on |
eval_times |
a numeric vector of times, at which the fixed predictions are made. This can be |
... |
other parameters passed to predict_function |
type |
the type of function to be returned, either |
prediction_element |
if |
times_element |
if |
Value
The function returns a function with three arguments, (model
, newdata
, times
), ready to supply it to an explainer.
Examples
library(survex)
library(survival)
rsf_src <- randomForestSRC::rfsrc(Surv(time, status) ~ ., data = veteran)
chf_function <- transform_to_stepfunction(predict,
type = "chf",
prediction_element = "chf",
times_element = "time.interest"
)
explainer <- explain(rsf_src, predict_cumulative_hazard_function = chf_function)