Lecture Notes · Lecture 8

Lecture 8 Notes — Survival Analysis

Learning outcomes: LO3, LO4 Companion files: slides L08, notebook Week8_Survival_Analysis.ipynb, data member_tenure.csv

1. Time-to-event questions

How long until a member cancels, a guest rebooks, a machine fails? Our synthetic data: 4,000 members observed for up to 24 months; 1,711 cancelled (the event) and 57.2% were still members when observation ended (censored).

2. Censoring

For a censored member we know only that tenure is at least the observed time. Ignoring this biases every average:

Method Estimate (months)
Mean tenure, everyone 8.9 (treats censored time as final)
Mean tenure, cancelled only 7.2 (drops the long-stayers)
Kaplan–Meier median 13.6

3. Kaplan–Meier estimator

At each event time t_i with d_i events and n_i members at risk:

S(t) = Π (1 − d_i / n_i) over event times up to t.

Censored members leave the risk set without causing a drop. Our hand-built estimator matches the lifelines library. Survival at 6, 12, 18 and 24 months: 77%, 54%, 40%, 27%; median 13.6 months.

4. Comparing groups

Premium members: median 19.5 months, 12-month retention 68%. Free members: median 11.2, retention 47%. The log-rank test gives p < 0.001 for plan and for acquisition channel.

5. Hazard

The hazard h(t) is the instantaneous risk of cancelling given you are still a member. Cumulative hazard H(t) and survival are linked by S(t) = exp(−H(t)). The cumulative hazard bends upward, so in this data risk rises with tenure (Weibull shape greater than 1).

6. Cox proportional-hazards model

h(t | x) = h₀(t) · exp(β₁x₁ + …). exp(β) is a hazard ratio.

Variable HR 95% CI
Premium 0.57 0.51–0.64
Social channel 1.46 1.32–1.62
Average rating given (per star) 0.62 0.59–0.66
Bookings in year 1 (each) 0.93 0.91–0.96

The concordance index is 0.64. The estimates recover the effects built into the synthetic data. The model assumes proportional hazards; a Schoenfeld-residual test gave a smallest p-value of 0.66, so there is no evidence against it. When violated, stratify or add time interactions.

7. Prediction and what-if

Predicted 12-month retention: at-risk free member 18%, typical free member 54%, engaged premium member 83%. Upgrading a typical member to premium raises 12-month retention from 54% to 71%. This assumes the effect is causal: confirm with an experiment before budgeting a campaign.

8. Spark

A life table needs only counts of events and at-risk members per period, which are aggregations. The Spark life table gave S(12) = 0.545 versus 0.544 from Kaplan–Meier (a small difference from handling of ties). Cox fitting is normally done on a sample or per segment.

9. Discussion questions

  1. Why is dropping censored members worse than keeping them with their observed time?
  2. A retention offer costs 5 units per member. How would you use the Cox model to decide whom to target?
  3. What would a crossing of two survival curves imply for the Cox model?

Next lecture: text and sentiment analytics.

← Back to all lectures