survivalModelExtrapolations: Compare Multiple Fitted Models for Survival Extrapolation

View source: R/survivalModelExtrapolations.R

survivalModelExtrapolationsR Documentation

Compare Multiple Fitted Models for Survival Extrapolation

Description

Fits seven parametric models to an individual patient survival data set (using the flexsurv package), displays extrapolations, and report the time point at which there is the widest range in estimated extrapolated survival probabilities. This function is intended to be used only as an informal exploratory tool to support elicitation for survival extrapolation, specifically, to inform the choice of target extrapolation time. The fitted models are exponential, weibull, gamma, gompertz, log logistic, log normal and geneneralised gamma.

Usage

survivalModelExtrapolations(
  survDf,
  tOffset = 0,
  tEnd,
  group,
  tTruncate = NULL,
  dists = c("exp", "weibull", "gamma", "gompertz", "llogis", "lnorm", "gengamma"),
  nModels = length(dists),
  showPlot = TRUE
)

Arguments

survDf

data frame with individual patient data. Require to be a .csv file with three columns: "time", "event" and "treatment" (in that order). Values in the "event" column should be 0 for a censored observation, and 1 otherwise. The"treatment" column should be included even if there is only one treatment group.'

tOffset

discard observations with time less than this value, and fit survival distributions to survDf$time - tOffset.

tEnd

the maximum time point for extrapolation

group

character variable to select treatment group: one of the levels in the factor variable survDf$treatment

tTruncate

optional argument: time point at which to censor all observations

dists

character vector of distributions to fit. Default is c("exp", "weibull", "gamma", "gompertz", "llogis", "lnorm", "gengamma") corresponding to the distributions listed above; can choose a subset of this.

nModels

how many fitted models to plot, up to a maximum of 7, chosen by lowest AIC value. Default is length(dists).

showPlot

whether to display the plot

Value

A list containing the elements

KMplot

a ggplot2 plot object;

tMaxRange

the time point at which there is the greatest difference between the largest and smallest extrapolated survival probability (if more than one distribution fitted);

modelAIC

the AIC for each fitted model.

Examples

## Not run: 

# Make a data frame using the survival::veteran data frame
sdf <- survival::veteran[, c("time", "status", "trt")]
colnames(sdf) <- c("time", "event", "treatment")
sdf$treatment <- factor(sdf$treatment, labels = c("standard", "test"))

survivalModelExtrapolations(sdf, tEnd = 1000, group = "test", tTruncate = 100)

## End(Not run)

SHELF documentation built on Sept. 11, 2024, 6:54 p.m.