
Advanced Topic - Survival Analysis
Zhaoxia Yu
We have learned linear regression and logistic regression:
linear regression: when the response variable is a numerical variable.
logistic regression: when the response variable is a binary variable.
Today, we will introduce methods for time-to-event data.
Researchers are comparing two new cancer treatments.
The outcome of interest is survival time, measured in months after treatment begins.
At the end of the study, they record what happened to each patient.
Some patients died during the study, while others were still alive when the study ended.
Question: Which treatment appears to help patients survive longer?
| A: Time | A: Outcome | B: Time | B: Outcome |
|---|---|---|---|
| 5 | Died | 4 | Died |
| 6 | Died | 5 | Died |
| 8 | Died | 6 | Died |
| 20 | alive when study ended | 7 | Died |
| 20 | alive when study ended | 8 | Died |
| 20 | alive when study ended | 9 | Died |
All patients eventually died, so we know each patient’s survival time exactly.
| Time (months) | Patients Alive | Survival Probability |
|---|---|---|
| 0 | 6 | 1.00 |
| 4 | 5 | 5/6 = 0.833 |
| 5 | 4 | 4/6 = 0.667 |
| 6 | 3 | 3/6 = 0.500 |
| 7 | 2 | 2/6 = 0.333 |
| 8 | 1 | 1/6 = 0.167 |
| 9 | 0 | 0.000 |
The life table summarizes how many patients are still alive over time.
The survival probability is simply
\[\frac{\text{Patients Alive}}{\text{Total Patients}}.\]
We can visualize these probabilities using a Kaplan–Meier (KM) curve.
| Time (months) | Patients Alive | Survival Probability |
|---|---|---|
| 0 | 6 | 1.000 |
| 5 | 5 | 5/6 = 0.833 |
| 6 | 4 | 4/6 = 0.667 |
| 8 | 3 | 3/6 = 0.500 |
| 20+ | ? | ? |
The first three rows are easy because we know exactly when three patients died.
But what happens after 20 months?
We know the remaining three patients were still alive when the study ended, but we do not know their actual survival times.
Question: How should we continue the life table?
| Time | Patients Alive | Survival |
|---|---|---|
| 0 | 6 | 1.000 |
| 5 | 5 | 0.833 |
| 6 | 4 | 0.667 |
| 8 | 3 | 0.500 |
| 20+ | ? | ? |
The curve stays flat after month 6 because
The small marks on the curve indicate patients who were still alive when the study ended.
| Patient | Last observed time | What do we know? |
|---|---|---|
| A | 5 | Died at month 5 |
| B | 8 | Died at month 8 |
| C | 20 | Still alive when the study ended |
For Patient C,
This is called a right-censored observation.
# A tibble: 12 × 3
treatment time status
<chr> <dbl> <dbl>
1 A 5 1
2 A 6 1
3 A 8 1
4 A 20 0
5 A 20 0
6 A 20 0
7 B 4 1
8 B 5 1
9 B 6 1
10 B 7 1
11 B 8 1
12 B 9 1
The output in the next slide includes
These are the same quantities we used to construct the life table.
Call: survfit(formula = Surv(time, status) ~ treatment, data = survival_data)
treatment=A
time n.risk n.event survival std.err lower 95% CI upper 95% CI
5 6 1 0.833 0.152 0.583 1
6 5 1 0.667 0.192 0.379 1
8 4 1 0.500 0.204 0.225 1
treatment=B
time n.risk n.event survival std.err lower 95% CI upper 95% CI
4 6 1 0.833 0.152 0.5827 1.000
5 5 1 0.667 0.192 0.3786 1.000
6 4 1 0.500 0.204 0.2246 1.000
7 3 1 0.333 0.192 0.1075 1.000
8 2 1 0.167 0.152 0.0278 0.997
9 1 1 0.000 NaN NA NA
The log-rank test compares the two Kaplan–Meier curves.
Kaplan–Meier curves are useful for comparing survival between groups.
Suppose patients receiving Treatment A are much younger than those receiving Treatment B.
We need a regression model that can account for multiple variables at the same time.
Recall that
Cox proportional hazards regression models time until an event occurs.
Advantages:
The lung dataset contains survival information for patients with advanced lung cancer.
time: Survival time (days)status: Whether the patient died during the studyage: Age (years)sex: 1 = Male, 2 = FemaleCall:
coxph(formula = Surv(time, status == 2) ~ age + sex, data = lung)
n= 228, number of events= 165
coef exp(coef) se(coef) z Pr(>|z|)
age 0.017045 1.017191 0.009223 1.848 0.06459 .
sex -0.513219 0.598566 0.167458 -3.065 0.00218 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
exp(coef) exp(-coef) lower .95 upper .95
age 1.0172 0.9831 0.9990 1.0357
sex 0.5986 1.6707 0.4311 0.8311
Concordance= 0.603 (se = 0.025 )
Likelihood ratio test= 14.12 on 2 df, p=9e-04
Wald test = 13.47 on 2 df, p=0.001
Score (logrank) test = 13.72 on 2 df, p=0.001
| Predictor | Hazard Ratio | Interpretation |
|---|---|---|
| Age | 1.02 | Each additional year of age increases the risk of death by about 2%. |
| Female (vs. Male) | about 0.60 | Females have about 40% lower risk of death than males. |
Linear regression estimates changes in the mean.
Logistic regression estimates odds ratios.
Cox regression estimates hazard ratios.
