hesim (version 0.5.4)

surv_quantile: Survival quantiles

Description

Compute quantiles from survival curves.

Usage

surv_quantile(x, probs = 0.5, t, surv_cols, by)

Value

A data.table of quantiles of each survival curve in surv_cols by each group in by.

Arguments

x

A data.table or data.frame.

probs

A numeric vector of probabilities with values in [0,1].

t

A character scalar of the name of the time column.

surv_cols

A character vector of the names of columns containing survival curves.

by

A character vector of the names of columns to group by.

Examples

Run this code
library("data.table")
t <- seq(0, 10, by = .01)
surv1 <- seq(1, .3, length.out = length(t))
surv2 <- seq(1, .2, length.out = length(t))
strategies <- c("Strategy 1", "Strategy 2")
surv <- data.table(strategy = rep(strategies, each = length(t)),
                   t = rep(t, 2), 
                   surv = c(surv1, surv2))
surv_quantile(surv, probs = c(.4, .5), t = "t",
              surv_cols = "surv", by = "strategy")

Run the code above in your browser using DataCamp Workspace