ggsurv: Survival curves with ggplot2

Description Usage Arguments Value Author(s)

View source: R/ggsurv.R

Description

This function produces plots of the survival point estimates using ggplot2. As a first argument it needs a list of estimates created by the one of the estimation function of the stremr package. See http://ggobi.github.io/ggally/#ggallyggsurv for additional modifications of the resulting output plot.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
ggsurv(
  estimates,
  CI = TRUE,
  CI_line = FALSE,
  plot_cens = TRUE,
  surv_col = "gg.def",
  cens_col = "gg.def",
  lty_est = 1,
  shape_est = seq_along(estimates),
  lty_ci = 2,
  size_est = 0.5,
  size_ci = size_est,
  size_pt = size_est + 0.3,
  cens_size = 2,
  cens_shape = 3,
  back_white = TRUE,
  xlab = "Time",
  ylab = "Survival",
  main = "",
  legend_pos = "right",
  surv_name = "St." %+% estimates[[1L]][["est_name"]][1L],
  SE_name = "SE." %+% estimates[[1L]][["est_name"]][1L],
  order_legend = TRUE,
  t_int_sel = NULL,
  ymin = NULL,
  ...
)

Arguments

estimates

A list, one item per regime / intervention. Each list item must be a data.frame containing the survival estimates by time for a single regime / intervention.

CI

should a 95% confidence interval be plotted? Defaults to TRUE. Uses the standard error estimates provided as a separate column of the input data.

CI_line

When TRUE the 95% CIs will be plotted as a line function (same as main plot type). When FALSE the 95% CIs are plotted using ggplot2::geom_ribbon.

plot_cens

mark the censored observations?

surv_col

colour of the survival estimate. Defaults to black for one stratum, and to the default ggplot2 colours for multiple strata. Length of vector with colour names should be either 1 or equal to the number of strata.

cens_col

colour of the points that mark censored observations.

lty_est

linetype of the survival curve(s). Vector length should be either 1 or equal to the number of strata.

shape_est

shape type of the survival point estimates. Vector length should be either 1 or equal to the number of strata.

lty_ci

linetype of the bounds that mark the 95% CI.

size_est

line width of the survival curve

size_ci

line width of the 95% CI

size_pt

point size of the survival estimate at each time-point

cens_size

point size of the censoring points

cens_shape

shape of the points that mark censored observations.

back_white

if TRUE the background will not be the default grey of ggplot2, but will be white with borders around the plot. Defaults to TRUE

xlab

the label of the x-axis.

ylab

the label of the y-axis.

main

the plot label.

legend_pos

Either the coordinates of the legend position inside the plot (e.g., (0.9, 0.2)) or the character word denoting the legend orientation with respect to the plot (e.g., "bottom", "right" or "left").

surv_name

The name of the column containing the survival estimates.

SE_name

The name of the column containing the standard errors (SE) for each time-point estimate of survival.

order_legend

Set to TRUE to order the legend display by final survival time (highest first).

t_int_sel

The subset of time-point indices for which survival should be plotted.

ymin

The minimum value of the y axis. The default (ymin=NULL) is to use ggplot to automatically adjust the limits of the y-axis.

...

Additional arguments (not used).

Value

An object of class ggplot

Author(s)

Original R code by Edwin Thoen edwinthoen@gmail.com, modified by Oleg Sofrygin oleg.sofrygin@gmail.com


osofr/estimtr documentation built on Jan. 25, 2022, 8:05 a.m.