Survival Analysis

Predicting how long until something happens, when many cases have not happened yet.

🔴 advanced5 min readstatistics
Survival analysis predicts how long until something happens, like a customer cancelling or a machine failing. The tricky part is that, for many people in your data, the event has not happened yet when the study ends. You know they lasted at least this long, but not how long in total. That is called censoring, and ordinary regression gets it wrong. The Kaplan-Meier curve estimates the share still surviving over time, and the Cox model measures how each factor raises or lowers the risk.

What is Survival Analysis?

Traditional classification predicts IF an event happens (11 or 00).

Traditional regression predicts WHEN a continuous outcome happens.

Neither works when modeling Time-to-Event data (customer churn, medical patient survival, machine equipment failure):

Why? Because of Right Censoring.

  Patient A: Entered study ──► Experienced Relapse at Month 6 (Event Observed: t = 6, Event = 1)
  Patient B: Entered study ──► Study Ended at Month 12 (No Relapse Yet! Censored: t = 12, Event = 0)

For Patient B, we know they survived at least 12 months, but we do not know their true event time.

Dropping censored subjects causes severe selection bias. Treating 12 months as their true event time is false.

Survival Analysis incorporates both event times and censored observations cleanly.

┌──────────────────────────┬──────────────────────────┬──────────────────────────┐
│ 1. SURVIVAL FUNCTION S(t)│ 2. HAZARD RATE h(t)      │ 3. COX MODEL             │
├──────────────────────────┼──────────────────────────┼──────────────────────────┤
│ Probability of surviving │ Instantaneous event rate │ Semi-parametric model    │
│ past time t: P(T > t).   │ at time t given survival │ evaluating how features  │
│ Decreases over time.     │ up to time t.            │ scale hazard rates.      │
└──────────────────────────┴──────────────────────────┴──────────────────────────┘

Key Mathematical Functions

1. Survival Function S(t)S(t)

Probability that an individual survives longer than time tt:

S(t)=P(T>t)S(t) = P(T > t)

S(0)=1.0S(0) = 1.0, and S(t)S(t) decreases monotonically toward 0.00.0 over time.

2. Hazard Function h(t)h(t)

Instantaneous rate at which events occur at time tt, given survival up to time tt:

h(t)=lim⁡Δt→0P(t≤T<t+Δt∣T≥t)Δth(t) = \lim_{\Delta t \to 0} \frac{P(t \le T < t + \Delta t \mid T \ge t)}{\Delta t}

1. Kaplan-Meier Estimator (Non-Parametric)

The Kaplan-Meier Estimator estimates the survival curve S(t)S(t) from raw data containing censored records:

S^(t)=∏ti≤t(1−dini)\hat{S}(t) = \prod_{t_i \le t} \left( 1 - \frac{d_i}{n_i} \right)

Generates step-function survival curves comparing groups (e.g. Treatment A vs Treatment B).

2. Cox Proportional Hazards Model (Semi-Parametric)

Evaluates how feature covariates xx (age, contract type, dosage) scale risk:

h(t∣x)=h0(t)⋅exp⁡(β1x1+β2x2+⋯+βpxp)h(t \mid x) = h_0(t) \cdot \exp\left( \beta_1 x_1 + \beta_2 x_2 + \dots + \beta_p x_p \right)

If β1=0.5  ⟹  exp⁡(0.5)≈1.65\beta_1 = 0.5 \implies \exp(0.5) \approx 1.65 (Feature x1x_1 increases event hazard rate by 65 percent!).

Say this out loud

Survival Analysis models time to event outcomes while handling right censored observations. The Survival Function S(t) represents the probability of surviving past time t. Kaplan Meier provides non parametric survival curves. The Cox Proportional Hazards Model evaluates how covariate features scale baseline hazard rates exponentially, assuming hazard ratios between individuals stay constant over time.

Followups to expect

  1. What metric evaluates Survival Models? Concordance Index (C-Index), measuring the proportion of sample pairs where predicted risk orders match true event time orders (0.5 = random guessing, 1.0 = perfect prediction).
  2. What is DeepSurv? A deep neural network extension of the Cox model that replaces linear term βTx\beta^T x with non linear deep layers gθ(x)g_\theta(x) to capture non linear feature interactions.

Check yourself

Question 1 of 3

What is Right Censoring in Survival Analysis datasets?

More in Classical ML

See all →
Bias–Variance Tradeoff4 minOverfitting vs Underfitting3 minLinear Regression4 min