Survival Analysis
Analyze time-to-event data using Kaplan-Meier curves, the log-rank test, and Cox proportional hazards regression — essential methods for clinical and epidemiological research.
You'll learn
How to analyze time-to-event data and interpret Kaplan-Meier survival curves.
Use this when
Your outcome is time until an event — death, relapse, discharge, or readmission.
What Is Survival Analysis?
Survival analysis analyzes the time until an event occurs. The "event" does not have to be death — it can be relapse, recovery, hospital discharge, equipment failure, or any event of interest.
- ●Time variable: Duration from study start (or diagnosis) until event or censoring
- ●Event indicator: Binary (1 = event occurred, 0 = censored)
- ●Censoring: Subjects who have not yet experienced the event when the study ends, or who are lost to follow-up. Their data is not discarded — survival analysis uses all available information.
Why not just use logistic regression? Because logistic regression ignores follow-up time. Two patients who are both alive at study end contribute equally, even if one was followed for 1 month and the other for 5 years.
The Kaplan-Meier Estimator
The Kaplan-Meier (KM) method estimates the survival function S(t) — the probability of surviving beyond time t — from your sample data. It produces the characteristic "step function" survival curve.
- ●Each step in the curve represents an event (death, relapse)
- ●Censored observations are marked with tick marks on the curve
- ●The curve starts at S(0) = 1 (100% event-free) and decreases over time
- ●Median survival: The time at which S(t) = 0.5 (50% of subjects have experienced the event)
- ●KM curves for different groups (treatment vs. control) can be plotted on the same graph for visual comparison
The Log-Rank Test
The log-rank test is the standard method for comparing KM curves between two or more groups. It tests whether the survival functions are equal.
- ●H₀: S₁(t) = S₂(t) — no difference in survival between groups
- ●H₁: At least one group has a different survival function
- ●The test is most powerful when the ratio of hazards is constant over time (proportional hazards assumption)
- ●For three or more groups: use an overall log-rank test, then pairwise comparisons with Bonferroni correction
Cox Proportional Hazards Regression
Cox regression models the hazard ratio (HR) — the ratio of the instantaneous event rate between groups — while adjusting for multiple covariates simultaneously.
h(t|X) = h₀(t) × exp(β₁X₁ + β₂X₂ + ...)
- ●HR = exp(β): Interpretation similar to OR in logistic regression
- ●HR = 2.0: Subjects with higher exposure have twice the instantaneous risk of the event
- ●HR = 0.6: A protective factor reduces the event rate by 40%
- ●The key assumption: Proportional hazards — the HR must be constant over time. Test with Schoenfeld residuals.
How to Report Survival Results
Example: "The 5-year disease-free survival was 72% (95% CI: 65–79%) in the treatment group vs. 54% (95% CI: 46–62%) in the control group (log-rank p = 0.003). After adjusting for age and stage, the treatment was associated with a 38% reduction in the risk of relapse (HR = 0.62, 95% CI: 0.45–0.86, p = 0.004)."
Practice with your own dataset
Upload a dataset with a time variable and an event indicator, then run Survival Analysis to see Kaplan-Meier estimates and the log-rank test.
Required variables
- • Time variable
- • Event indicator (0/1)
- • Optional group variable
- 1.Upload a dataset with follow-up time (days/months) and event (0/1) columns
- 2.Select "Survival Analysis" from the analysis menu
- 3.Assign time variable, event indicator, and optionally a grouping variable
- 4.Review KM estimates, median survival, log-rank p-value, and HR if groups were compared
Trusted sources behind this lesson
Further reading
Read next
Sample Size and Statistical Power
Learn why underpowered studies waste resources and mislead, how to calculate the sample size you need for any study design, and what effect size to anticipate.