Survival analysis: Kaplan-Meier curves, the log-rank test and hazard ratios
How many months did it take for a patient's illness to come back after starting a drug? Some patients still had no relapse when the study ended, and some moved away and stopped answering. Here you will see how to draw a curve without throwing those people away, by stretching and shrinking the bars of fifteen patients. All data on this page is made up. The page explains statistical ideas only and is not medical advice.
Short answer. Survival analysis studies "how long it took until something happened". The hard part is that some people could not be followed to the end (censoring). The Kaplan-Meier curve does not throw them away. It counts each person only for as long as they were followed, and draws "the share who have not had the event yet" as a staircase. Whether two curves differ is checked with the log-rank test, and how much they differ is told by the hazard ratio.
Drag the end of a bar (● or ○) left or right to change how long that person was followed (1 to 36 months). Tap the end without dragging to switch between event and censored. The boxes and buttons below do the same. ● is a person who had the event (here, a relapse) at that time. ○ is a person who had no event up to that time and then could not be followed any more. On the green curve, censoring shows as a short vertical tick. "At risk" at the bottom is the number of people still being followed at that time. The 15 patients are made up.
Definitions
Write T for the time until the event (here, relapse), as a random variable. We define the following.
- survival function
- The probability that no event has happened by time t.
- censoring
- Not knowing the event time T exactly, only that it lies in some range. Right censoring means we only know there was no event up to the last time c the person was followed, that is:
- Kaplan-Meier estimator
- Let t₁ < t₂ < … be the distinct times at which events happen. Let dᵢ be the number of events at tᵢ, and nᵢ the number of people followed up to just before tᵢ with no event and no censoring (the people at risk). The survival function is estimated by the product below. In the text, this estimate is also written S(t).
- median survival time
- The first time at which the estimated survival function is 0.5 or lower.
- hazard function
- Given no event up to t, the probability of an event in the next short time Δt, divided by Δt, in the limit as Δt goes to 0. It is a rate per unit of time, not a probability.
- hazard ratio
- The ratio of the hazard functions of the two groups. Assuming this ratio stays the same for every t is the proportional hazards assumption.
- log-rank test
- Tests the null hypothesis "the two groups have the same survival function". At each event time tᵢ, let nᵢ be the number at risk in both groups together, dᵢ the number of events, n₁ᵢ and n₂ᵢ the numbers at risk in the treatment and control groups, and Oᵢ the observed events in the treatment group. The expected events Eᵢ in the treatment group and the variance piece Vᵢ are: The test statistic is below. Under the null hypothesis, it roughly follows a chi-square distribution with 1 degree of freedom.
1. Why an average or a simple share does not work
Here are five made-up patients for a worked example. Each was followed from the day treatment started until the illness came back.
| Person | Followed for | How it ended |
|---|---|---|
| 1 | 3 months | ● relapse (event) |
| 2 | 5 months | ○ moved away, lost contact (censored) |
| 3 | 7 months | ● relapse |
| 4 | 10 months | ● relapse |
| 5 | 12 months | ○ study ended with no relapse (censored) |
- Take the average?
(3 + 5 + 7 + 10 + 12) ÷ 5 = 7.4 months. But persons 2 and 5 did not relapse at 5 and 12 months. All we know is "no relapse at least until then". Counting those times as relapse times makes the answer too short. Averaging only the three relapses gives 6.7 months, even shorter, because it leaves out the people who lasted longest. - Count "the share with no relapse after 10 months"? We do not know what happened to person 2 after 5 months. Leave person 2 out and it is 1 of 4 (person 5), so 25%. Count person 2 as relapse-free and it is 2 of 5, so 40%. Neither has a good reason behind it. Kaplan-Meier gives 26.7% (section 3).
Censoring is common in real studies. People join on different days but the study ends on one day, so the later someone joins, the shorter they are followed. The lab below uses the 15 people from the top lab to compare three ways of handling censoring.
| Method | Median survival | Survival at 12 months | Survival at 24 months |
|---|
This picture uses the data from the top lab. Change a bar up there and this changes too. The green solid line is the correct curve, the orange long dashes drop the censored people, and the purple short dots count censored people as "no event until 36 months".
Try this. ① With the starting data the three medians are 16 months (correct), 13 months (dropped) and 24 months (counted as event-free). Survival at 24 months is 35.5%, 11.1% and 46.7%, so the wrong methods are off by −24.4 and +11.1 percentage points. ② The dropped curve hits 0 at the last event (27 months). Everyone left had an event, so it claims "everyone has the event in the end". ③ In the top lab, switch every end to ●. The three curves become one. With no censoring there is nothing to choose.
2. Censoring: people whose ending you did not see
Censoring means you do not know exactly when the event happened (or will happen) for that person. You only know it lies in some range. It is named by which side you do not know.
| Kind | What you know | Example |
|---|---|---|
| Right censoring | "No event at least until this time" | The study ended, contact was lost, the person left the study. The most common kind, and the one this page covers |
| Left censoring | "The event had already happened when we first looked" | The illness was there at the first check-up, but we do not know when it started |
| Interval censoring | "It happened somewhere between two visits" | Checked every 3 months: not there at 6 months, there at 9 months |
The Kaplan-Meier curve and the log-rank test handle right censoring. Left and interval censoring need other methods.
A key assumption: censoring must be unrelated to the event
Kaplan-Meier assumes a censored person "had the same future as the people still in the study". After they leave, the people who remain stand in for them. This is the assumption that censoring is unrelated to the event. If people leave because the study ended or because they moved, that is usually fine. But if people who got worse leave to go to another hospital, those who remain are healthier than the whole group, and the curve looks better than the truth. You cannot check this assumption from the data alone. Record why people left, and check that the share who left is not very different between groups.
Sometimes a different event makes the event you study impossible, for example death from another cause. If you treat that as censoring, the curve turns into an imaginary "what if the other cause did not exist" and its meaning changes. This is called competing risks, and there are separate methods for it. This page does not cover them.
3. The Kaplan-Meier curve: a worked example
There is one idea. At each time an event happens, look at the people still being followed, count how many got past that time, and multiply those shares together. The people still being followed are called at risk, written n. The number of events at that time is d. A censored person stays in n until they leave and drops out after that.
S(t) is "the share with no event after time t", and Π (capital pi) means "multiply them all". Here is the full count for the five people from section 1.
| Time | At risk n | Events d | Censored | Share that got past, 1 − d ÷ n | S(t) |
|---|---|---|---|---|---|
| 3 months | 5 | 1 | 0 | 4/5 = 0.8 | 0.8 |
| 5 months | 4 | 0 | 1 | (no event) | 0.8 |
| 7 months | 3 | 1 | 0 | 2/3 ≈ 0.667 | 0.8 × 2/3 ≈ 0.533 |
| 10 months | 2 | 1 | 0 | 1/2 = 0.5 | 0.533 × 0.5 ≈ 0.267 |
| 12 months | 1 | 0 | 1 | (no event) | 0.267 |
- 0 to 3 months: no one has had the event, so S = 1.
- 3 months: 1 of 5. The share that got past is 4/5, so S steps down to 0.8.
- 5 months: person 2 is censored. The curve stays at 0.8 and gets a tick. The next n is one smaller.
- 7 months: now 1 of 3 (persons 3, 4, 5). Person 2 has left, so the bottom number is 3, not 4. S = 0.8 × 2/3 ≈ 0.533.
- 10 months: 1 of 2. S ≈ 0.533 × 1/2 ≈ 0.267.
- 12 months: person 5 is censored. The curve ends at 0.267 with a tick. No one was followed after that, so we do not know what comes next.
Here is the same arithmetic written as equations.
The first time the curve reaches 0.5 or less, 10 months, is the median survival. The question from section 1, "the share with no relapse after 10 months", is 0.267, or 26.7%.
When an event and a censoring happen at the same time
This page counts the event first. A person censored at that time is still inside that time's n, because "they were followed with no event up to that time". This is the usual rule, and the n values in the table above use it. For example, if at 5 months one person has the event and another is censored, n at 5 months is everyone still there, including the censored person, who leaves only after that.
With no censoring it is just a simple share
If no one is censored, the bottom number shrinks only because of events, and the product cancels out step by step, as in (4/5) × (3/4) × (2/3) = 2/5. So Kaplan-Meier equals "people with no event after t ÷ people at the start". It only gives a different answer when there is censoring.
# Python standard library only. At the same time, events are counted first
def kaplan_meier(times, events):
at_risk, survival, curve = len(times), 1.0, []
for t in sorted(set(times)):
d = sum(1 for x, e in zip(times, events) if x == t and e)
c = sum(1 for x, e in zip(times, events) if x == t and not e)
if d:
survival *= 1 - d / at_risk
curve.append((t, at_risk, d, round(survival, 3)))
at_risk -= d + c
return curve
kaplan_meier([3, 5, 7, 10, 12], [True, False, True, True, False])
# [(3, 5, 1, 0.8), (7, 3, 1, 0.533), (10, 2, 1, 0.267)]
4. How the formula is built
Let us build S(t) = Π (1 − dᵢ ÷ nᵢ) one step at a time with the five people from the worked example. Each time you press "Next", a piece is added to the formula (the orange background marks the new piece), the curve gets a new step, and the table below fills in.
| Time tᵢ | At risk nᵢ | Events dᵢ | Got past, 1 − dᵢ ÷ nᵢ | Running S(tᵢ) |
|---|
In the top bars, green means still being followed at the orange dashed time (at risk), and the paler ones have already left.
Written only as equations, the steps above look like this. c₁ is the number of people censored between t₁ and t₂.
The multiplication in step 5 is the multiplication rule of probability: the chance of "A and B" is "the chance of A × the chance of B given A" (see Probability and Bayes' theorem). Getting past 7 months means "get past 3 months, and then, among those who did, also get past 7 months". 1 − d₂ ÷ n₂ is exactly a conditional probability counted "among people who got past 3 months", so you can multiply it in. That is why Kaplan and Meier called this the product-limit estimate.
Why do steps appear only at event times? At a time with no event, the share that got past is 1 − 0 ÷ n = 1, and multiplying by 1 changes nothing. Censoring does not enter that share at all; it only makes the next n smaller.
5. How to read the curve
- The vertical axis is "the share with no event yet". It starts at 100% and only goes down, never up.
- Median survival. The first time the curve reaches 50% or less. It is how long it took for half the people to have the event. If the curve never drops to 50%, write "not reached" and do not use an average instead. If the curve sits flat at exactly 50%, some tools use the middle of that flat stretch.
- Survival at a fixed time. Read it like "71.1% survival at 12 months". It is the height of the curve at that time.
- Do not trust the tail much. Near the right end only a few people are at risk, so one person's event makes a big step. Look at the at-risk row too, and do not read much into the shape where few people remain. A curve that ends above 0 does not mean "the rest never have the event". Nobody was followed after that.
- Confidence band. At each time it shows a range for where the true survival probably is. This page gets the standard error from Greenwood's formula and draws
S ± 1.96 × standard error, cut to stay between 0 and 1.
Each piece of the sum gets bigger when the number at risk nᵢ is small. That is why the band widens to the right. At 3 months in the worked example it is 0.8 × √(1 ÷ (5 × 4)) ≈ 0.179, so the band runs from 0.449 to 1. Many statistics programs build the band on a different scale, such as a log scale, so that it never leaves 0 to 1. Their band can differ a little from this page's.
Common misreadings. ① "The 95% band at 12 months is 47.0% to 95.1%, so there is a 95% chance the true value is inside" is not quite right. It means that if you made a band this way in many repeated studies, about 95% of them would cover the true value (see Confidence intervals). ② The band is worked out separately at each time. It does not mean there is a 95% chance the whole curve stays inside the band at once. ③ Two groups' bands overlapping does not mean "no difference". Comparing is done with the test in section 7.
Try this. (The top lab) ① The starting data has 9 events and 6 censored. Median survival is 16 months, survival at 12 months is 71.1%, and at 24 months 35.5%. The number at risk at 0, 6, 12, 18, 24, 30 and 36 months is 15, 12, 9, 6, 4, 2 and 1. ② Turn on the "95% confidence band". At 12 months the band is 47.0% to 95.1%; at 24 months it is wider, 6.9% to 64.2%. ③ Tap the end of person 2 (4 months, ○) to make it ●. Survival at 12 months drops to 66.0%. Same 4 months, but "event at 4 months" and "no event up to 4 months" are different information. ④ Switch person 15 (36 months, ○) to ●. The end of the curve drops to 0. Only one person is left at that time, so one person decides the end. ⑤ Drag person 10 (19 months, ○) to 16 months. Now two events and one censoring share 16 months. Because events are counted first, none of the numbers in the readout change (only the at-risk count at 18 months goes from 6 to 5). If the censoring were removed first, n at 16 months would be 7 instead of 8, and the curve would drop to about 0.451 instead of 0.474. ⑥ Switch every end to ●. Survival at 12 months becomes 60.0%, the same as the 9 people with no event after 12 months ÷ 15 people.
6. Key properties
| Property | In plain words |
|---|---|
| Never goes up | The curve steps down at events and stays flat otherwise. It never rises |
| Steps only at events | Censoring does not lower the curve; it only makes the next bottom number smaller. So every step after a censoring is a little bigger |
| No censoring means a simple share | It equals "people with no event after t ÷ people at the start" |
| Assumes no shape | It does not assume a distribution such as the normal distribution in advance; it builds the staircase straight from the data (a nonparametric method) |
| Shaky near the end | Few people at risk, so big steps and a wide band. After the last observation nothing is known |
7. Comparing two groups: the log-rank test
The treatment group's curve and the control group's curve look different. That could be chance. The log-rank test assumes "the two groups' curves are really the same" and measures how far the data is from that assumption (see Hypothesis testing and p-values).
The idea goes like this. At each event time, if the groups were the same, the events should be split in proportion to how many people each group has at risk. If 40 treatment and 40 control people are at risk and 3 events happen, the treatment group would be expected to have 3 × 40 ÷ 80 = 1.5 of them. If it actually had 0, that is 1.5 fewer than expected. Add up this "observed − expected" over all event times.
n is the total at risk in both groups at that time, and d is the total events in both groups. The variance piece is "how much the observed count would wobble around the expected count if the groups were the same". If the groups are the same, χ² (chi-square) roughly follows a chi-square distribution with 1 degree of freedom, so the area to its right gives the p-value. When χ² is above 3.84, p is below 0.05.
| Time | At risk (treatment / control) | Events (treatment / control) | Expected treatment events | Observed − expected | Variance piece |
|---|
The data is made up with a fixed-seed random number generator. The control group has a constant hazard (median survival 12 months), and the treatment group's hazard is that times the "true hazard ratio". About 2% of people per month lose contact (censored), and the study ends at 36 months. The same seed gives the same people, so changing only the hazard ratio stretches or shrinks the same people's event times. "Draw new data" adds 1 to the seed. The table has one row per event time, and the last row is the sum.
Try this. ① At the start (40 per group, true hazard ratio 0.6, seed 1): the treatment group has 21 events against 28.12 expected, and the control group 28 against 20.88. χ² = (21 − 28.12)² ÷ 11.34 = 4.46, p = 0.035, and the hazard ratio estimate is 0.56. The first table row (1 month) shows at risk 40 / 40, events 0 / 3, expected 1.5. ② Press "Draw new data" (seed 2). The true value is still 0.6, but χ² is 1.91 and p = 0.167. Press it again (seed 3): χ² 7.98, p = 0.005, estimate 0.45. Even with the same true value, p jumps around a lot from sample to sample. ③ With seed 1, set the true hazard ratio to 1: χ² 0.06, p = 0.811. Running seeds 1 to 200 with this page's code, p < 0.05 shows up 13 times (6.5%) even though the groups really are the same (see Type I and II errors and power). ④ With seed 1 and true hazard ratio 0.6, cut the group size to 10: p = 0.883 and the estimate is 1.08, pointing the wrong way. Raise it to 100: χ² 11.03, p < 0.001, estimate 0.57. Over seeds 1 to 200, p < 0.05 came up 45% of the time (90 times) with 40 per group and 75% (150 times) with 100 per group (see Sample size).
The hazard ratio estimate. For each group take "observed ÷ expected", then divide the two: (O_treatment ÷ E_treatment) ÷ (O_control ÷ E_control). O is observed and E is expected events. It is a quick estimate you can work out by hand. Hazard ratios in papers usually come from the Cox model in section 9. The two are usually close but not the same.
Common misreadings. ① p = 0.035 does not mean "a 3.5% chance the groups are the same". It means "if the groups were the same, the chance of data at least this far off". ② A large p is not evidence that the groups are the same. In Try this ②, seed 2 had a true hazard ratio of 0.6 but p = 0.167. With few people or few events the test can miss a real difference. ③ p is not the size of the difference. With a huge number of people, even a tiny difference gives a tiny p. Size is told by the hazard ratio and its confidence interval.
| What the log-rank test sees | What it does not see |
|---|---|
| Whether one group keeps having more (or fewer) events across the whole time | Differences when curves cross. Early and late differences cancel each other out (the "crossing example" in section 8) |
| It handles censoring correctly, comparing only the people left at each event time | The size of the difference. p does not say "how different" |
| It does not assume a shape (distribution) for the curve (nonparametric tests) | Adjusting for other things that affect the outcome, such as age. That is done with the Cox model (section 9) |
| It gives every event the same weight | A question about one time, such as "is survival at 12 months different?". That is a different question with a different calculation. There are also versions that give more weight to early differences (weighted log-rank tests) |
8. Hazard and the hazard ratio
The hazard is "among people who have made it so far, the speed at which events happen in the next moment". It is a speed (a rate per unit of time), not a probability, so it comes with a unit such as "per month" or "per year".
Δt is a very short time. A hazard of 0.05 per month means "out of 100 people still going, roughly 5 have the event over the next month". Because it is a speed, it can be above 1 if you use a long time unit. A high hazard makes the curve fall steeply; a low one makes it gentle. If the hazard never changes, the curve is S(t) = e^(−h × t) and the median survival is ln 2 ÷ h ≈ 0.693 ÷ h. A hazard of 0.0578 per month gives 12 months.
The hazard ratio (HR) divides one group's hazard by the other's: HR = h_treatment(t) ÷ h_control(t). Assuming this ratio does not change over time is the proportional hazards assumption. Under that assumption, S_treatment(t) = S_control(t)^HR.
| Reading a hazard ratio of 0.5 as | Right? | Why |
|---|---|---|
| "At every moment, the event speed among people still going is half" | Right | That is exactly what a hazard ratio means |
| "People live twice as long" | Wrong | The median is exactly doubled only when the hazard is constant. If the hazard rises over time it is less than doubled (1.41 times in the lab below); if it falls, more (4 times) |
| "Half the chance of an event" | Wrong | When the control group is at 50%, treatment is at 1 − 0.5^0.5 ≈ 29.3%, which is 0.59 times. It is close to "half" only early on, while events are rare |
The first three buttons draw model curves. They are Weibull distributions tuned so the control group's median survival is 12 months (hazard constant, rising in proportion to time, or falling with one over the square root of time), and the treatment group's hazard is the hazard ratio times the control's at every moment. Drag across the picture or use the slider to move time t. The "Crossing example" is prepared made-up data (30 people per group). The treatment group was made with a high hazard for the first 6 months and a low one after. The bottom panel then shows the event speed (events ÷ person-months followed) for 0 to 6 months and 6 to 36 months.
Try this. ① At the start (constant hazard, hazard ratio 0.5, t = 12): median survival is 12 months for control and 24 for treatment, twice as long. The share with an event by 12 months is 50.0% for control and 29.3% for treatment, 0.59 times. Not half. ② Press "Rising". The hazard ratio is still 0.5, but the treatment median is 16.97 months, 1.41 times. "Falling" gives 48 months, 4 times. How many times longer people last depends on the shape of the hazard. Still, at 12 months the event shares are 50.0% and 29.3% for all three shapes, because that is when the control group is at 50%. ③ With "Constant hazard", set t to 3: the event shares are 15.9% and 8.3% (0.52 times), close to half. At 36 they are 87.5% and 64.6% (0.74 times). ④ In the bottom panel, whatever the shape, the treatment hazard follows the control hazard at exactly the hazard ratio times its height. That is what proportional hazards means. ⑤ "Crossing example": in the first 6 months the event speed is 0.125 for treatment and 0.056 for control, a hazard ratio of 2.22. After that it is 0.017 and 0.048, a ratio of 0.35. The two curves meet at about 21 months and then swap places. Yet a single hazard ratio for the whole time is estimated at 1.08, with log-rank χ² 0.08 and p = 0.784. The curves are clearly different, but the test barely sees it.
When proportional hazards breaks. If the hazard ratio changes over time, as in the crossing example, one hazard ratio cannot sum it up. "Hazard ratio 1.08" mixes the early 2.22 with the later 0.35 and is not true at any time. In that case report separate hazard ratios for separate periods, or use another summary such as survival at a fixed time or "average event-free time within a fixed period". To check the assumption, plot log(−log S(t)) for each group and see whether the two lines run parallel, or use the test your statistics program offers. Under proportional hazards S_treatment = S_control^HR, so the gap between these values is always log HR.
9. The Cox proportional hazards model: adjusting for other things
If the treatment group happened to be younger, part of the gap between the curves could come from age rather than the treatment. The Cox proportional hazards model puts things like age in as well and finds the hazard ratio when everything else is the same. This is called the adjusted hazard ratio.
h₀(t): the hazard of a person whose x values are all 0 (the baseline hazard). Its shape is left open, so the model works whether the hazard rises or falls.x₁, x₂: values for each person. For example x₁ is 1 for treatment and 0 for control, and x₂ is age in years.e^β₁: how many times the hazard changes when x₁ goes up by 1 and the other values (age) stay the same. This is the adjusted hazard ratio. If e^β₁ = 0.6, then "comparing people of the same age, the treatment group's hazard is 0.6 times".- Multiplying values by numbers and adding them inside e looks like logistic regression. Logistic regression treats the log odds as that sum; the Cox model treats the log hazard as the log baseline hazard shifted by that sum.
It is called "proportional hazards" because when you divide two people's hazards, h₀(t) cancels and only e^(β₁(x₁ − x₁') + β₂(x₂ − x₂') + …) is left. There is no t in that ratio, so it stays the same over time. The assumption from section 8 is needed here too. Adjusting works only for things you measured. Differences you did not measure remain. That is why clinical trials assign people at random: on average it balances even the things nobody measured (see Randomization and control groups and Confounding and bias).
This page does not cover how the β values are found (by making the partial likelihood as large as possible). It only shows the shape of the formula and what it means.
10. Hazard ratio, relative risk and odds ratio
All three are "a ratio between two groups", so they are easy to mix up. What gets divided is different (see Odds ratio and relative risk).
| Ratio of what | Time | Example from section 8 (control at 50%, hazard ratio 0.5) | |
|---|---|---|---|
| Hazard ratio (HR) | Event speed at each moment | Uses all times. Under proportional hazards it is one value | 0.5 |
| Relative risk (RR) | Share with an event by a fixed time | Looks at one time only. You need to know everyone's status up to then | 29.3% ÷ 50% ≈ 0.586 |
| Odds ratio (OR) | Odds of an event (happened ÷ not happened) by a fixed time | Looks at one time only | (0.293 ÷ 0.707) ÷ (0.5 ÷ 0.5) ≈ 0.414 |
The same two curves give three different numbers: 0.5, 0.586 and 0.414. When events are rare (early times) the three get close; when events are common they drift apart. When you quote a number from a paper, always say which ratio it is.
Where is it used?
- Clinical trials. Time to relapse, worsening or death is compared between a treatment group and a control group. Kaplan-Meier curves, the log-rank p-value, and the Cox model's hazard ratio with its confidence interval are often reported together (see Clinical trial design).
- Machine and part failures. Reliability analysis, which studies time to failure, uses the same methods. A part that has not failed when the test ends is censored.
- Customer churn. The time from sign-up to cancellation. Customers who are still subscribed are censored. Counting "the share still here 3 months after sign-up" using only people who have already cancelled goes wrong for the same reason as in section 1.
- Time to readmission. The time from leaving hospital to the first readmission. If the event can happen many times (repeated readmissions) or another event can prevent it (competing risks, section 2), other methods fit better.
Common questions
Can I just drop the censored people?
No. A censored person tells you "there was no event at least until this time". If you drop them, only people with events are left and the curve falls too fast. If you instead count them as event-free until the end, the curve falls too slowly. Kaplan-Meier counts each person only for the time they were followed.
What does it mean when the median survival is "not reached"?
The curve never dropped to 50% during the time people were followed. More than half had no event by the end. Do not replace it with the average of the follow-up times: that treats censored times like event times and comes out too short. Report the survival at a fixed time (for example 24 months) instead.
Does a hazard ratio of 0.5 mean people live twice as long?
No. A hazard ratio of 0.5 means that, among people who have made it so far, the speed at which events happen in the next moment is half, at every point in time. The median survival is exactly doubled only when the hazard stays constant over time. If the hazard rises, it is less than doubled; if it falls, more than doubled. It also does not mean "half the chance of an event by some time".
If the log-rank test gives p = 0.03, is there a 3% chance the groups are the same?
No. The p-value is the chance of getting data at least this far off, assuming the two groups' curves really are the same. It is not the chance that the groups are the same, and it is not the size of the difference. How big the difference is comes from the hazard ratio and its confidence interval.
Is survival analysis only about death?
No. Use it whenever you measure "time until something happens" and some cases end before you see it. Examples are the time until a machine part fails, until a customer cancels a subscription, or until a discharged patient is admitted again. A machine that has not failed yet, or a customer still subscribed, is censored.
Words
| Words used here | Textbook term |
|---|---|
| How long it took until something happened | Survival time, time-to-event |
| That something (relapse, death, failure, cancellation) | Event, failure |
| Did not see the ending | Censoring: right, left and interval censoring |
| Censoring unrelated to the event | Non-informative censoring, independent censoring |
| Share with no event yet, S(t) | Survival function |
| The staircase curve | Kaplan-Meier estimator, product-limit estimator |
| People still being followed | Risk set, number at risk |
| When the curve first reaches 50% or less | Median survival time |
| Band worked out at each time | Pointwise confidence interval, Greenwood's formula |
| Comparing two curves | Log-rank test, Mantel-Cox test |
| Observed / expected events | Observed and expected counts |
| Speed of events in the next moment | Hazard function, hazard rate |
| Ratio of two groups' hazards | Hazard ratio (HR) |
| The ratio does not change over time | Proportional hazards assumption |
| Model that adjusts for other values | Cox proportional hazards model, Cox regression |
| Hazard of someone whose values are all 0 | Baseline hazard |
| Hazard ratio when the other values are the same | Adjusted hazard ratio |
| Another event that prevents the event | Competing risks |
| Average event-free time within a fixed period | Restricted mean survival time (RMST) |
| Ratio of shares / ratio of odds by a fixed time | Relative risk (risk ratio) / odds ratio |
| Distributions with a constant, rising or falling hazard | Exponential distribution, Weibull distribution |
Sources
- E. L. Kaplan, Paul Meier, Nonparametric Estimation from Incomplete Observations, Journal of the American Statistical Association (1958). The product-limit estimator.
- D. R. Cox, Regression Models and Life-Tables, Journal of the Royal Statistical Society: Series B, 34(2) (1972). The proportional hazards model.
- NIST/SEMATECH e-Handbook of Statistical Methods, 8.2.1.5 Kaplan-Meier. Kaplan-Meier for failure (reliability) data.
- Areas under the chi-square distribution are computed with the complementary error function approximation from Numerical Recipes (erfcc, relative error below 1.2×10⁻⁷). Checked against the known values χ² 3.84 → p 0.05 and 6.63 → p 0.01 for 1 degree of freedom.
← Risk, relative risk and odds ratioDiagnostic tests and the ROC curve →