Learn R Programming

survminer (version 0.3.1)

ggcoxadjustedcurves: Adjusted Survival Curves for Cox Proportional Hazards Model

Description

This function plots adjusted survival curves for coxph model. The idea behind this function is described in https://cran.r-project.org/web/packages/survival/vignettes/adjcurve.pdf. For every observation in the dataset a prediction for survival curve is made. Then the predictions are averaged with respect to a selected variable.

Usage

ggcoxadjustedcurves(fit, variable = NULL, individual.curves = FALSE,
  data = NULL, palette = "hue", curve.size = 2, curve.alpha = 0.2,
  ylab = "Survival rate", ggtheme = theme_survminer(), ...)

Arguments

fit

an object of class coxph.object - created with coxph function.

variable

a variable (vector) with values corresponding to groups to be plotted

individual.curves

if TRUE then all individual predicted survival curves will be plotted

data

a dataset for predictions. If not supplied then data will be extracted from `fit` object.

palette

the color palette to be used for coloring or filling by groups. Allowed values include "grey" for grey color palettes; brewer palettes e.g. "RdBu", "Blues", ...; or custom color palette e.g. c("blue", "red"); and scientific journal palettes from ggsci R package, e.g.: "npg", "aaas", "lancet", "jco", "ucscgb", "uchicago", "simpsons" and "rickandmorty".

curve.size, curve.alpha

size and alpha for individual survival curves

ylab

y axis label.

ggtheme

function, ggplot2 theme name. Default value is theme_classic2. Allowed values include ggplot2 official themes: see theme.

...

further arguments passed to the function ggpar for customizing the plot.

Value

Returns an object of class gg.

Examples

Run this code

library(survival)
fit2 <- coxph( Surv(stop, event) ~ rx + size, data = bladder )
ggcoxadjustedcurves(fit2, data = bladder)
ggcoxadjustedcurves(fit2, individual.curves = TRUE, data = bladder, curve.alpha=0.01)
ggcoxadjustedcurves(fit2, data = bladder, variable= bladder[,"rx"])
ggcoxadjustedcurves(fit2, data = bladder, variable= bladder[,"rx"],
   individual.curves=TRUE, curve.alpha=0.01)

Run the code above in your browser using DataLab