Kaplan-Meier + log-rank — survival analysis with censoring

Verified

Advanced & specialized

Independently verified. Every statistic this test reports has been re-derived against an independent reference — never the library the pipeline itself calls — the rendered output was read back in a browser, and the result is locked with a committed regression suite.

Run this test straight away on a free built-in teaching dataset — no data of your own needed — or bring your own. Either opens the guided workspace: variable setup, assumption diagnostics, results with effect sizes and confidence intervals, figures, and APA-ready reporting.

Loading teaching datasets…

Or use your own dataset

Loading your datasets…

Non-parametric estimation of the survival function Ŝ(t) via the product-limit estimator, with Greenwood pointwise SEs.

Compares k groups via the log-rank test (sensitive to differences in hazards across the entire follow-up period); reports an unadjusted Cox hazard ratio for the 2-group case. Handles right-censored data. Reports per-group n / events / censoring rate, median survival with 95% CI, survival at landmark times, RMST, visual proportional-hazards diagnostics, and a comparison of log-rank vs Wilcoxon-Gehan when the PH assumption is uncertain.

Worked example

Do two cancer treatments differ in patient survival over 5 years?

120 patients (60 per arm) were followed up to 60 months; time-to-death (censoring those still alive) is compared with Kaplan-Meier curves and a log-rank test.

Result

Median survival was longer on the new treatment (42 vs 24 months) and the curves separated significantly, log-rank χ²(1) = 6.0, p = .014.

How you'd report it (APA)

A Kaplan-Meier analysis showed longer median survival on the new treatment (42 vs 24 months); the log-rank test was significant, χ²(1) = 6.0, p = .014.

Try it yourself: Load this ready-made sample and follow the run above.

When to use it

  • Two-group survival comparison
    Time-to-relapse: treatment (n = 75, 42 events) vs control (n = 75, 58 events).
  • k-group survival comparison (k ≥ 2)
    Survival by stage (I/II/III/IV, n = 80 per stage).
  • Single-group survival (no comparison)
    5-year overall survival in a cancer registry cohort (n = 1200).

When NOT to — use instead

Hypotheses

H₀: S₁(t) = S₂(t) = … = S_k(t) for all t — no difference in survival across groups.
Hₐ: at least one pair of survival functions differs at some t.

Parameter tested: hazard ratio / median survival / S(t) at landmark times

Assumptions (and what to do if they fail)

Hazard rates are PROPORTIONAL across groups — the ratio of hazards is constant over time. KM curves should not cross; the −log(−log Ŝ) plot should yield approximately parallel curves.medium

Check: Do KM curves cross?

If violated: Non-proportional hazards invalidate the log-rank test's optimal power and make the Cox HR time-varying.

Censoring is not concentrated at the extremes. Heavy censoring in one group's tail invalidates long-tail comparisons.medium

Check: Per-group censoring %.

If violated: Dramatic differences in censoring rates signal informative censoring risk.

The median survival is reached in each group (at least 50% of subjects experienced the event) — if not, median is undefined.low

Check: Does Ŝ cross 0.5?

If violated: Undefined median — Ŝ never reaches 0.5.

Ready to run a Kaplan-Meier + log-rank — survival analysis with censoring on your own data?

Guided setup, automatic assumption checks, effect sizes, figures and an APA write-up.

Run this test →