Kaplan-Meier Survival Analysis: Visualizing Time-to-Event Data

simulator intermediate ~10 min
Loading simulation...
HR = 0.65 — 35% reduction in hazard of death

With hazard ratio 0.65, the treatment reduces the hazard of death by 35%. Median survival improves from 24 months (control) to approximately 37 months (treatment). With 100 patients per group and 15% censoring, the log-rank test is highly significant.

Formula

S(t) = ∏ (1 − d_i / n_i) for all t_i ≤ t
HR = h_treatment(t) / h_control(t)
χ² = Σ (O_i − E_i)² / E_i

Time-to-Event Data

Survival analysis addresses a fundamental question in medicine: how long until an event occurs? The event might be death, disease recurrence, recovery, or any well-defined transition. Unlike ordinary regression, survival data has a unique feature — censoring. Not every patient experiences the event during the study period, and we cannot simply discard these observations or treat them as events. The Kaplan-Meier estimator elegantly handles this by updating survival probability only at times when events actually occur.

Reading the Survival Curve

The visualization shows two step-function curves — treatment (cyan) and control (red) — each stepping down whenever a death occurs. Tick marks indicate censored observations (patients who dropped out or were still alive at data cutoff). The vertical distance between curves at any time point represents the survival advantage of treatment. The shaded regions show 95% confidence intervals, which widen as patients are lost to follow-up and the estimate becomes less precise.

Hazard Ratio and Clinical Significance

The hazard ratio is the most important summary statistic from a survival analysis. In this simulation, an exponential survival model generates event times with a constant hazard, making the hazard ratio the simple ratio of median survival times inverted. Real clinical data often shows non-proportional hazards — the treatment effect may emerge slowly or diminish over time — requiring more sophisticated models like the Cox proportional hazards regression.

From Statistics to Patient Impact

Statistical significance (p < 0.05) tells us the observed difference is unlikely due to chance, but clinical significance asks: is the difference large enough to matter? A drug that extends median survival by 2 weeks at the cost of severe side effects may be statistically significant with a large sample but clinically meaningless. The simulation lets you explore how sample size, effect size, and censoring interact to determine what studies can actually detect.

FAQ

What is a Kaplan-Meier curve?

A Kaplan-Meier curve is a step function that estimates the probability of surviving beyond each time point, accounting for censored observations (patients lost to follow-up or still alive at study end). It is the most widely used method for visualizing survival data in clinical trials.

What is censoring in survival analysis?

Censoring occurs when the exact survival time is unknown — typically because the patient was still alive when the study ended (right censoring) or was lost to follow-up. Kaplan-Meier analysis handles censoring by adjusting the number at risk at each event time.

What is a hazard ratio?

The hazard ratio (HR) compares the instantaneous rate of events (e.g., death) between two groups. HR = 0.65 means the treatment group has 35% lower hazard at any given time. HR < 1 favors treatment; HR > 1 favors control; HR = 1 means no difference.

What is the log-rank test?

The log-rank test compares two survival curves by examining whether the observed number of events in each group differs from what would be expected if the curves were identical. It is the standard hypothesis test for comparing survival distributions in clinical trials.

Sources

Embed

<iframe src="https://homo-deus.com/lab/biostatistics/survival-analysis/embed" width="100%" height="400" frameborder="0"></iframe>
View source on GitHub