fastkm: fastkm

Description Usage Arguments Details Value See Also Examples

View source: R/fastkm.R

Description

Fast Kaplan-Meier estimator

Usage

1
2
fastkm(time, status, ltrunc = rep.int(0, length(time)),
  left.limit = FALSE, eval = time)

Arguments

time

vector of right-censored survival times

status

censoring indicator for each element of time (0 = right-censored, 1 = event)

ltrunc

vector of left-truncation times

left.limit

indicates wether estimated survival function is left continuous

eval

points at which the estimated survival function should be evaluated

Details

This function calculates the Kaplan-Meier estimator for right-censored survival data, at arbitrary time points. It can handle left-truncated and/or right-censored data with ties. Avoids the overhead of the survfit or prodlim functions by stripping away most of the features not needed here.

Value

A list containing the vectors time, surv and variance, and n.atrisk

See Also

survfit and prodlim

Examples

1
2
3
4
5
6
7
8
9
T <- rexp(100)
C <- rexp(100)
Y <- pmin(T, C)
D <- T <= C
sort(fastkm(Y, D)$surv, decreasing=TRUE)
# should be exactly the same as
fit <- survfit(Surv(Y, D) ~ 1)
f <- approxfun(fit$time, fit$surv, f=0, rule=2, yleft=1)
f(fit$time)

mbrueckner/AHR documentation built on Dec. 5, 2018, 4:12 p.m.