Learn R Programming

PSsurvival (version 0.2.0)

plot.weightedKM: Plot Method for Weighted Kaplan-Meier Estimates

Description

Plot Method for Weighted Kaplan-Meier Estimates

Usage

# S3 method for weightedKM
plot(
  x,
  type = "Kaplan-Meier",
  include_CI = TRUE,
  conf_type = "log-log",
  conf_level = 0.95,
  max_time = NULL,
  strata_to_plot = NULL,
  strata_colors = NULL,
  curve_width = 1,
  CI_alpha = 0.3,
  legend_position = "right",
  legend_title = NULL,
  plot_title = NULL,
  xlab = "Time",
  ylab = NULL,
  xlim = NULL,
  ylim = NULL,
  risk_table = FALSE,
  risk_table_stats = c("n.risk", "n.acc.event"),
  risk_table_height = 0.25,
  risk_table_breaks = NULL,
  risk_table_fontsize = 3.5,
  ...
)

Value

A ggplot2 object if risk_table = FALSE, or a combined plot (cowplot object) if risk_table = TRUE.

Arguments

x

An object of class "weightedKM" from weightedKM().

type

Type of curve to plot: "Kaplan-Meier" (survival probabilities, default) or "CR" (cumulative risk, aka. cumulative incidence = 1 - survival).

include_CI

Logical. Include confidence interval ribbons? Default TRUE.

conf_type

Type of confidence interval: "plain", "log", or "log-log" (default). See Details.

conf_level

Confidence level for intervals. Default 0.95.

max_time

Maximum time to display on x-axis. Default is maximum observed event time.

strata_to_plot

Character vector of treatment levels to plot. Default plots all groups.

strata_colors

Character vector of colors for each stratum in strata_to_plot. Must match length. Default uses ggplot2 colors.

curve_width

Line width for survival curves. Default 1.

CI_alpha

Transparency level for confidence interval ribbons (0-1). Default 0.3.

legend_position

Position of legend: "right" or "bottom". Default "right".

legend_title

Title for legend. Default "Treatment".

plot_title

Main plot title. Default depends on type.

xlab

X-axis label. Default "Time".

ylab

Y-axis label. Default depends on type.

xlim

Numeric vector of length 2 specifying x-axis limits. Default c(0, max_time).

ylim

Numeric vector of length 2 specifying y-axis limits. Default c(0, 1).

risk_table

Logical. Add risk table below the plot? Default FALSE. Requires cowplot package if TRUE.

risk_table_stats

Character vector specifying statistics to display in risk table. Options: "n.risk" (number at risk), "n.acc.event" (cumulative events). Default c("n.risk", "n.acc.event").

risk_table_height

Numeric. Relative height of risk table (0-1). Default 0.25.

risk_table_breaks

Numeric vector of time points for risk table columns. If NULL (default), automatically determined based on max_time.

risk_table_fontsize

Numeric. Font size for risk table text. Default 3.5.

...

Additional arguments (currently unused).

Details

When type = "CR", the function plots \(1 - S(t)\) representing the probability of experiencing the event by time t. Variance is the same as for survival, but confidence intervals are calculated on the CR scale.