Learn R Programming

PSsurvival (version 0.2.0)

plot.surveff: Plot Method for surveff Objects

Description

Plot Method for surveff Objects

Usage

# S3 method for surveff
plot(
  x,
  type = "surv",
  max_time = NULL,
  strata_to_plot = NULL,
  strata_colors = NULL,
  conf_level = 0.95,
  include_CI = TRUE,
  curve_width = 1,
  CI_alpha = 0.3,
  legend_position = "right",
  legend_title = NULL,
  plot_title = NULL,
  ...
)

Value

A ggplot2 object.

Arguments

x

A surveff object.

type

Type of plot: "surv" for survival curves or "survdiff" for treatment effect curves. Default "surv".

max_time

Maximum time to display on x-axis. If NULL, uses max(eval_times).

strata_to_plot

Vector of strata to plot. For type = "surv", must be subset of treatment_levels. For type = "survdiff", must be subset of contrast names (column names of difference_estimates). If NULL, plots all available strata.

strata_colors

Vector of color names/codes for strata. Length must match strata_to_plot. Order matches strata order. If NULL, uses ggplot2 default colors.

conf_level

Confidence level for confidence intervals. Default 0.95.

include_CI

Logical. Include confidence interval ribbons? Default TRUE.

curve_width

Line width for survival/difference curves. Default 1.

CI_alpha

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

legend_position

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

legend_title

Title for legend. If NULL, uses "Treatment" for type="surv" or "Comparison" for type="survdiff".

plot_title

Plot title. If NULL, uses default title based on type.

...

Additional arguments (ignored).

Details

Creates publication-ready plots of survival curves or treatment effects over time.

For type = "surv": Plots estimated survival functions with optional confidence intervals. Y-axis ranges from 0 to 1.

For type = "survdiff": Plots estimated treatment effects (survival differences) with optional confidence intervals. Y-axis is not constrained to [0,1].