Kaplan-Meier estimation and plotting.

This is a convenient interface to the survfit function from the survival package that is designed to cover 99% of the typical Kaplan-Meier analyses in the pharmacometric area. The KM plot can be exported to PDF. In addition, information about median survival time is generated and shown as a table. A cox regression for the provided strata is done as well and results returned as a table.

km_IQRsurvival(
  data,
  TIMEcol,
  CENScol = NULL,
  EVENTcol = NULL,
  type = "survival",
  STRATAcat = NULL,
  STRATAcont = NULL,
  STRATAcontUnits = NULL,
  probs.cont = c(0.5),
  conf.type = "plain",
  conf.int = 0.95,
  xlab = NULL,
  ylab = NULL,
  title = NULL,
  subtitle = NULL,
  xlim = NULL,
  ylim = c(0, 1),
  xtickDelta = NULL,
  shadedCI = TRUE,
  risk.table = FALSE,
  risk.table.height = 0.25,
  legend.labs = NULL,
  plot.time0 = FALSE,
  SIGNIF = 4,
  filename = NULL
)

Arguments

data

A data frame containing the columns that are defined in the following

TIMEcol

Name of the time column in data for the analysis. Time of event or time of last visit without an event.

CENScol

Name of the censoring column in the data. Elements in this column need to be 0 or 1. 0 if an event happened in the observation period. 1 if event did not happen or subject dropped-out before event happened (right-censored). If CENScol is defined then EVENTcol is not allowed to be defined.

EVENTcol

Name of the event column in the data. Elements in this column need to be 0 or 1. 1 if an event happened in the observation period. 0 if event did not happen or subject dropped-out before event happened (right-censored). If CENScol is defined then EVENTcol is not allowed to be defined.

type

Character string defining the type of the plot "survival" and "cdf" are allowed.

STRATAcat

Single character string or vector of strings containing names of columns in data that should be used for stratification. These columns should have categorical content.

STRATAcont

Single character string or vector of strings containing names of columns in data that should be used for stratification. These columns should have continuous content. They will be converted to categorical content based on the quantiles defined in the probs.cont argument.

STRATAcontUnits

Character string of same length as STRATAcont, defining the units of each element in STRATAcont.

probs.cont

Numeric value between 0 and 1 or vector of such values. To be used for quantile calculation and binning the values in STRATAcont into their quantile numbers.

conf.type

Type of confidence interval calculation. Can be "none", "plain" or "log". Please refer to the survfit function in the survival package to learn more.

conf.int

Numeric value between 0 and 1, defining the confidence interval. If NULL or NA, then no confidence intervals will be determined and shown.

xlab

Label for the x-axis for the plots.

ylab

Label for the y-axis for the KM plot.

title

Title for the KM plot.

subtitle

Subtitle for the KM plot. Use "" for removal of subtitle

xlim

Vector with two elements. First: lower x-axis limit, Second: higher x-axis limit for the KM plot.

ylim

Vector with two elements. First: lower y-axis limit, Second: higher y-axis limit for the KM plot.

xtickDelta

Numeric value defining increments for xticks. Equidistant from 0 or min(xlim) to last datapoint of max(xlim).

shadedCI

Logical. TRUE will draw shaded areas for the CIs. FALSE will draw thiner lines as boundaries for the CIs. Use "FALSE" if submitting to the FDA.

risk.table

Logical. TRUE will add a table in the plot with numbers of subjects still at risk. FALSE will only show the KM plot.

risk.table.height

Value between 0-1 to define the relative height of the table showinf numbers of subjects at risk.

legend.labs

Vector of character strings allowing to change the legend labels.

plot.time0

Logical. TRUE will add 100 survival at time 0. Defaults to FALSE.

SIGNIF

Number of significant digits used for the median survival time table.

filename

If a filename (possibly including a path) is provided then the table and plot are exported to PNG and table text files. If no filename provided then a list containing both the plot object and the table object are returned.

Value

List with ggplot2 object for the KM plot and IQRoutputTable objects for median survival time and cox regression results