Survival analysis: Kaplan–Meier and Cox
When do members cancel? Censoring, Kaplan–Meier curves, the log-rank test and hazard ratios from Cox.
Counting "how many cancelled" is easy. This question is where people stall.
"How long after signing up do members cancel? Does it depend on the plan?"
Try to work out an average membership length and you hit a snag: members still subscribed haven't cancelled yet, and nobody knows when they will. The method for this is survival analysis. Here we go step by step from the Kaplan–Meier curve to Cox regression.
What survival analysis is
Survival analysis studies the time until something happens.
Despite the name, it isn't only about life and death. It works for anything where you want to know "when does it happen?" — cancellations, machine failures, repeat purchases.
The key idea: censoring
When the event hasn't happened yet by the end of observation, the case is censored.
Say you pull the data in a member's eighth month and they are still subscribed: all you know is "they didn't cancel for at least 8 months". Drop them, or treat them as cancelling at 8 months, and the result is biased. Survival analysis uses that information as it is.
What the data needs
- Duration — from the start to the event or the end of observation (e.g. months)
- Event — 1 if it happened, 0 if not yet
- Groups · covariates — plan, sign-up channel, usage time and so on
Everyone's starting point must be defined the same way. Here it is "the sign-up date".
Today's example
- Data — 1,200 members of an online subscription service
- Duration — months since sign-up (months)
- Event — cancelled or not (status · 384 cancelled)
- Comparison — 700 on the monthly plan vs 500 on the annual plan
Step 1 · The Kaplan–Meier curve
The Kaplan–Meier curve is a step-shaped graph of the share for whom the event hasn't happened yet as time passes.
The point where the curve crosses 0.5 is the median survival time — how long it took for half to cancel. If the curve never drops below 0.5, it is written as "not reached".
Step 2 · The log-rank test
Whether the curves differ between groups is checked with the log-rank test. With p < .05, the two groups' survival curves are taken to differ.
Step 3 · Cox regression
To account for other variables as well, use Cox proportional hazards regression. Read the result as a hazard ratio (HR).
- HR > 1 — the event happens sooner
- HR < 1 — the event happens later
- If the 95% CI contains 1 → not significant
An HR of 0.48, for example, means the risk of cancelling is about 52% lower with everything else equal.
Cox regression assumes the hazard ratio stays constant over time — the proportional hazards assumption — so always check it with the Schoenfeld residual test.
When another model fits better
- Competing risks (Fine-Gray) — when something other than the event of interest ends the observation (e.g. merging into a family plan rather than cancelling)
- Accelerated failure time (AFT) model — when you'd rather read "how many times longer it takes" (a time ratio) than risk
- Cure model — when there seems to be a group for whom the event never happens
How to write it up
- Number of cases, events and censored cases
- Median survival time with 95% CI for each group
- χ² and p of the log-rank test
- HR and 95% CI from Cox regression, plus the proportional hazards check
The median survival time of monthly-plan members was 14.0 months (95% CI [12.1, 16.3]), while annual-plan members did not reach the median during follow-up. The two survival curves differed significantly (log-rank χ²(1) = 58.4, p < .001), and in a Cox regression adjusting for sign-up channel and monthly usage time, annual-plan members still had a 52% lower risk of cancelling than monthly-plan members (HR = 0.48, 95% CI [0.38, 0.61]).
Example sentence · the numbers are made up
In Skari
Upload a file to Skari AI and, from the duration column and the 0/1 event column, it reads it as follow-up (survival) data — what one row is, how many events there are, and why it reads it that way.

If there are groups to compare, it sets out an analysis plan first: Table 1 → Kaplan–Meier → Cox, with the primary and secondary analyses, assumption checks and the reporting guideline (STROBE).

Run a survival analysis on your members
Upload a file to Skari AI and it reads the data and plans the analysis first
Rather than choosing the analysis after seeing results, you decide what to look at and how first, then run it — which also makes the methods section of a paper or report easy to write.
In Kaplan–Meier survival analysis, the survival curves by group, the number-at-risk table, median survival times and the log-rank result are all on one screen.



In Cox proportional hazards regression, you get hazard ratios with 95% confidence intervals, the concordance (C-index) and events per variable (EPV), and the proportional hazards assumption is checked with the Schoenfeld test.


Results can be exported to Word, PDF and Excel, and every calculation runs in R.
The Statistics menu also has competing risks (Fine-Gray), accelerated failure time (AFT) models and cure models, so you can carry on with the model that suits your data.
Wrapping up
The heart of survival analysis is not throwing away the fact that something hasn't happened yet. Look at the shape with the curves, check the difference with the log-rank test and account for other factors with Cox regression, and you can answer "when" questions with confidence.
Want the theory behind it?The Academy's survival analysis guide covers Kaplan–Meier, Cox regression and choosing between survival models →