plot.survdnn {survdnn} | R Documentation |
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 class '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,
...
)
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. |
Value
A 'ggplot' object.
Examples
library(survival)
data(veteran)
set.seed(42)
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)