plot.model_profile_survival {survex} | R Documentation |
Plot Model Profile for Survival Models
Description
This function plots objects of class "model_profile_survival"
created
using the model_profile()
function.
Usage
## S3 method for class 'model_profile_survival'
plot(
x,
...,
geom = "time",
variables = NULL,
variable_type = NULL,
facet_ncol = NULL,
numerical_plot_type = "lines",
times = NULL,
marginalize_over_time = FALSE,
plot_type = NULL,
title = "default",
subtitle = "default",
colors = NULL,
rug = "all",
rug_colors = c("#dd0000", "#222222")
)
Arguments
x |
an object of class |
... |
additional objects of class |
geom |
character, either |
variables |
character, names of the variables to be plotted. When |
variable_type |
character, either |
facet_ncol |
number of columns for arranging subplots. Only used when |
numerical_plot_type |
character, either |
times |
numeric vector, times for which the profile should be plotted, the times must be present in the 'times' field of the explainer. If |
marginalize_over_time |
logical, if |
plot_type |
character, one of |
title |
character, title of the plot |
subtitle |
character, subtitle of the plot, |
colors |
character vector containing the colors to be used for plotting variables (containing either hex codes "#FF69B4", or names "blue"). |
rug |
character, one of |
rug_colors |
character vector containing two colors (containing either hex codes "#FF69B4", or names "blue"). The first color (red by default) will be used to mark event times, whereas the second (grey by default) will be used to mark censor times. |
Value
A collection of ggplot
objects arranged with the patchwork
package.
Examples
library(survival)
library(survex)
model <- randomForestSRC::rfsrc(Surv(time, status) ~ ., data = veteran)
exp <- explain(model)
m_prof <- model_profile(exp, categorical_variables = "trt")
plot(m_prof)
plot(m_prof, numerical_plot_type = "contours")
plot(m_prof, variables = c("trt", "age"), facet_ncol = 1)
plot(m_prof, geom = "variable", variables = "karno", plot_type = "pdp+ice")
plot(m_prof, geom = "variable", times = exp$times[c(5, 10)],
variables = "karno", plot_type = "pdp+ice")
plot(m_prof, geom = "variable", times = exp$times[c(5, 10)],
variables = "trt", plot_type = "pdp+ice")