variable_response: Variable response for survival models

Description Usage Arguments Examples

View source: R/variable_response.R

Description

Function variable_response calculates the expected output condition on a selected variable.

Usage

1
variable_response(explainer, variable, type = "pdp", link = explainer$link)

Arguments

explainer

an object of the class 'surv_explainer'.

variable

a character with variable name.

type

a character - type of the response to be calculated. Currently following options are implemented: 'pdp' for Partial Dependency.

link

a function - a link function that shall be applied to raw model predictions. This will be inherited from the 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)
svr_cph <- variable_response(surve_cph, "sex")

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