Learn R Programming

survdnn (version 0.6.0)

plot.survdnn: Plot survdnn Survival Curves using ggplot2

Description

Visualizes survival curves predicted by a fitted `survdnn` model. Curves can be grouped by a categorical variable in `newdata` and optionally display only the group-wise means or overlay them.

Usage

# S3 method for survdnn
plot(
  x,
  newdata = NULL,
  times = 1:365,
  group_by = NULL,
  plot_mean_only = FALSE,
  add_mean = TRUE,
  alpha = 0.3,
  mean_lwd = 1.3,
  mean_lty = 1,
  ...
)

Value

A `ggplot` object.

Arguments

x

A fitted `survdnn` model object.

newdata

Optional data frame for prediction (defaults to training data).

times

A numeric vector of time points at which to compute survival probabilities.

group_by

Optional name of a column in `newdata` used to color and group curves.

plot_mean_only

Logical; if `TRUE`, plots only the mean survival curve per group.

add_mean

Logical; if `TRUE`, adds mean curves to the individual lines.

alpha

Alpha transparency for individual curves (ignored if `plot_mean_only = TRUE`).

mean_lwd

Line width for mean survival curves.

mean_lty

Line type for mean survival curves.

...

Reserved for future use.

Examples

Run this code
library(survival)
data(veteran)
set.seed(42)
# \donttest{
mod <- survdnn(Surv(time, status) ~ age + karno + celltype, data = veteran,
               hidden = c(16, 8), epochs = 100, verbose = FALSE)
plot(mod, group_by = "celltype", times = 1:300)
# }

Run the code above in your browser using DataLab