prediction_breakdown: BreakDown for survival models

Description Usage Arguments Value Examples

View source: R/prediction_breakdown.R

Description

Function prediction_breakdown is an extension of a broken function from breakDown package. It computes the contribution in prediction for the variables in the model. The contribution is defined as the difference between survival probabilities for model with added specific value of variable and with the random levels of this variable.

Usage

1
prediction_breakdown(explainer, observation, time = NULL, prob = NULL, ...)

Arguments

explainer

an object of the class 'surv_explainer'

observation

a new observation to explain

time

a time point at which variable contributions are computed. If NULL median time is taken.

prob

a survival probability at which variable contributions are computed

...

other parameters corresponding to arguments from broken function from breakDown package. See https://github.com/pbiecek/breakDown/blob/master/R/break_agnostic.R for details

Value

An object of class surv_prediction_breakdown_explainer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(survxai)
library(rms)
data("pbcTest")
data("pbcTrain")
predict_times <- function(model, data, times){
                  prob <- rms::survest(model, data, times = times)$surv
                  return(prob)
                  }
cph_model <- cph(Surv(years, status)~sex + bili + stage, data=pbcTrain, surv=TRUE, x = TRUE, y=TRUE)
surve_cph <- explain(model = cph_model, data = pbcTest[,-c(1,5)],
                    y = Surv(pbcTest$years, pbcTest$status), predict_function = predict_times)
broken_prediction <- prediction_breakdown(surve_cph, pbcTest[1,-c(1,5)])

survxai documentation built on Aug. 28, 2020, 5:07 p.m.