
Survival Probabilities From a Tidymodels Workflow as a Matrix (for survex)
Source:R/adapter_tidymodels_survex.R
adapter_tidymodels_survex.Rd`survex::explain_survival()` wants a function that returns an N by T matrix of survival probabilities, one row per subject and one column per time. A tidymodels censored-regression workflow returns a nested tibble instead (`predict(type = "survival", eval_time = times)`). This unnests it and checks the shape, so it can be used as `predict_survival_function`: pass a function of `(model, newdata, times)` that calls `adapter_tidymodels_survex(model, newdata, times)`.
Arguments
- workflow
A fitted tidymodels workflow (or any object whose `predict()` method accepts `new_data`, `type = "survival"` and `eval_time`).
- new_data
Data frame of subjects.
- times
Numeric vector of evaluation times (finite, non-negative, increasing; duplicates are not allowed). The columns of the result follow this order.