Cox Proportional Hazards

Michael BrenndoerferOctober 26, 20263 min read
Machine Learning from ScratchAll chapters
Part 6 of 15Survival Analysis
Chapter 50Cox Proportional Hazards
Reading section 1 of 10 · Cox Proportional Hazards · 3 minSection 1 of 10 · 3 min

Section 1 of 10 · 3 min read

Cox Proportional HazardsSection view · Sections in this chapter1 / 10 ↓
Reading tools Definitions, links & notes

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Notes & comments

Kaplan-Meier and Nelson-Aalen summarize survival and cumulative hazard for a population or stratum. They can describe a mixture of people with different hazards when their censoring assumptions hold; they do not themselves specify how predictors change an individual's hazard. For equipment with different maintenance histories, a regression model lets us ask how the hazard is associated with those histories while retaining censored observations in the appropriate risk sets.

The Cox proportional hazards model, introduced by David Cox in 1972, is the standard regression model for censored outcomes. Its defining feature is simple. Each individual's hazard is written as a shared, unspecified baseline hazard h0(t)h_0(t) multiplied by an individual-specific factor exp⁡(β⊤x)\exp(\beta^\top x) that depends only on that individual's covariates. The covariate factor scales the hazard up or down by the same amount at every point in time, which is precisely the proportional-hazards assumption. Because the baseline hazard is left entirely unspecified, Cox's model is semiparametric: it makes a strong parametric claim about how covariates act, and no parametric claim about the shape of time.

The method's second insight is what makes it practical. Cox showed that β\beta can be estimated by maximizing a partial likelihood that uses only the order in which events occur and who was still at risk when they did. The unknown baseline h0(t)h_0(t) cancels at every event time, so we never have to specify it. That cancellation is the core idea of the chapter. We will derive it from first principles, build the fitting machinery from scratch with NumPy, and reconstruct the baseline and survival curves afterwards. Along the way, you will see how each formula translates into code and how to check the result against a mature library.

A hazard ratio is not a survival-probability ratio, and it is not an effect size on the probability scale. Even when hazards are strictly proportional, the ratio of survival probabilities at time tt depends on tt and on the baseline hazard itself. Holding this distinction straight is essential for correctly communicating results.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy