Learn R Programming

AHR (version 1.5.0)

fastkm: fastkm

Description

Fast Kaplan-Meier estimator

Usage

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

Value

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

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.

See Also

survfit and prodlim

Examples

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataLab