plot.surv_ceteris_paribus_explainer: Plot for ceteris_paribus object

Description Usage Arguments Examples

View source: R/plot_ceteris_paribus.R

Description

Function plot for ceteris_paribus object visualise estimated survival curve of mean probabilities in chosen time points. Black lines on each plot correspond to survival curve for our new observation specified in the ceteris_paribus function.

Usage

1
2
3
4
5
6
7
8
9
## S3 method for class 'surv_ceteris_paribus_explainer'
plot(
  x,
  ...,
  selected_variable = NULL,
  scale_type = "factor",
  scale_col = NULL,
  ncol = 1
)

Arguments

x

object of class "surv_ceteris_paribus_explainer"

...

arguments to be passed to methods, such as graphical parameters for function geom_step.

selected_variable

name of variable we want to draw ceteris paribus plot

scale_type

type of scale of colors, either "discrete" or "gradient"

scale_col

vector containing values of low and high ends of the gradient, when "gradient" type of scale was chosen

ncol

number of columns for faceting

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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)
cp_cph <- ceteris_paribus(surve_cph, pbcTest[1,-c(1,5)])
plot(cp_cph)

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