Statistics Glossary → Kaplan-Meier Survival Analysis
Kaplan-Meier Survival Analysisanalysis
A method that summarises the time until an event (death, relapse, failure, readmission) with a survival curve, properly accounting for people who have not yet had the event during follow-up, and compares the curves of groups.
Concept
With time-to-event data it is usually impossible to wait until everyone has had the event: the study ends, and some patients move to another city. For these people we only know that they stayed event-free for 'at least this long'; they are censored observations. Discarding them or averaging the times in the ordinary way biases the results. The Kaplan-Meier method uses censored observations correctly to estimate 'the probability of remaining event-free at each point in time'.
At each event time, the people still followed and still event-free (those at risk) are counted and the proportion who stay event-free is computed. The survival probability is the running product of these proportions: S(t) = Π (1 - d_i / n_i), where d_i is the number of events at that time and n_i the number at risk. A censored person counts among those at risk up to the moment of censoring and then leaves the calculation. From the resulting step curve one reads the median survival time (when the curve drops below 0.5), the survival probabilities at chosen times, and the average event-free time up to a given horizon (restricted mean survival time, RMST).
Groups are compared with the log-rank test, which compares observed and expected numbers of events at each event time and is most powerful when the hazards are proportional. The key assumption is non-informative censoring: people who leave follow-up should not have a different event risk from those who remain. Kaplan-Meier handles only one grouping variable at a time; to study several factors together, Cox regression is needed.
When to use it
- When the interest is in time to an event and some observations are censored; to describe a group's survival curve or compare the curves of several groups.
- If differences are concentrated early in follow-up, use the Breslow (generalised Wilcoxon) or Tarone-Ware test, which give more weight to early events, instead of the log-rank; if there is a possible confounder, use the stratified log-rank test.
- To estimate the effects of several factors together, use Cox regression; if there are several event types that preclude one another, competing risks analysis is preferred.
An everyday example
A hospital assigned 200 patients discharged after a heart attack to two rehabilitation programmes and followed the time to hospital readmission for one year. By the end of the year some patients had never been readmitted and some had moved to another city and left follow-up. Kaplan-Meier draws, for each programme, the curve of 'the probability of staying out of hospital over time'; for example 82% at 6 months in programme A and 70% in programme B. The log-rank test says whether the difference between the two curves can be explained by chance.
Parameters in MerQur
Event codes (optional)
Concept: The status column shows for each person whether the event occurred by the end of follow-up (event) or the person left follow-up event-free (censored). If the column is coded other than 0/1, the value that counts as an event must be stated.
Everyday example: If hospital records code '1 = still followed, no event' and '2 = readmitted', the event code is entered as 2. Patients coded 1 are then treated as censored.
What it does: If the status column is not 0/1, it specifies which values are counted as events; other filled values are censored and empty values are missing. If empty, the column must be 0/1, otherwise the analysis stops.
Effect on the result: Determines the event indicator, and therefore all estimates and tests.
On the validation data: lung (status 1 = censored, 2 = death), code "2": n = 228, 165 events, median 310 days. With the code empty, MerQur stops with the message "Event column must have 0/1 values (found: [1, 2])"; the explicit code prevents ambiguity in interpreting a 1/2-coded event column.
Confidence Level (%90 / %95 / %99 / Other, custom value 80.0 to 99.9)
Concept: Sets the confidence level of the interval estimates for survival probabilities, median time and RMST. The tests between groups are not affected by this choice.
Everyday example: If the probability of staying out of hospital at 6 months is 82% in programme A, the 95% confidence interval might be 74%-88%; choosing 99% widens the interval, but 82% does not change.
What it does: α = 1 - level. The S(t) confidence intervals, the median and quartile intervals and the RMST interval are built at this level; the tests are not affected.
Effect on the result: Only the interval limits change.
On the validation data: lung, overall: median fixed at 310; median CI: 90% [285, 353], 95% [284, 361], 99% [268, 364]. RMST fixed at 376.27; CI 95% [337.65, 414.90]. S(180) = 0.7217; CI 95% [0.6583, 0.7753], 99% [0.6364, 0.7903].
CI transformation (log-log / log / plain)
Concept: The survival probability is bounded between 0 and 1; near these bounds, the simple 'estimate ± z·SE' interval can spill past them. The log and log-log transformations build the interval on a transformed scale and convert it back, producing intervals that always stay between 0 and 1 and usually have better coverage.
Everyday example: If the probability is close to 1, such as 97%, a simple interval may give a meaningless upper limit like '92%-102%'. The log-log transformation gives the interval as, for example, 90%-99%.
What it does: The scale of the pointwise S(t) interval: log-log (default; undefined at S = 0), log (S·exp(±z·√v)), plain (S ± z·SE, clipped to [0, 1]). The median and quartile intervals are the times at which this band crosses the p level.
Effect on the result: All S(t) and quartile/median intervals change.
On the validation data: lung S(180) CI: log-log [0.6583, 0.7753], log [0.6655, 0.7825], plain [0.6632, 0.7801]. K-M BMT ALL group t = 332 (S = 0.5492): plain [0.39000, 0.70839], log-log [0.37830, 0.69110]; the same to 5 digits as Klein-Moeschberger Table 4.4.
Additional comparison tests: Breslow, Tarone-Ware
Concept: The log-rank test gives every event time equal weight. The Breslow test weights by the number at risk and the Tarone-Ware test by its square root, so they are more sensitive to differences early on, when most people are still being followed.
Everyday example: If most programme B patients are readmitted in the first two months and the two programmes run similarly afterwards, the Breslow test captures this early difference better than the log-rank.
What it does: Weights the log-rank sum by the number at risk n (Breslow, generalized Wilcoxon) or √n (Tarone-Ware); more sensitive to early differences. It works only when a group is selected.
Effect on the result: Only adds test statistics.
On the validation data: whas100/gender: log-rank 3.9714 (p = 0.0463), Breslow 3.4624 (0.0628), Tarone-Ware 3.6860 (0.0549); veteran 25.4037 / 19.4331 / 22.5728.
Pairwise group comparisons and Multiple-comparison correction (None / Bonferroni / Holm / Benjamini-Hochberg)
Concept: With three or more groups, the overall test only says 'at least one group differs'. Pairwise comparisons show which groups differ from one another; since many tests are run, the p values are adjusted with the Bonferroni, Holm or Benjamini-Hochberg method.
Everyday example: If three programmes (A, B and standard care) are compared, three pairwise tests are run. Without adjustment the chance of a 'false alarm' among them grows; the Holm adjustment limits this risk.
What it does: With 3 or more groups, a two-sample test (log-rank and the selected additional tests) for each pair of groups using only the data of those two groups; the p values are adjusted within the test family with the selected method.
Effect on the result: The pairwise p values change. When pairwise comparison is off, the choice of correction does not change the output; no pairwise comparison is produced for two-group data.
On the validation data: veteran adeno-squamous log-rank p = 0.000519; adjusted: Bonferroni 0.003115, Holm 0.002596, BH 0.001338. whas100 agecat 1-3: p = 0.030864, Holm 0.123456.
Strata (STRATA) variable
Concept: The stratified log-rank test compares the groups separately within each level of a confounding variable and combines the results. The comparison stays fair even if the groups are unbalanced on that variable.
Everyday example: If programme A happened to get more young patients, A's advantage might come from age alone. With age group given as the stratum, the programmes are compared within each age group.
What it does: Groups are compared within the strata levels; the O-E and the hypergeometric variance are summed per stratum, χ² = U'V⁻U, df = rank(V). The per-group KM curves and the unstratified log-rank do not change.
Effect on the result: Only the stratified test changes.
On the validation data: Exposed data, Treatment, stratum Sex: unstratified 5.6485, stratified 7.2466 (p = 0.0071). lung sex / ph.ecog: 10.3267, 10.7951 (n = 227).
Plot type (Survival / Cumulative incidence / Cumulative hazard / Log survival / Log-minus-log)
Concept: The same Kaplan-Meier estimate can be drawn in different forms: the probability of staying event-free, the cumulative event probability (1 - S), the cumulative hazard (-ln S) or the log-minus-log scale. Roughly parallel curves on the log-minus-log plot suggest the proportional hazards assumption is reasonable.
Everyday example: For clinicians the 'staying out of hospital' curve may be clearer, for management the 'share readmitted within a year' curve. If the two programmes' curves cross on the log-minus-log plot, the log-rank test and a Cox model should be interpreted with care.
What it does: Selects the plotted function: S, 1-S, -ln S, ln S, ln(-ln S) vs ln t. The log-minus-log plot is for visual checking of the proportional hazards assumption.
Effect on the result: It does not change the numerical results; only the plot changes. "Cumulative hazard" is -ln S.
On the validation data: The text and table do not change; the plotted values are transformations of the Kaplan-Meier estimate S.
Time points (optional)
Concept: At the chosen time points, the survival probability, its standard error, confidence interval and the number at risk are reported. As the number at risk falls, the estimate at that point becomes more uncertain.
Everyday example: Choosing months 3, 6 and 12 shows in the table the share of each programme's patients staying out of hospital at those times. If only 20 patients per group are still at risk at month 12, the confidence interval there is wide.
What it does: S(t), SE, CI and the number at risk are reported at the given times. If empty, 3/6/9/12, 12/24/36/48/60 or 12/36/60/120/180 is used automatically according to the maximum time.
Effect on the result: Only the reported times change. Times beyond the largest observed time are skipped and a warning is given.
On the validation data: lung at day 180 S = 0.7217 (SE 0.0298, at risk 160); 365: 0.4092 (0.0358, 65); 730: 0.1157 (0.0283, 13). 6-MP at 10/20/30 weeks: 0.7529 / 0.6275 / 0.4482.
Additional output: Trend test, Full survival table, Actuarial life table and Life table interval width
Concept: The trend test checks, with a single-degree-of-freedom test, whether survival rises or falls steadily across ordered groups (e.g. disease stage I-IV). The full table shows the calculation at each event time, and the actuarial life table divides time into equal intervals and summarises the numbers of events and censorings in each.
Everyday example: If patients are split into four groups by heart failure grade, the trend test answers 'does readmission come earlier as the grade rises?' more powerfully than the overall test. The life table shows month by month how many patients were readmitted and how many left follow-up.
What it does: Trend: the linear-trend log-rank in ordered groups, χ²(1) = (s'U)²/s'Vs. Full table: the number at risk, events, censored, S, Greenwood SE and CI at every event time. Life table: the Cutler-Ederer method (n' = n - c/2, q = d/n', S, f, h and Gehan SEs); if the interval width is empty, a 1/2/5 x 10^k that gives about 10 intervals is chosen.
Effect on the result: Only adds output.
On the validation data: Trend: whas100 agecat1 (46/65/75/86) χ²(1) = 12.4388 (p = 0.00042). Life table: the values of the 16 intervals are given for the Males data (w = 1) (the last interval is open).
Example on real data
Data: NCCTG lung cancer, R survival lung
Variables: time time (days), event status (2 = death), group sex
- Question: In patients with advanced lung cancer (n = 228, 165 deaths), does survival time differ between men (sex = 1) and women (sex = 2)?
- Descriptives: The overall median survival is 310 days (95% CI [284, 361]); the survival probability at day 180 is 0.7217 [0.658, 0.775]. The restricted mean survival time (RMST) is 376.27 days.
- Group results: Median survival is 270 days [210, 306] in men and 426 days [345, 524] in women; RMST is 326.08 and 455.90 days, respectively.
- Result: Log-rank χ²(1) = 10.33, p = 0.0013; the null hypothesis is rejected, the survival curves of the two sexes differ, and women live longer.
- Limitation: The log-rank test does not give the size of the difference and is most powerful under proportional hazards; Cox regression is needed for confounders such as age and performance status.
- APA: Log-rank χ²(1, N = 228) = 10.33, p = .001; median survival was 270 days in men and 426 days in women.
Related concepts
Censoring (survival analysis)Post hoc tests (pairwise comparisons)Log-rank test (and Breslow, Tarone-Ware)Kaplan-Meier estimator (survival curve)Cumulative hazard and log-minus-log plotLife table (actuarial method)Median survival time and restricted mean survival time (RMST)Survival confidence interval transformations (log-log)
The numbers in the examples are MerQur's output on independent, publicly available validation data; see the MerQur Technical Note for details.