Algorithmcore
Kaplan-Meier estimator
Also called product-limit estimator.
Estimates the survival function under right censoring as the product over event times of one minus the deaths over the number at risk. It is the nonparametric MLE.
- Time
- Θ(n log n) worst
- Space
- Θ(n) extra
- Where
- k = the number of distinct event times; n = the number of subjects
- Model
- Real RAM
- Properties
- deterministicexactofflineiterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Edward L. Kaplan, Paul Meier, 1958
The Kaplan-Meier estimator estimates the survival function from data in which some event times are right censored: for those subjects we know only that the event had not happened by the time follow-up stopped. At each distinct event time it counts the subjects still at risk and the events, estimates the conditional probability of getting past as , and multiplies these factors:
A censored subject counts in every risk set up to its censoring time and then leaves without causing a step. With no censoring, is one minus the empirical distribution function. Under independent censoring is the nonparametric maximum likelihood estimate of , and the computation is one sort and one pass.
In plain words
Patients enter a study and are followed until they die or until the study stops watching them. For a patient who left the study alive after 10 weeks, we do not know the death time, only that it is later than 10 weeks. To estimate the chance of surviving past 20 weeks, go through time in order. Each time someone dies, look at the people who were still being followed just before, and note the fraction who survived that moment. Multiply these fractions together. A person who left early helps in every fraction up to the time they left, and then drops out of the count. Throwing that person away, or counting them as dead, would both make survival look worse than it is.
The problem
Input. Observations for , where is the observed time, the event time, the censoring time, and if (an event) and otherwise (censored).
Model. The pairs are independent across , the have survival function , and censoring is independent: given that a subject is still at risk at time , the chance of an event at does not depend on the censoring. No form of is assumed. The censoring page states these conditions in full.
Output. The distinct event times , with at risk and events at each, and the values . The estimate is the right-continuous step function that equals before and on .
Ties. A censoring time equal to an event time counts as later: the censored subject is in the risk set . This is the convention of Kaplan and Meier, and it matches the usual reading that a subject censored at was seen alive at .
The algorithm
KAPLAN-MEIER(y[1..n], δ[1..n])- 1
sort the indices 1..n by y - 2
r ← n; S ← 1; out ← empty list - 3
i ← 1 - 4
while i ≤ n - 5
t ← y of the i-th sorted index; d ← 0; c ← 0 - 6
while i ≤ n and y of the i-th sorted index = t: add 1 to d if δ = 1, else to c; i ← i + 1 - 7
if d > 0 then S ← S · (1 - d/r); append (t, r, d, S) to out - 8
r ← r - d - c ▷ the d + c subjects leave the risk set after t - 9
return out
Line L1 sorts the times. The variable is the size of the current risk set; it starts at and line L8 removes each group of tied subjects after their time is processed, so censored subjects at are still counted at . Line L7 makes a step only at event times. The code returns the list of steps together with the largest observed time , and evaluates by a scan or a binary search over the steps.
If the largest observation is censored, does not reach , and the data say nothing about beyond : the code raises an error for in that case. If the largest observation is an event, drops to there.
Example
The 6-MP arm of the leukemia trial of Freireich et al. (1963), as listed by Gehan (1965), has 21 remission times in weeks, with marking a censored time:
6, 6, 6, 6+, 7, 9+, 10, 10+, 11+, 13, 16, 17+, 19+, 20+, 22, 23, 25+, 32+, 32+, 34+, 35+.
The pass of lines L4 to L8 visits 16 distinct times. The rows with form the output:
| at | factor | decimal | ||||
|---|---|---|---|---|---|---|
| 6 | 21 | 3 | 1 | 18/21 | 6/7 | 0.8571 |
| 7 | 17 | 1 | 0 | 16/17 | 96/119 | 0.8067 |
| 9 | 16 | 0 | 1 | none | 96/119 | 0.8067 |
| 10 | 15 | 1 | 1 | 14/15 | 64/85 | 0.7529 |
| 11 | 13 | 0 | 1 | none | 64/85 | 0.7529 |
| 13 | 12 | 1 | 0 | 11/12 | 176/255 | 0.6902 |
| 16 | 11 | 1 | 0 | 10/11 | 32/51 | 0.6275 |
| 17, 19, 20 | 10, 9, 8 | 0 | 1 each | none | 32/51 | 0.6275 |
| 22 | 7 | 1 | 0 | 6/7 | 64/119 | 0.5378 |
| 23 | 6 | 1 | 0 | 5/6 | 160/357 | 0.4482 |
| 25, 32, 34, 35 | 5, 4, 2, 1 | 0 | 1, 2, 1, 1 | none | 160/357 | 0.4482 |
At the censored subject is in the risk set of 21, and only after the step does fall by to 17. The estimated median remission time, the first with , is 23 weeks. The last observation, 35, is censored, so stays at up to 35 and is undefined after it. The Greenwood formula gives standard errors 0.0764 at and 0.1346 at .
The two wrong ways to treat the censored times give quite different answers. If the 12 censored times are dropped, the 9 events alone have empirical median 10 weeks. If they are counted as events, the median is 16 weeks and the estimate at 23 weeks is instead of . Both are biased downward, because both lose the information that the censored patients were still in remission.
The placebo arm of the same trial has no censoring (1, 1, 2, 2, 3, 4, 4, 5, 5, 8, 8, 8, 8, 11, 11, 12, 12, 15, 17, 22, 23). Its Kaplan-Meier estimate is the empirical survival function : after week 1, after week 3, after week 8, and median 8 weeks. The log-rank test compares the two arms.
Correctness
The proof in proofs/correctness.md shows three things. First, the pass of lines L4 to L8 keeps the invariant that equals the number of subjects with when the group at time starts, so every output row is . Second, under a likelihood that does not involve the censoring distribution, the product-limit estimate maximizes the likelihood over all distributions on , and it is the unique maximizer on . Third, it equals Efron's redistribute-to-the-right estimate, in which each censored subject passes its probability mass in equal shares to every subject later in time.
Proof: The pass computes the product-limit estimate, which is the nonparametric MLE and equals Efron's redistribute-to-the-right estimatefull
Let the data be for , with distinct event times (the distinct with ), and . The product-limit estimate is .
Claim 1 (the pass computes the product-limit estimate). Every row that line L7 appends is for some , and each gives one row, in increasing order of .
Proof. After line L1 the indices are in increasing order of . The inner loop of line L6 reads exactly the indices whose time equals , so the outer loop visits each distinct observed time once, in order, and at time it sets and to the numbers of events and censorings at .
Invariant: when the outer loop starts the group at time , and . At the first group, and , and both sides are right because no is below the smallest time and the product is empty. Suppose the invariant holds at . If is an event time, line L7 sets to ; otherwise is unchanged and . Line L8 subtracts the subjects with , so becomes for the next distinct time , and because no event time lies in . So the invariant holds at . At an event time the row appended has , and .
Claim 2 (maximum likelihood). Let be the set of probability distributions on , where mass at means that the event never happens. For write and , and define
Assume at least one event. Then attains its maximum over , and is a maximizer if and only if for all , the largest observed time.
This is the likelihood of the data as a function of when censoring is independent and noninformative: the full likelihood is times a factor that depends only on the censoring distribution (censoring derives this factorization). So the claim says that the product-limit estimate is the nonparametric maximum likelihood estimate.
Proof. Put and . Take with ; such an exists (put mass at each and at ). Then for every .
Step 1: the mass sits at the event times and beyond . Define by moving the mass of in each open interval , for , to the point , and the mass in to . Masses at the only grow, so for every event. For a censored , every moved point goes to the right, so mass that was above stays above , and . Hence . The inequality is strict if has mass in some with , because then and ; it is also strict if has mass in , because the subject with is then censored (an event at would make ) and .
Step 2: maximize over distributions on . Write such a distribution through its discrete hazards , which give and . Every vector comes from exactly one such distribution, with the remaining mass at , and every such distribution has a vector (if , set ; then anyway). Substitute: the event of subject at contributes , and a censored subject with contributes . Collect the factors. appears once for each event at , so times. appears once for each event at a time and once for each censored subject with , that is, once for each subject with except the events at . That count is . So
The factors depend on separate variables. For and , the function on has the unique maximizer : its logarithm is strictly concave on with derivative , which vanishes only at (if , the function is increasing and the maximizer is ). So the unique maximizer has , and its survival function is .
Combining the steps: every has , where is the distribution of Step 2. Equality throughout forces to have no mass in any or in (Step 1) and to have the hazards at the (Step 2), which together fix on to be . Beyond , when the largest observation is censored, does not depend on where the mass lies, so is not identified there.
Claim 3 (redistribute to the right). Order the subjects by time, with events before censorings at equal times, as positions . Give each subject mass . Go through the positions in order; at a censored subject at position , split its current mass equally among the subjects at positions and set its own mass to . Let . Then for every .
Proof. Event subjects never pass mass on, and redistribution keeps the total mass equal to . Call the subjects at positions the tail at .
Invariant: when the pass reaches position , all subjects in the tail at hold the same mass , and the tail holds total mass . At this holds with . If position is an event, nothing moves, and the tail at still has equal masses and total . If position is censored and , it gives to each of the later subjects, which all held ; they now hold each, equal again, and their total is , the old total of the tail at . Censored subjects keep no mass, so the second part also holds.
Now take an event time and let be the first position with . By the ordering, the tail at is exactly the subjects with , and its first positions are the events at . By the invariant the subjects hold equal mass and total . The events at come next, so nothing changes their mass before they are passed, and they keep each to the end. So
Since is constant between event times and , induction on gives .
Cost. Line L1 sorts keys in comparisons. Each iteration of the inner loop of line L6 advances , so lines L4 to L8 run inner steps and at most outer steps, each with arithmetic. The total is in the worst case.
Complexity
The sort in line L1 costs comparisons in the worst case. The pass of lines L4 to L8 visits each subject once and does arithmetic per subject and per distinct time, so it costs . The output has rows. The total is time and extra space in the real RAM model. If the data arrive sorted, the cost is . After the pass, a value costs by a binary search over the step times.
With exact rational arithmetic the numbers grow: the denominator of divides , so the bit size of can grow linearly in . In floating point the product of factors in has a relative error of at most about units in the last place (one rounding each for , the subtraction and the product), and no cancellation grows the error. For very long products the sum of , computed with log1p, avoids underflow.
Properties
- No censoring. If every , then , the product telescopes, and , one minus the empirical distribution function.
- Self-consistency. For , . Each censored subject contributes its conditional probability of being still alive at , estimated by itself (Efron 1967). The Turnbull estimator solves the same kind of equation for interval-censored data.
- Nonparametric MLE. It maximizes the likelihood over all distributions, as proved in the correctness file.
- Consistency and limit law. If , then almost surely, and converges on to a Gaussian process with variance for continuous , where is the censoring survival function (Breslow and Crowley 1974; Andersen et al. 1993, Chapter IV). The Greenwood formula estimates this variance.
- Relation to Nelson-Aalen. , where is the Nelson-Aalen estimator, because for every factor. The two agree closely when every is small.
Variants and improvements
- Delayed entry (left truncation). If subject enters observation at time , the risk set at is . The same product with these estimates for . Small risk sets early in time can make this estimate unstable.
- Life-table (actuarial) estimate. For grouped data in intervals, use as the effective number at risk, on the reading that censored subjects were at risk for half the interval.
- Survival from the cumulative hazard. , with the Nelson-Aalen estimate, is an alternative estimate of . It never reaches .
- Interval censoring. When event times are known only to lie in intervals, the nonparametric MLE is the Turnbull estimator, which reduces to Kaplan-Meier for exact and right-censored data.
- Competing risks. With several causes of failure, computed with the other causes treated as censoring overestimates the cumulative incidence of one cause. The Aalen-Johansen estimator gives the correct estimate; see competing risks.
- Covariates. The Cox model with the Breslow estimator gives a survival curve for each covariate value. Without covariates it reduces to .
- Dependent censoring. If censoring depends on measured covariates, inverse probability of censoring weights, in the style of inverse probability weighting, restore consistency.
When to use it
Use Kaplan-Meier to describe the survival of one group with right-censored data, to read off the median survival time or the survival probability at a fixed time, and as the first plot of any survival analysis. Report the number at risk under the plot, because the right end of the curve rests on few subjects. To compare groups, use the log-rank test, not the visual gap between curves. For pointwise confidence intervals use the Greenwood formula, preferably on the log-log scale.
Pitfalls
- Dropping censored subjects, or treating them as events. Both bias downward, as the 6-MP example shows: medians of 10 and 16 weeks against 23.
- Ties between events and censorings. Count a censoring at in the risk set at . Removing it first changes the factor at .
- The tail. After the largest time, if it is censored, the estimate is undefined. The mean survival time is then undefined too; report the restricted mean with a stated .
- Informative censoring. If sicker patients leave the study earlier, is biased upward, and the data cannot reveal this (Tsiatis 1975): the bias is not testable from alone.
- Competing risks. Treating death from other causes as censoring and reporting as the risk of one cause overestimates that risk.
- Large steps at the end. When few subjects remain at risk, each event causes a large drop. Do not read the shape of the curve where is small.
- Median. If never falls to , the median is not estimable, and the code returns no value. Do not replace it with the last time.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/kaplan-meier-estimator/. The authors are listed in prov/FNVF5H.jsonl.
from collections.abc import Sequence
from fractions import Fraction
from typing import NamedTuple
class Step(NamedTuple):
"""One distinct event time t_j of the Kaplan-Meier table."""
time: float
at_risk: int # n_j, the number with y_i >= t_j
events: int # d_j, the number of events at t_j
survival: float # S-hat(t_j), a Fraction when exact=True
class KaplanMeier:
"""The Kaplan-Meier estimate S-hat as a right-continuous step function.
steps holds one row per distinct event time. t_max is the largest observed
time. S-hat(t) is defined for t <= t_max, and also for t > t_max when the
largest time is an event or S-hat has reached 0; otherwise S-hat is
undefined beyond t_max and __call__ raises ValueError there.
"""
def __init__(self, steps: list[Step], t_max: float, last_is_event: bool, one) -> None:
self.steps = steps
self.t_max = t_max
self.last_is_event = last_is_event
self._one = one
def __call__(self, t: float):
s = self._one
for step in self.steps:
if step.time > t:
break
s = step.survival
if t > self.t_max and not self.last_is_event and s != 0:
raise ValueError("S-hat is undefined after the largest time when that time is censored")
return s
def median(self):
"""The smallest event time t with S-hat(t) <= 1/2, or None if S-hat stays above 1/2."""
for step in self.steps:
if step.survival <= self._one / 2:
return step.time
return None
def kaplan_meier(times: Sequence[float], events: Sequence[int], exact: bool = False) -> KaplanMeier:
"""Kaplan-Meier estimate from right-censored data.
times[i] is the observed time y_i = min(T_i, C_i) and events[i] is 1 when
y_i is an event time and 0 when it is a censoring time. A censoring tied
with an event counts as at risk at that time. With exact=True the survival
values are Fractions. Cost: one sort, O(n log n), and one O(n) scan.
"""
n = len(times)
if n == 0 or len(events) != n:
raise ValueError("need the same positive number of times and event flags")
if any(e not in (0, 1) for e in events):
raise ValueError("event flags must be 0 or 1")
one = Fraction(1) if exact else 1.0
order = sorted(range(n), key=lambda k: times[k]) # @line L1
r, s, out = n, one, [] # @line L2
i = 0 # @line L3
while i < n: # @line L4
t, d, c = times[order[i]], 0, 0 # @line L5
while i < n and times[order[i]] == t: # @line L6
if events[order[i]]:
d += 1
else:
c += 1
i += 1
if d > 0: # @line L7
s = s * (one - Fraction(d, r)) if exact else s * (1.0 - d / r)
out.append(Step(t, r, d, s))
r -= d + c # @line L8
last = times[order[-1]]
last_is_event = any(times[k] == last and events[k] for k in range(n))
return KaplanMeier(out, last, last_is_event, one) # @line L9
def greenwood_variance(km: KaplanMeier, t: float):
"""Greenwood's estimate S-hat(t)^2 * sum over t_j <= t of d_j / (n_j (n_j - d_j)).
A term with d_j = n_j makes S-hat(t) = 0, and the estimate is then 0.
"""
s = km(t)
if s == 0:
return s
total = 0 * s
for step in km.steps:
if step.time > t:
break
n, d = step.at_risk, step.events
total += Fraction(d, n * (n - d)) if isinstance(s, Fraction) else d / (n * (n - d))
return s * s * total
test_kaplan_meier_estimator.py 212 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/kaplan-meier-estimator/. The authors are listed in prov/FNVF5H.jsonl.
import math
import random
from fractions import Fraction
import pytest
from kaplan_meier_estimator import greenwood_variance, kaplan_meier
# 6-MP arm of Freireich et al. (1963), as listed by Gehan (1965). 0 marks a censored time.
MP_T = [6, 6, 6, 6, 7, 9, 10, 10, 11, 13, 16, 17, 19, 20, 22, 23, 25, 32, 32, 34, 35]
MP_D = [1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0]
PL_T = [1, 1, 2, 2, 3, 4, 4, 5, 5, 8, 8, 8, 8, 11, 11, 12, 12, 15, 17, 22, 23]
def product_limit(times, events, t):
"""The product-limit formula written out: product over event times s <= t of (1 - d(s)/n(s))."""
s = Fraction(1)
for u in sorted({y for y, e in zip(times, events) if e}):
if u > t:
break
n = sum(1 for y in times if y >= u)
d = sum(1 for y, e in zip(times, events) if y == u and e)
s *= Fraction(n - d, n)
return s
def redistribute_to_the_right(times, events):
"""Efron's construction: start with mass 1/n on each subject, ordered by time with
events before censorings at equal times; each censored subject, in turn, gives its
mass in equal parts to every subject after it. Returns 1 - (event mass up to t) as a function."""
n = len(times)
order = sorted(range(n), key=lambda k: (times[k], -events[k]))
mass = [Fraction(1, n)] * n
for pos, k in enumerate(order):
if not events[k] and pos < n - 1:
share = mass[pos] / (n - 1 - pos)
for later in range(pos + 1, n):
mass[later] += share
mass[pos] = Fraction(0)
def surv(t):
return 1 - sum((mass[p] for p, k in enumerate(order) if events[k] and times[k] <= t), Fraction(0))
return surv
def random_data(rng, n, tmax, pcens):
times = [rng.randint(1, tmax) for _ in range(n)]
events = [0 if rng.random() < pcens else 1 for _ in range(n)]
return times, events
def test_six_mp_table() -> None:
km = kaplan_meier(MP_T, MP_D, exact=True)
rows = [(s.time, s.at_risk, s.events, s.survival) for s in km.steps]
assert rows == [
(6, 21, 3, Fraction(6, 7)),
(7, 17, 1, Fraction(96, 119)),
(10, 15, 1, Fraction(64, 85)),
(13, 12, 1, Fraction(176, 255)),
(16, 11, 1, Fraction(32, 51)),
(22, 7, 1, Fraction(64, 119)),
(23, 6, 1, Fraction(160, 357)),
]
assert km(5) == 1 and km(9) == Fraction(96, 119) and km(34) == Fraction(160, 357)
assert km.median() == 23
assert math.isclose(math.sqrt(greenwood_variance(km, 23)), 0.13459, abs_tol=5e-5)
assert math.isclose(math.sqrt(greenwood_variance(km, 6)), 0.07636, abs_tol=5e-5)
# The largest time, 35, is censored, so S-hat is undefined after 35.
assert km(35) == Fraction(160, 357)
with pytest.raises(ValueError):
km(35.5)
def test_placebo_arm_is_the_empirical_survival_function() -> None:
km = kaplan_meier(PL_T, [1] * len(PL_T), exact=True)
assert [s.survival for s in km.steps] == [Fraction(k, 21) for k in (19, 17, 16, 14, 12, 8, 6, 4, 3, 2, 1, 0)]
assert km.median() == 8
assert km(100) == 0
def test_against_product_limit_formula() -> None:
rng = random.Random(20261114)
for _ in range(300):
n = rng.randint(1, 25)
times, events = random_data(rng, n, rng.randint(1, 12), rng.random())
km = kaplan_meier(times, events, exact=True)
t_max = max(times)
for t in range(0, t_max + 2):
try:
got = km(t)
except ValueError:
assert t > t_max and not any(e for y, e in zip(times, events) if y == t_max)
continue
assert got == product_limit(times, events, t)
def test_no_censoring_gives_empirical_survival() -> None:
rng = random.Random(7)
for _ in range(200):
n = rng.randint(1, 30)
times = [rng.randint(1, 10) for _ in range(n)]
km = kaplan_meier(times, [1] * n, exact=True)
for t in range(0, 12):
assert km(t) == Fraction(sum(1 for y in times if y > t), n)
def test_equals_redistribute_to_the_right() -> None:
rng = random.Random(1967)
for _ in range(300):
n = rng.randint(1, 20)
times, events = random_data(rng, n, rng.randint(1, 8), rng.random())
km = kaplan_meier(times, events, exact=True)
rtr = redistribute_to_the_right(times, events)
for step in km.steps:
assert step.survival == rtr(step.time)
def test_self_consistency_equation() -> None:
# Efron (1967): S(t) = (1/n) [#{y_i > t} + sum over censored y_i <= t of S(t) / S(y_i)].
rng = random.Random(831)
for _ in range(200):
n = rng.randint(1, 20)
times, events = random_data(rng, n, 9, rng.random())
km = kaplan_meier(times, events, exact=True)
for t in range(0, max(times) + 1):
s = km(t)
rhs = sum(1 for y in times if y > t) + sum(
(s / km(y) for y, e in zip(times, events) if not e and y <= t and km(y) > 0), Fraction(0)
)
assert s == rhs / n
def test_float_and_exact_agree() -> None:
rng = random.Random(3)
for _ in range(100):
times, events = random_data(rng, 40, 15, 0.4)
a = kaplan_meier(times, events)
b = kaplan_meier(times, events, exact=True)
for x, y in zip(a.steps, b.steps):
assert x[:3] == y[:3] and math.isclose(x.survival, float(y.survival), rel_tol=1e-12, abs_tol=1e-15)
def log_lik(times, events, support, probs, tail):
"""Log-likelihood of a distribution with mass probs[j] at support[j] and mass tail after support[-1]."""
total = 0.0
for y, e in zip(times, events):
if e:
p = probs[support.index(y)]
else:
p = sum(q for s, q in zip(support, probs) if s > y) + tail
if p <= 0:
return -math.inf
total += math.log(p)
return total
def test_kaplan_meier_maximizes_the_likelihood() -> None:
rng = random.Random(1958)
for _ in range(60):
times, events = random_data(rng, 15, 10, 0.4)
if not any(events):
continue
km = kaplan_meier(times, events)
support = [s.time for s in km.steps]
prev, probs = 1.0, []
for s in km.steps:
probs.append(prev - s.survival)
prev = s.survival
best = log_lik(times, events, support, probs, prev)
for _ in range(200):
w = [rng.expovariate(1.0) for _ in range(len(support) + 1)]
z = sum(w)
alt = log_lik(times, events, support, [x / z for x in w[:-1]], w[-1] / z)
assert alt <= best + 1e-9
def test_greenwood_without_censoring_is_binomial_variance() -> None:
rng = random.Random(1926)
for _ in range(200):
n = rng.randint(2, 30)
times = [rng.randint(1, 10) for _ in range(n)]
km = kaplan_meier(times, [1] * n, exact=True)
for t in range(0, 11):
s = km(t)
assert greenwood_variance(km, t) == s * (1 - s) / n
def test_last_time_rules_and_median() -> None:
km = kaplan_meier([1, 2, 3], [1, 0, 1], exact=True)
assert km(3) == 0 and km(10) == 0
km = kaplan_meier([1, 2, 3], [1, 1, 0], exact=True)
assert km(2) == Fraction(1, 3) and km(3) == Fraction(1, 3)
with pytest.raises(ValueError):
km(4)
assert km.median() == 2
assert kaplan_meier([5, 6], [0, 0]).median() is None
# A censoring tied with an event stays in the risk set at that time.
km = kaplan_meier([2, 2, 4], [1, 0, 1], exact=True)
assert km.steps[0].at_risk == 3 and km(2) == Fraction(2, 3)
def test_rejects_bad_input() -> None:
with pytest.raises(ValueError):
kaplan_meier([], [])
with pytest.raises(ValueError):
kaplan_meier([1, 2], [1])
with pytest.raises(ValueError):
kaplan_meier([1, 2], [1, 2])
History
Edward Kaplan and Paul Meier each wrote a paper on the estimation of survival from incomplete observations, and they published them as one joint paper in the Journal of the American Statistical Association in 1958. The paper gives the product-limit estimate, shows that it is the maximum likelihood estimate among all distributions, and derives its variance by the same argument as Greenwood (1926). Actuaries had long used products of conditional survival probabilities in life tables. Efron (1967) gave the redistribute-to-the-right description and the self-consistency equation while studying two-sample tests with censored data. Breslow and Crowley (1974) proved the weak convergence of , and the counting process approach of Aalen and of Gill in the late 1970s and early 1980s gave the martingale proofs collected by Andersen, Borgan, Gill and Keiding (1993).
References
- E. L. Kaplan and Paul Meier, Nonparametric estimation from incomplete observations, Journal of the American Statistical Association 53(282), 1958, pp. 457 to 481 (the product-limit estimate, its derivation as a maximum likelihood estimate, and its variance)
- Bradley Efron, The two sample problem with censored data, Proceedings of the Fifth Berkeley Symposium on Mathematical Statistics and Probability, Vol. 4, University of California Press, 1967, pp. 831 to 853 (the redistribute-to-the-right construction and self-consistency on pp. 842 and 843)
- John P. Klein and Melvin L. Moeschberger, Survival Analysis, Techniques for Censored and Truncated Data, 2nd edition, Springer, 2003, Chapter 4 (nonparametric estimation of basic quantities for right-censored and left-truncated data)
- Per Kragh Andersen, Ørnulf Borgan, Richard D. Gill and Niels Keiding, Statistical Models Based on Counting Processes, Springer, 1993, Chapter IV (nonparametric estimation, including the product-limit estimator, its consistency and its weak convergence)
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag FNVF5H Edit this page History Report an error Markdown