← Back to Blog

Survival analysis · ~9 min read

Kaplan-Meier and the Log-Rank Test: A Clinician's Guide to Survival Analysis

Statistics for clinical researchers and surgical trainees

In short

Use Kaplan-Meier when your outcome is the time until an event (death, relapse, reoperation, graft failure) and some patients have not had the event by the end of follow-up. The Kaplan-Meier estimate turns those incomplete observations into an honest survival curve; the log-rank test asks whether two or more curves differ across the whole of follow-up, not at one hand-picked time point. Report median survival with the number still at risk, the log-rank P value, and, wherever possible, a hazard ratio with its confidence interval.

Time-to-event questions are everywhere in clinical research. How long until the cancer returns? How long does the prosthesis last before revision? How long before the transplanted kidney fails? Every one of these has a feature that ordinary comparisons cannot handle: when the study ends, many patients have simply not had the event yet. You know they survived at least this long, but not how much longer. Throw those patients away and you bias the result. Count them as if they had the event and you bias it the other way. Kaplan-Meier analysis exists to use exactly that partial information without distorting it.

What Kaplan-Meier actually estimates

A patient who is still event-free when follow-up ends, or who moves away, or who dies of an unrelated cause, is censored. Censoring is not missing data. It is genuine information: this person was under observation for a known length of time and had not had the event during it. In 1958, Edward Kaplan and Paul Meier showed how to fold that information into a survival estimate by recalculating the probability of surviving each moment the event actually occurs, rather than at fixed calendar intervals.1 The result is the familiar stepped curve: the y axis is the estimated proportion still event-free, the x axis is time, and each downward step marks a time at which one or more events happened.2

The reason clinicians reach for it, rather than reporting a single "percentage dead at two years", is that follow-up is almost never equal across patients. Someone enrolled in the last month of a five-year study contributes one month of information, not five years of it. A raw percentage silently treats everyone as fully followed and quietly discards the censored patients or miscounts them. Kaplan-Meier keeps each patient in the denominator for exactly as long as they were actually watched.

How to read the curve

Four things carry the meaning of a Kaplan-Meier plot, and a reviewer will look for each one.

The steps are events. A drop in the curve is one or more events at that time. Long flat stretches mean no events occurred, not that nothing happened.

The tick marks are censoring. Small vertical ticks on the curve show where patients were censored. A curve that is mostly ticks near the end is running on very few patients, and its right-hand tail should be read with caution.

Median survival is the standard summary. Read across from 0.5 on the y axis to where the curve crosses it: that time is the median survival, the point by which half the group has had the event. If the curve never falls to 0.5, the median is "not reached", which is a legitimate and common result in a group that is doing well.

The numbers at risk anchor everything. A good survival figure prints a small table beneath the x axis showing how many patients remain at risk at each time point. Precision falls away as that number shrinks, so a dramatic separation late in follow-up may rest on a handful of patients. Always report the numbers at risk; interpreting a curve without them is guesswork.2

The log-rank test compares the whole curve, not one time point

Once you have two curves, treatment and control, the question becomes whether they genuinely differ. The log-rank test is the standard answer.4 At every time an event occurs, it compares the number of events actually observed in each group against the number you would expect if the groups shared one underlying survival experience, then accumulates those differences across the entire follow-up. Its null hypothesis is that the two survival curves are the same everywhere.

This is the single most important thing to understand about survival comparisons, and the most common error in practice: the comparison depends on the whole curve, not on any isolated point.5 "Survival at 12 months was 71% versus 64%" is a description of one vertical slice. It is not a test, it discards most of the data, and two curves can cross or converge in ways that a single time point completely hides. Report the log-rank test over the whole of follow-up, and use time-point survival only as illustrative description alongside it.

To make this concrete, here is a genuine time-to-event comparison. The dataset is the classic 1963 trial of 6-mercaptopurine against placebo for maintaining remission in acute leukaemia: 42 patients, time to relapse in weeks, with patients still in remission at the end recorded as censored.3 The numbers below are computed by the StatsPlease engine (the same deterministic survival routine described in our validation page), not produced by a language model.

Computed result: Kaplan-Meier with log-rank test
GroupNRelapsesMedian remission
6-Mercaptopurine21923 weeks
Placebo21218 weeks

Log-rank χ²(1) = 16.79 · P < .001 · HR 0.21 (95% CI, 0.09 to 0.47)

Remission lasted significantly longer with 6-mercaptopurine (median 23 weeks) than with placebo (median 8 weeks); log-rank χ²(1) = 16.79, P < .001. The hazard of relapse was about one-fifth that of placebo (hazard ratio 0.21; 95% CI, 0.09 to 0.47).

Computed from the public leukaemia remission dataset. Twelve of the 21 patients on 6-mercaptopurine were still in remission when follow-up ended (censored), which is exactly the information Kaplan-Meier is built to use.

Example data: Freireich et al. (1963), the standard public teaching dataset for survival analysis, distributed with the lifelines library. Figures computed by the StatsPlease survival engine (lifelines under the hood); reproducible to the same values in SPSS or R.

The assumption that quietly decides everything: proportional hazards

The log-rank test is at its most powerful when the two groups have proportional hazards: the relative risk of the event is roughly constant over time, so one curve stays consistently below the other. When that holds, a single hazard ratio summarises the whole comparison, and the log-rank test is close to the best test available.

It often does not hold. If the curves cross, an early advantage for one arm can be cancelled by a late advantage for the other, and the log-rank test, which sums differences across time, can return a non-significant result even though the treatments clearly differ.4 Delayed effects, common with modern immunotherapies where the curves separate only after several months, cause the same loss of power. Before you lean on a log-rank P value, look at the curves: if they cross or the separation is heavily delayed, proportional hazards is suspect, and a single hazard ratio may be misleading. In that situation the restricted mean survival time, or a test designed for non-proportional hazards, is a more honest summary. The point is not that the log-rank test is wrong, but that it answers one specific question, and you should check that it is the question your curves actually pose.

How to report it in AMA format

Most clinical and surgical journals use AMA style, and statistical editors check survival reporting closely. A complete report has four parts.

  • Median survival per group with its 95% confidence interval, or "not reached" if the curve never crosses 0.5.
  • The log-rank result, written as χ2 with its degrees of freedom (one less than the number of groups) and an exact P value: log-rank χ2(1) = 16.79, P < .001. Use P < .001 only when the value really is below .001; otherwise give the exact value, P = .02.
  • A hazard ratio with its 95% confidence interval, from a Cox model, as the effect size: HR 0.21 (95% CI, 0.09 to 0.47). The log-rank test tells you whether the curves differ; the hazard ratio tells you by how much. Reviewers increasingly expect both.
  • The numbers at risk printed under the survival figure, and a clear statement of what counted as an event and what counted as censoring.

Keep the leading zero off P values (P = .02, never 0.02) but keep it on the hazard ratio and confidence limits (0.21, not .21). Italicise the statistic symbols (P, χ2). These are the exact conventions the AMA Manual of Style applies to survival results.

What to write in your methods section

One or two sentences close the door on the predictable reviewer queries. Name the estimator, the comparison test, and how censoring was defined: "Time to relapse was estimated using the Kaplan-Meier method and compared between arms with the log-rank test. Patients still in remission at the last follow-up were censored at that date. Hazard ratios with 95% confidence intervals were obtained from a Cox proportional-hazards model, and the proportional-hazards assumption was checked graphically." If you checked proportional hazards and it failed, say what you did instead. Stating the assumption and the check, rather than staying silent, is what separates a methods section that survives review from one that invites a major revision.

Common mistakes

Comparing survival at a single time point instead of testing the whole curve. Omitting the numbers at risk, so nobody can see how thin the tail is. Reporting a log-rank P value for curves that visibly cross, where proportional hazards has failed. And the quiet one: informative censoring. Kaplan-Meier assumes a censored patient carries the same future risk as one still being followed. If patients are censored because they were about to have the event (for example, taken off study at the first sign of progression), that assumption breaks and the curve flatters the treatment. If censoring is heavier in one arm, say why.

Try it yourself

Reproduce this result: in SPSS or R

The example above uses a public dataset, so you can run it in any tool and get the identical numbers. That is the whole point of a deterministic analysis: the log-rank χ2 is 16.79 whether you compute it in SPSS, R, or anywhere else.

In SPSS

  1. Enter three columns: time to relapse in weeks, a status column (1 = relapse, 0 = censored), and a treatment group column.
  2. Go to Analyze → Survival → Kaplan-Meier.
  3. Put the time column in Time, the status column in Status (click Define Event and set the value to 1), and the treatment column in Factor.
  4. Click Compare Factor and tick Log rank. Under Options, request Survival table(s) and the Mean and median survival. Click OK.
  5. Read the median survival per group and the log-rank chi-square with its P value from the output.

In R (survival package)

  1. Load the data into a data frame with columns weeks, relapse (1/0), and group.
  2. Fit the curves: fit <- survfit(Surv(weeks, relapse) ~ group, data = d).
  3. Read the medians and print the numbers at risk: summary(fit) and print(fit).
  4. Run the log-rank test: survdiff(Surv(weeks, relapse) ~ group, data = d).
  5. Get the hazard ratio: coxph(Surv(weeks, relapse) ~ group, data = d), then read exp(coef) and its confidence interval.

Compare: both should return a median of 23 weeks for 6-mercaptopurine against 8 weeks for placebo, a log-rank χ²(1) = 16.79, and P < .001. Identical numbers, because both run the same computation. Time-to-event analysis is coming to StatsPlease; when it lands, it will return these same values with the AMA sentence written for you, computed from your data, not generated.

References

  1. Kaplan EL, Meier P. Nonparametric estimation from incomplete observations. Journal of the American Statistical Association. 1958;53(282):457–481. https://doi.org/10.1080/01621459.1958.10501452
  2. Ranstam J, Cook JA. Kaplan-Meier curve. British Journal of Surgery. 2017;104(4):442. https://doi.org/10.1002/bjs.10238
  3. Freireich EJ, Gehan E, Frei E 3rd, et al. The effect of 6-mercaptopurine on the duration of steroid-induced remissions in acute leukemia. Blood. 1963;21(6):699–716. https://doi.org/10.1182/blood.V21.6.699.699
  4. Bland JM, Altman DG. The logrank test. BMJ. 2004;328(7447):1073. https://doi.org/10.1136/bmj.328.7447.1073
  5. Rich JT, Neely JG, Paniello RC, Voelker CCJ, Nussenbaum B, Wang EW. A practical guide to understanding Kaplan-Meier curves. Otolaryngology–Head and Neck Surgery. 2010;143(3):331–336. https://doi.org/10.1016/j.otohns.2010.05.007

Survival support is on the way. Your other analyses are ready now.

Time-to-event analysis is coming to StatsPlease. For the comparisons you can run today, upload your dataset and press the preset that matches your design: Group Comparison for two or more groups, Before vs After for paired measurements, or Correlation for two continuous variables. Pressing the preset runs the analysis and returns the formatted AMA result in about 60 seconds, computed from your data, not generated.

Try StatsPlease free