Skip to contents

Visualize survival predictions, feature attributions, and contribution percentages and force plots for survival results. The latter two are specifically for GradSHAP(t) and IntGrad(t) methods.

Usage

# S3 method for class 'surv_result'
plot(x, ..., type = "attr")

plot_force(x, num_bars = 10)

plot_pred(x)

plot_attr(x, normalize = "none", add_comp = NULL)

plot_contr(x, aggregate = FALSE)

Arguments

x

An object of class surv_result containing survival attribution results.

...

(unsed arguments)

type

Type of plot to generate when using the generic plot() method. Options:

  • "pred": plot survival predictions over time

  • "attr": plot feature attributions over time (default)

  • "contr": plot feature contributions percentages over time

  • "force": plot force plots for each instance

num_bars

Number of bars to show in the force plot. Default is 10.

normalize

Normalization method for plot_attr(). Options:

  • "none" (default): no normalization

  • "abs": normalize by the sum of absolute values

  • "rel": normalize by the sum of values Note: Only recommended for visualization of GradSHAP(t) or IntGrad(t) results.

add_comp

Optional vector of comparison curves to add to the attribution plot (plot_attr() only). Options include:

  • "pred": predicted survival curve

  • "pred_ref": reference survival curve

  • "pred_diff": difference between prediction and reference You can also specify "all" to include all three curves. Default is NULL.

aggregate

Logical; if TRUE, contributions are aggregated across all instances in plot_contr(). If FALSE (default), one panel per instance is shown.

Value

A ggplot2 object.

Details

These functions provide a convenient way to visualize the results of survival attribution methods:

  • plot() is a generic wrapper that dispatches to the appropriate plot type based on the type argument.

  • plot_pred() visualizes survival predictions across time for the selected instances.

  • plot_attr() displays time-resolved attributions over time per instance.

The following methods are only available for GradSHAP(t) and IntGrad(t):

  • plot_contr() visualizes the relative contribution of features over time, optionally aggregated across instances for global insights.

  • plot_force() generates force plots showing the features' effect to the prediction over time.