Kaplan-Meier survival curve
Plot Kaplan-Meier survival curves from times and event codes, with Greenwood intervals, median survival and a log-rank test between groups.
A clear answer. Here’s how.
Sorts each group’s times and applies the product-limit rule: at every time with d events among the n subjects still at risk, S(t) is multiplied by (n − d) ÷ n; subjects censored at that time count as at risk for it, then leave. Greenwood’s formula gives Var(log S) ≈ Σ d ÷ (n(n − d)), and the standard error shown is S × its square root. Pointwise intervals are log-log, S^exp(±z·σ ÷ log S) (SAS’s default; it stays inside 0–1), log, S·exp(±z·σ) capped at 1 (R’s default), or plain, S ± z·SE clipped to 0–1; σ is the Greenwood square root, and limits are left blank where they are undefined (S = 1 for log-log, S = 0). The median is the first event time with S(t) at or below 0.5, or the midpoint of an interval where S is exactly 0.5; its interval runs from where the lower limit first reaches 0.5 to where the upper limit does, as R’s survfit reports it, and a limit that is never reached is shown as not reached. The restricted mean is the area under the curve up to the chosen time, with the curve held at its last value if follow-up ends earlier, and a Greenwood-type standard error. The log-rank (Mantel–Cox) test compares observed with expected events at every event time, using the full covariance matrix, so χ² has groups − 1 degrees of freedom. Survival beyond the last follow-up is not extrapolated. It assumes censoring unrelated to the outcome and does not fit Cox models, competing risks, weighted log-rank tests or delayed entry. It is a calculator, not a substitute for a statistician when decisions depend on the answer.
How this is checked
5 reference checks passed These 5 cases were run when this page was built, on 20 October 2026, and all reproduce within the stated tolerance. The same cases are part of the automated tests that run on every change to Toolmoz. Engine version 1.
See the checks and where each expected answer comes from
Case 1
- Inputs
- The tool’s default inputs
- Expected, and what Toolmoz gave
- Log-rank chi-square expected 16.792940989216532, Toolmoz 16.792940989216536Observed events (6-MP) expected 9, Toolmoz 9Expected events (6-MP) expected 19.25050094803113, Toolmoz 19.25050094803113Median survival (6-MP) expected 23, Toolmoz 23Median survival (Placebo) expected 8, Toolmoz 8Survival at time 12 (6-MP) expected 0.7529411764705882, Toolmoz 0.7529411764705881Survival at time 12 (Placebo) expected 0.19047619047619047, Toolmoz 0.19047619047619047
- Where the expected answer comes from
- Freireich 6-MP leukaemia trial (Gehan 1965): textbook S(10) = 0.753 for 6-MP and median remissions of 23 and 8 weeks; R’s survdiff gives χ² = 16.8 on 1 df. Full-precision values from an independent Python fractions script: E(6-MP) = 19.2505, variance 6.25696, χ² = (9 − 19.2505)² ÷ 6.25696
- Allowed difference
- ±1e-9 relative
Case 2
- Inputs
- Time, event and group, one subject per line 6,1 6,1 6,1 6,0 7,1 9,0 10,1 10,0 11,0 13,1 16,1 17,0 19,0 20,0 22,1 23,1 25,0 32,0 32,0 34,0 35,0Also report survival at this time (0 for none) 13
- Expected, and what Toolmoz gave
- Survival at time 13 expected 0.6901960784313725, Toolmoz 0.690196078431372495% CI lower limit, survival at time 13 expected 0.431610222486184, Toolmoz 0.43161022248618695% CI upper limit, survival at time 13 expected 0.8490659633494508, Toolmoz 0.84906596334945Median survival expected 23, Toolmoz 2395% CI for the median, lower limit expected 13, Toolmoz 1395% CI for the median, upper limit expected Not reached, Toolmoz Not reached
- Where the expected answer comes from
- Textbook 6-MP values S(6) = 0.857, S(7) = 0.807, S(10) = 0.753, S(13) = 0.690 = (18/21)(16/17)(14/15)(11/12) = 176/255; the log-log limits S^exp(±1.96 σ ÷ log S) with Greenwood σ² = 3/(21×18) + 1/(17×16) + 1/(15×14) + 1/(12×11), evaluated in an independent Python script
- Allowed difference
- ±1e-12
Case 3
- Inputs
- Time, event and group, one subject per line 6,1 6,1 6,1 6,0 7,1 9,0 10,1 10,0 11,0 13,1 16,1 17,0 19,0 20,0 22,1 23,1 25,0 32,0 32,0 34,0 35,0Also report survival at this time (0 for none) 23Interval for S(t) log
- Expected, and what Toolmoz gave
- Survival at time 23 expected 0.4481792717086835, Toolmoz 0.448179271708683495% CI lower limit, survival at time 23 expected 0.2487882268176597, Toolmoz 0.2487882268176606395% CI upper limit, survival at time 23 expected 0.8073720455290773, Toolmoz 0.807372045529073895% CI for the median, lower limit expected 16, Toolmoz 16
- Where the expected answer comes from
- Textbook S(23) = 0.448 = 160/357; log interval S·exp(±1.96σ) from an independent Python script; R’s survfit (log intervals) reports the 6-MP median as 23 with lower limit 16 and no upper limit
- Allowed difference
- ±1e-12
Case 4
- Inputs
- Time, event and group, one subject per line 6,1 6,1 6,1 6,0 7,1 9,0 10,1 10,0 11,0 13,1 16,1 17,0 19,0 20,0 22,1 23,1 25,0 32,0 32,0 34,0 35,0Also report survival at this time (0 for none) 10Interval for S(t) plainRestricted mean survival up to this time (0 for none) 23
- Expected, and what Toolmoz gave
- Survival at time 10 expected 0.7529411764705882, Toolmoz 0.752941176470588195% CI lower limit, survival at time 10 expected 0.5640993266787883, Toolmoz 0.564099326678789595% CI upper limit, survival at time 10 expected 0.9417830262623882, Toolmoz 0.9417830262623867Restricted mean survival up to time 23 expected 17.909243697478992, Toolmoz 17.909243697478985Standard error of the restricted mean expected 1.55318997824838, Toolmoz 1.5531899782483798
- Where the expected answer comes from
- Plain limits S ± 1.96 × Greenwood SE; the restricted mean is the area under the steps 1 × 6 + (6/7) × 1 + (96/119) × 3 + (64/85) × 3 + (176/255) × 3 + (32/51) × 6 + (64/119) × 1 = 10656/595, with its standard error from Σ A² d ÷ (n(n − d)), in an independent Python fractions script
- Allowed difference
- ±1e-9
Case 5
- Inputs
- Time, event and group, one subject per line 6,1,A 6,1,A 6,1,A 6,0,A 7,1,A 9,0,A 10,1,A 10,0,A 11,0,A 13,1,A 16,1,A 17,0,A 19,0,A 20,0,A 22,1,A 23,1,A 25,0,A 32,0,A 32,0,A 34,0,A 35,0,A 1,1,B 1,1,B 2,1,B 2,1,B 3,1,B 4,1,B 4,1,B 5,1,B 5,1,B 8,1,B 8,1,C 8,1,C 8,1,C 11,1,C 11,1,C 12,1,C 12,1,C 15,1,C 17,1,C 22,1,C 23,1,C
- Expected, and what Toolmoz gave
- Log-rank chi-square expected 52.3406779285147, Toolmoz 52.34067792851471Degrees of freedom expected 2, Toolmoz 2Observed events (B) expected 10, Toolmoz 10Expected events (B) expected 1.7440330471183465, Toolmoz 1.7440330471183465
- Where the expected answer comes from
- Three groups (6-MP, the 10 shortest placebo remissions and the other 11): the χ² of the observed minus expected events with the inverse of the 2 × 2 covariance matrix, computed in exact fractions by an independent Python script
- Allowed difference
- ±1e-9 relative
What this shows: the engine reproduces independently worked values for these cases. It does not prove every possible input is right. To test an answer you were given, see how to check a number; to see what is and is not checked across Toolmoz, see the accuracy ledger.
See a worked example
Worked example
A fixed demonstration, separate from the values you enter above.
- Time, event and group, one subject per line
weeks,relapse,group 6,1,6-MP 6,1,6-MP 6,1,6-MP 6,0,6-MP 7,1,6-MP 9,0,6-MP 10,1,6-MP 10,0,6-MP 11,0,6-MP 13,1,6-MP 16,1,6-MP 17,0,6-MP 19,0,6-MP 20,0,6-MP 22,1,6-MP 23,1,6-MP 25,0,6-MP 32,0,6-MP 32,0,6-MP 34,0,6-MP 35,0,6-MP 1,1,Placebo 1,1,Placebo 2,1,Placebo 2,1,Placebo 3,1,Placebo 4,1,Placebo 4,1,Placebo 5,1,Placebo 5,1,Placebo 8,1,Placebo 8,1,Placebo 8,1,Placebo 8,1,Placebo 11,1,Placebo 11,1,Placebo 12,1,Placebo 12,1,Placebo 15,1,Placebo 17,1,Placebo 22,1,Placebo 23,1,Placebo
- Column separator
- Detect automatically
- Interval for S(t)
- Log-log (complementary log-log, as SAS PROC LIFETEST)
- Confidence level
- 95%
- Also report survival at this time (0 for none)
- 12
- Restricted mean survival up to this time (0 for none)
- 0
- Interval bands on the figure
- Automatic (up to two groups)
Example result
| Group | Time | At risk | Events | Censored | Survival S(t) | Std error (Greenwood) | 95% CI lower | 95% CI upper |
|---|---|---|---|---|---|---|---|---|
| 6-MP | 6 | 21 | 3 | 1 | 0.857142857143 | 0.0763603548321 | 0.619717955266 | 0.951551747647 |
| 6-MP | 7 | 17 | 1 | 0 | 0.806722689076 | 0.0869352851801 | 0.563146564622 | 0.922809019203 |
| 6-MP | 9 | 16 | 0 | 1 | 0.806722689076 | 0.0869352851801 | 0.563146564622 | 0.922809019203 |
| 6-MP | 10 | 15 | 1 | 1 | 0.752941176471 | 0.0963496529943 | 0.5031995108 | 0.889361835169 |
| 6-MP | 11 | 13 | 0 | 1 | 0.752941176471 | 0.0963496529943 | 0.5031995108 | 0.889361835169 |
Log-rank χ² = 16.79 on 1 df, p < 0.0001. Observed and expected events: 6-MP 9 vs 19.25; Placebo 21 vs 10.75. S(t) is the product-limit estimate with Greenwood standard errors and 95% log-log (complementary log-log) pointwise intervals. The median is the first event time with S(t) at or below 0.5 (the midpoint where S is exactly 0.5 over an interval), and its interval is where the confidence limits cross 0.5. Censoring is assumed unrelated to the outcome.