Kaplan-Meier Survival Curve and Log-Rank Test Calculator
Comparing survival times between two groups calls for neither a t-test nor a comparison of means. The reason is censoring: some subjects are still alive at the end of the study, or are lost to follow-up — you only know they survived “at least this long,” not their exact time. Treating these subjects as “dying at the last follow-up” underestimates survival; dropping them outright overestimates it. Both approaches are wrong.
The Kaplan-Meier estimator and log-rank test were designed specifically to handle censoring.
Two steps
Kaplan-Meier: S(t) = Π over each event time ti ≤ t (1 − d_i / r_i)
d_i = events at that time, r_i = number at risk at that time
log-rank: form a 2×2 table at each event time, then combine
e_j = d_j · r0_j / r_j (expected events in group 0)
v_j = r1_j · r0_j · d_j · (r_j − d_j) / [r_j² · (r_j − 1)]
χ² = [Σ(o_j − e_j)]² / Σ v_j (df = 1)
Censored subjects remain in the risk set until the moment of censoring, then exit. That is the entire key: they contribute information about surviving to that point, but nothing about what follows.
Why median survival may be undefined
Median survival is the first time point at which S(t) ≤ 0.5. If the curve remains above 0.5 at the end of follow-up, median survival is not reached: it cannot be extrapolated, nor written as “greater than X” and used as a point estimate. This tool reports “not reached” in that situation.
Verification
Using the leukemia remission data from Cox & Oakes, Analysis of Survival Data, Table 1.1 (Freireich 1963, 6-MP vs placebo, 21 subjects per group, time in weeks):
| Quantity | This tool | Reference value |
|---|---|---|
| Σ(o − e) | −10.2505 | +10.251 |
| Σ v | 6.2570 | 6.257 |
| χ²(df=1) | 16.7929 | 16.793 |
| Median survival, 6-MP | 23 | 23 |
| Median survival, placebo | 8 | 8 |
The reference values are from the University of Michigan Biostatistics lecture notes (Yi Li), which provide a complete worked derivation of this table. The tool loads this dataset by default, so you can verify immediately.
The sign reversal in Σ(o − e) is correct: the lecture notes use the placebo group as reference; this tool uses Group 1 (6-MP in the default data). The absolute value is identical. Since χ² squares the sum, the choice of reference group does not affect it.
Matching intermediate quantities is a stronger check than matching only the final statistic — two errors can cancel in the final value, but matching both Σ(o−e) and Σv confirms every step is correct.
Scope and limitations
- Log-rank answers “is there a difference between the two curves,” not “how large is the difference.” No matter how small the p-value, it is not an effect size. A hazard ratio (HR) requires Cox proportional-hazards regression, which this tool does not perform. The reason is not merely convenience: using the leukemia data above, four defensible algorithms yield four different HRs — O/E ratio 0.239, Peto one-step 0.194, Cox with Breslow tie-handling 0.221, Cox with Efron 0.208 — a range of 23%. Even “run Cox regression” is not a single, unambiguous answer: the same model, varying only how simultaneous events (ties) are handled, differs by 6%. Reporting an HR therefore requires stating the algorithm used, and an online tool that just hands you a number cannot do that — which is why this tool only performs the test and reports no effect size.
- Log-rank assumes proportional hazards: the hazard ratio between the two groups should be roughly constant throughout follow-up. If the two curves cross, log-rank will cancel out the opposing differences before and after the crossing and conclude “no difference” — when in fact the difference may be substantial, just reversed in direction. When curves cross, consider the Renyi test or restricted mean survival time (RMST) instead.
- Only two-group comparisons are supported. Multiple groups require a generalized log-rank test (df = number of groups − 1), which this tool does not implement.
- Censoring must be non-informative (independent of prognosis). If sicker subjects are more likely to be lost to follow-up, KM will systematically overestimate survival — this cannot be corrected by the method itself and must be addressed in study design.
- The χ² approximation is unreliable with few events. This tool displays a warning when the total event count is below 10.
FAQ
What do I enter in the status column — 1 or 0?
**1 means the event was observed** (death, relapse, reaching the endpoint); **0 means censored** (the event had not occurred by study end, or the subject was lost to follow-up). Reversing these completely flips the conclusion — censored observations are treated as events and the survival curve drops to zero. Many software packages mark censoring with a `+` symbol (e.g., `6+` meaning at least 6 weeks); that notation corresponds to status 0.
Why can't I just compare mean survival times between the two groups?
Because of censoring. For subjects still alive at study end, you only know they survived "at least this long." Treating that time as their actual survival time **underestimates** survival; dropping them **overestimates** it (subjects who survive longer are more likely to be censored). The Kaplan-Meier approach keeps censored subjects in the risk set until the moment of censoring, then removes them — they contribute information about surviving to that point, but nothing about what follows.
What does it mean when median survival shows "not reached"?
It means the survival curve has not dropped to 0.5 by the end of follow-up — in other words, **more than half the subjects have not yet experienced the event**. In this case median survival does not exist in the data and cannot be extrapolated. The correct way to report it is "median survival not reached," not as "> some number" used as a point estimate. You can still compare the two groups with log-rank — it uses information from all time points and does not depend on the median.
A small p-value means the effect is large, right?
No. **Log-rank answers "are the two curves different," not "how different are they."** The p-value depends on both effect size and sample size: with a large enough sample, a tiny difference can produce an extremely small p. For an effect size you need a hazard ratio (HR) from Cox proportional-hazards regression. But an HR is not a single, unambiguous number: using the default leukemia data in this tool, four defensible algorithms give four HRs — O/E ratio 0.239, Peto one-step 0.194, Cox with Breslow tie-handling 0.221, Cox with Efron 0.208, a range of 23%. **Even "run Cox regression" raises the immediate follow-up question of which tie-handling method** — that choice alone changes the answer by 6%. So this tool only performs the test and does not report HR: handing you a number without stating the algorithm is more dangerous than not providing one at all.
The two survival curves cross — can I trust the log-rank result?
**Not reliably, and the failure mode is subtle.** Log-rank sums (o − e) across all time points. Crossing curves mean the differences before and after the crossing have opposite signs and cancel out, producing a conclusion of "no difference" — when the actual difference may be large, just reversed in direction. This is log-rank's most commonly overlooked assumption (proportional hazards). When curves cross, consider the Renyi test, a weighted log-rank test, or report the difference in restricted mean survival time (RMST) instead.
Can I compare more than two groups?
This tool handles two groups only. Multiple groups require a generalized log-rank test (df = number of groups − 1), whose test statistic has a different form — it is not simply a combination of pairwise comparisons. If you want to know whether any difference exists among several groups, you need the multi-group version; for pairwise comparisons, remember to correct for multiple testing — this site has a [Benjamini-Hochberg FDR correction](../fdr-bh/) tool.
Related tools
Pharmacokinetic Non-Compartmental Analysis (NCA): AUC, Half-life, and Clearance Online Calculator
Paste concentration-time data and dose to get AUC(0→t), extrapolated AUC, λz, half-life, MRT, clearance, and Vz; defaults to linear-up/log-down.
ROC Curve & AUC Calculator with Hanley-McNeil Confidence Intervals
ROC curve, AUC (two methods cross-checked), Hanley-McNeil confidence intervals, Youden optimal threshold, and Mann-Whitney test from raw scores or a known AUC.
Diagnostic Test 2×2 Table Calculator: Sensitivity, Specificity, and Predictive Values
Enter TP/FP/FN/TN; compute sensitivity, specificity, PPV, NPV, likelihood ratios, Youden's J, and 95% Wilson CIs, with optional Bayesian prevalence updating.
Buy me a coffee