Learn R Programming

survex (version 1.2.0)

risk_from_chf: Generate Risk Prediction based on the Survival Function

Description

Some models do not come with a ready to use risk prediction. This function allows for its generation based on the cumulative hazard function.

Usage

risk_from_chf(predict_cumulative_hazard_function, times)

Value

A function of two arguments (model, newdata) returning a vector of risks.

Arguments

predict_cumulative_hazard_function

a function of three arguments (model, newdata, times) that allows for making cumulative hazard predictions.

times

a numeric vector of times at which the function should be evaluated.

Examples

Run this code
# \donttest{
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"
)
risk_function <- risk_from_chf(chf_function, unique(veteran$time))

explainer <- explain(rsf_src,
    predict_cumulative_hazard_function = chf_function,
    predict_function = risk_function
)
# }

Run the code above in your browser using DataLab