surv_dist: Survival distributions

surv_distR Documentation

Survival distributions

Description

Solve for the time or proportion event-free assuming exponential survival.

Usage

surv_dist(p1, time1, p2 = NULL, time2 = NULL)

Arguments

p1, p2

proportion of patients who are event-free for the known and unknown rates, respectively

time1, time2

times corresponding to p1 and p2, respectively; note that exactly one of p2 and time2 should be null

Examples

time <- seq(0, 5, 0.01)
cumhaz <- cumsum(rep(exp(0.2), length(time)) * 0.01)
surv <- exp(-cumhaz)

set.seed(1)
n <- runif(100)
failtimes <- time[colSums(outer(surv, n, `>`))]

library('survival')
sf <- survfit(Surv(failtimes) ~ 1)
op <- par(mfrow = c(1, 2))
plot(time, surv, type = 'l', xlab = 'Time', ylab = 'Survival')
plot(sf)
par(op)

surv_extract(sf)

## given median survival of 0.58 time units, what proportions are
## event-free at times
times <- c(0.4, 0.6, 0.8)
p <- surv_dist(0.5, 0.58, time2 = times)
round(p, 3)

summary(sf, times = times)

## similarly, given median survival of 0.58 time units, when are the
## proportions of 0.609, 0.478, and 0.374 event-free
surv_dist(0.5, 0.58, round(p, 3))


raredd/rawr documentation built on April 29, 2024, 10:29 a.m.