plot.calibrator: Plot the observed and fitted survival for the linear...

View source: R/oop_calibrator.R

plot.calibratorR Documentation

Plot the observed and fitted survival for the linear predictor score strata.

Description

Draws two types of plots:

  • a Kaplan-Meier plots of the observed survival (solid line) and the Cox model-predicted survival in each linear predictor score strata. The global calibration measures are presented in plot caption. The legend contains the number of observations assigned to each linear predictor score strata. The total numbers of observations and events are shown in the plot tag.

  • a list of plots of square errors averaged over unique time points, observations and unique values of the linear predictor score

Usage

## S3 method for class 'calibrator'
plot(
  x,
  type = c("strata", "squares"),
  palette = NULL,
  cust_theme = survminer::theme_survminer(),
  KM_size = 0.5,
  show_cox = TRUE,
  cox_size = 0.5,
  cox_linetype = "dashed",
  color_seed = 1234,
  signif_digits = 2,
  show_reference = TRUE,
  error_stat = c("none", "se", "2se", "95perc"),
  ...
)

Arguments

x

a calibrator object.

type

type of the plot or plots:

  • 'strata' generates a Kaplan-Meier plot of survival in the score strata

  • 'squares' draws a series of plots of squared errors averaged over unique time points, observations and unique values of the linear predictor score

palette

a vector of color names corresponding to the strata number.

cust_theme

custom ggplot theme.

KM_size

size of the Kaplan-Meier plot line, ignored if type = 'squares'.

show_cox

logical, should the Cox model-predicted survival for the strata be plotted? Ignored if type = 'squares'.

cox_size

size of the Cox survival plot line. Ignored if show_cox = FALSE or type = 'squares'.

cox_linetype

type of the Cox survival plot line, dashed by default. Ignored if show_cox = FALSE or type = 'squares'.

color_seed

seed for the random color generator, ignored if palette provided.

signif_digits

significant digits for rounding the calibration statistics displayed in the plot caption. Ignored if type = 'squares'.

show_reference

logical, should averaged squared errors be displayed for the reference (NULL model)? Defaults to TRUE. Used only if type = 'squares'.

error_stat

error statistic to be presented as a ribbon, defaults to none. Used only if type = 'squares'.

...

extra arguments passed to ggsurvplot (if type = 'strata') or to plot_squares.

Details

The Kaplan-Meier plot is generated with ggsurvplot.

Value

a ggplot object or a list og ggplot objects.


PiotrTymoszuk/coxExtensions documentation built on Feb. 6, 2024, 10:58 p.m.