Kaplan-Meier + log-rank — survival analysis with censoring
VerifiedAdvanced & specialized
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.
Median survival was longer on the new treatment (42 vs 24 months) and the curves separated significantly, log-rank χ²(1) = 6.0, p = .014.
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 comparisonTime-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
- Need to control for covariates
- Multiple competing event typesKM overestimates each cause-specific cumulative incidence under competing risks. → Competing Risks \u2014 Fine-Gray + Aalen-Johansen CIF (multi-cause survival)
- Recurrent (non-terminal) eventsKM is for first-event terminal outcomes. → Cox Proportional Hazards \u2014 multivariable survival with adjusted HRs
- PH violation with crossing curvesLog-rank loses power. → RMST \u2014 Restricted Mean Survival Time (area under S(t) to \u03c4)
Hypotheses
Parameter tested: hazard ratio / median survival / S(t) at landmark times
Assumptions (and what to do if they fail)
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.
Check: Per-group censoring %.
If violated: Dramatic differences in censoring rates signal informative censoring risk.
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 →