The product-limit (Kaplan-Meier) estimate of the CDF for a vector
of possibly right-censored event times – TDA's mple, via
Efron's redistribute-to-the-right algorithm, applied one
observation at a time in sorted order (events before censoring at
the same time). When no two events fall at exactly the same time,
this matches the standard product-limit CDF exactly – confirmed
against survival::survfit across random instances (events
may still tie with a censored observation; only ties among
events are excluded). When two or more events tie,
processing them one at a time rather than as a single simultaneous
risk-set reduction means only the last observation
processed within that tied group reaches the value standard
Kaplan-Meier software reports for that time – earlier ones in the
same group show smaller, order-dependent intermediate values.
Two events tied at time = 2 out of 3
total observations give F = (1/3, 2/3, 1) here, where
standard Kaplan-Meier reports F(2) = 2/3 for both tied
observations. This is a property of the algorithm as TDA
implements it, not a bug and not this wrapper's choice to make.
Separately: F always reaches exactly 1 at the
highest-time observation, even when that observation is
censored – redistribution only moves probability mass to later
observations, never destroys it, and the highest-time observation
has nothing later to redistribute its share to, so all of the
mass ends up accounted for there by construction. Standard
Kaplan-Meier software instead leaves the survival curve at
whatever value it last reached, undefined beyond a censored tail.
time = c(1, 2, 3),
censored = c(0, 0, 1) gives F = (1/3, 2/3, 1) here.
This is the low-level building block behind TDA's
tda_ple, which most users want instead – this one
works directly on plain vectors, with no grouping, formula
interface, or standard errors.
Usage
tda_mple(time, censored, dir = tempfile("tda"))Value
A list, both the same length as time, in the
original (unsorted) order: F, the estimated CDF at each
observation; jumps, the increase in F at each
observation (0 for a censored observation).
See also
Other matrix algebra:
tda_mcel(),
tda_mcent(),
tda_mch(),
tda_mcross(),
tda_mdiag(),
tda_mev(),
tda_mevs(),
tda_midf(),
tda_midf1(),
tda_midf2(),
tda_midf3(),
tda_minvs(),
tda_mkmet(),
tda_mkp(),
tda_mmul(),
tda_mnc(),
tda_mnrow(),
tda_mpbl(),
tda_mpfit(),
tda_mpinv(),
tda_mpit(),
tda_mpz(),
tda_mscal1(),
tda_msqrtd(),
tda_msvd(),
tda_mwvec()
Examples
# six durations, two of them censored (still running at 3 and 7)
t <- c(2, 3, 3, 5, 7, 8)
cen <- c(0, 0, 1, 0, 1, 0)
pl <- tda_mple(t, cen)
pl$F # the Kaplan-Meier distribution function at each observation
#> [1] 0.1666667 0.3333333 0.3333333 0.5555556 0.5555556 1.0000000
pl$jumps # its increase there; 0 at the censored ones
#> [1] 0.1666667 0.1666667 0.0000000 0.2222222 0.0000000 0.4444444