CS2 · explained

The Cox proportional hazards model, and what a hazard ratio means

The Cox model multiplies a baseline hazard by a factor that depends on who the life is, and never says what the baseline is. This page explains why that is a strength rather than a dodge, what the partial likelihood does, and how to read a fitted coefficient.

CS2 · Risk Modelling & Survival Analysis · 12 min read

After this page you can

Read a fitted Cox coefficient as a hazard ratio, compute a survival probability from a baseline, and evaluate a partial likelihood

The question the model answers

You have a block of lives and you want to know how much a characteristic matters. Does smoking double the force of mortality, or raise it by a tenth? Does being male rather than female matter more or less than being ten years older? Does the answer change with duration since the policy started?

You could fit a full parametric survival model separately to each group and compare. That needs enough data in every group to pin down a shape, and it answers a question you did not ask: you wanted one number for the effect of smoking, not two curves to eyeball.

The Cox model gives you that one number, and it does so while refusing to commit to any shape for the underlying hazard at all. That combination is why it is one of the most used statistical models anywhere, and why it is in CS2.

The model

For a life with covariates z = (z1, …, zp) — the measured characteristics, coded as numbers — the hazard at time t is

h(t; z) = h0(t) · exp(β1z1 + … + βpzp)

In words: everybody shares one hazard curve shape, and who you are only multiplies it up or down by a constant factor.

Two parts, doing two jobs.

h0(t), the baseline hazard, is the hazard for a life whose covariates are all zero. It can be any positive function of time whatever — rising, falling, bumpy. The model never specifies it, which is why the Cox model is called semi-parametric: parametric in the covariates, non-parametric in time.

exp(β′z), the relative risk, does not depend on t. This is the proportional hazards assumption and it is the entire content of the model. Whatever the baseline does, a smoker's hazard is the same multiple of it at every duration.

Why the exponential? Because a hazard must be positive, and exp of anything is positive. Writing the factor as 1 + β′z would let a hazard go negative for some covariate values, which is meaningless. The exponential also makes the coefficients add where the factors multiply, which is what makes them readable.

Reading a fitted coefficient

This is the part that is worth more marks than the fitting, and it is one line.

hazard ratio for a one-unit rise in zk = exp(βk)

Take the ratio of two lives' hazards and the baseline cancels, because it is the same function for both. All that survives is exp(β′(zA − zB)). So:

  • βk = 0 means a hazard ratio of 1 — the covariate does nothing.
  • βk > 0 means a ratio above 1 — higher values of the covariate are more dangerous.
  • βk < 0 means a ratio below 1 — protective.
  • Two covariates together multiply: exp(β1 + β2), not add.

The size is worth a feel. A coefficient of 0.1 is a 10.5% increase in hazard, 0.7 is roughly a doubling, and 1.0 is a factor of 2.72. Coefficients in fitted mortality models are often small; a coefficient of 3 should make you check the coding of the covariate before you believe it.

What a hazard ratio is not

It is not a ratio of survival probabilities, and it is not a difference in life expectancy. A hazard ratio of 2 does not halve anybody's survival probability; it squares it. That is the relation to carry:

S(t; z) = [S0(t)]exp(β′z)

which follows immediately from S = exp(−H) and the fact that multiplying the hazard by a constant multiplies the integrated hazard by the same constant. A baseline survival of 0.9 with a hazard ratio of 2 gives 0.92 = 0.81, not 0.45. Translating a hazard ratio into a survival probability by multiplying is the most common misreading of a fitted Cox model in practice as well as in exams.

The partial likelihood: how β is estimated without knowing h0

Here is the difficulty. You want to estimate β, but the full likelihood of the data involves h0(t), which is an unknown function rather than a handful of unknown numbers. Cox's answer is to ask a question whose answer does not involve the baseline at all.

At each observed death time, ask: given that exactly one of the lives at risk died at this instant, what is the probability it was the one who actually did? Under proportional hazards, that probability is each life's relative risk divided by the total relative risk in the risk set:

contribution at tj = exp(β′z(j)) / ∑i ∈ R(tj) exp(β′zi)

The baseline has cancelled, top and bottom, because it was the same for everybody present. Multiply these contributions across all the death times and you have the partial likelihood:

L(β) = ∏j exp(β′z(j)) / ∑i ∈ R(tj) exp(β′zi)

In words: the model is rewarded when the lives who actually died were the ones it thought were riskiest, out of those present at the time.

Three things follow, and they are the examinable consequences.

Only the order of the deaths matters, not the times. The times enter only through who is in each risk set. Double every observation time and the estimate of β does not move. That is a striking property and a useful check on whether you have understood the construction.

Censored lives contribute to denominators, never to numerators. Exactly as in Kaplan-Meier, and for the same reason: a life still being watched was at risk, and that is all the information it has.

There is no closed-form answer. The partial likelihood is maximised numerically. A question will ask you to write it down, to evaluate it, or to compare it at two candidate values — not to solve it by hand.

Testing the assumption, because it is an assumption

Proportional hazards is a real restriction and it is often false. The standard check is graphical: if hazards are proportional then

ln(−ln S(t; z)) = ln(−ln S0(t)) + β′z

so plotting ln(−ln Ŝ(t)) against time, or against ln t, for each group should give curves that are parallel — separated by a constant vertical gap, whatever shape they have. Curves that converge, cross or fan out say the hazard ratio is changing with time, and the model as written cannot represent that.

The usual repair is to put time into the model explicitly: fit separate baselines within strata, or add a covariate that is an interaction with time. Noticing that the assumption has failed, and saying what you would do about it, is worth more than fitting the model correctly to data it does not suit.

Questions students ask

If the model never estimates h0(t), how can it give a survival probability?

It cannot, on its own — and that is the honest answer. To get an absolute survival probability you need a baseline, which is estimated separately afterwards, usually by a Nelson-Aalen style calculation on the fitted model. The Cox fit alone gives you relative risk. A question that asks for a survival probability will supply the baseline, as the worked example below does.

Why "partial" likelihood?

Because it deliberately throws information away. It uses only who died in what order relative to who was at risk, and discards everything the actual times could have told you about the baseline. The trade is a good one: what is kept is exactly the part that bears on β, and what is discarded is exactly the part that would have required assuming a shape.

How are ties handled?

Awkwardly, which is why they have names. The exact treatment considers every order in which the tied deaths could have happened, which is expensive. Breslow's and Efron's approximations are what software uses, and they differ little unless ties are heavy relative to the risk set. For an exam, say that ties need an approximation and name one.

Is this the same as a generalised linear model?

No, though they rhyme. Both put a linear combination of covariates through a function, and both are fitted by maximising a likelihood. But a GLM models the mean of a response with a fully specified distribution, while the Cox model models a hazard and leaves its time shape unspecified. The partial likelihood is not a likelihood for any distribution of the data.

A worked example

Two parts. First a fit on a tiny data set, to see what the partial likelihood actually does; then an interpretation, which is where the marks usually are. Both data sets are invented for this example.

  1. Part one: a partial likelihood on five lives

    Five lives are observed, each with one covariate z, coded 1 for a smoker and 0 for a non-smoker. Times are in years.

    LifezTimeWhat happened
    A12died
    B04died
    C15censored
    D06died
    E07censored

    Three deaths, so three factors. The risk sets are everybody with a time at or after the death time: at t = 2 all five, at t = 4 the four lives B, C, D, E, and at t = 6 the two lives D and E.

  2. Evaluate at β = 0.5

    Each smoker weighs e0.5 = 1.6487213 and each non-smoker weighs 1.

    t = 2: denominator = 1.6487213(A) + 1(B) + 1.6487213(C) + 1(D) + 1(E) = 6.2974426
    factor = 1.6487213 / 6.2974426 = 0.2618081
    t = 4: denominator = 1(B) + 1.6487213(C) + 1(D) + 1(E) = 4.6487213
    factor = 1 / 4.6487213 = 0.2151129
    t = 6: denominator = 1(D) + 1(E) = 2.0000000
    factor = 1 / 2 = 0.5000000
    L(0.5) = 0.2618081 × 0.2151129 × 0.5 = 0.028159

    Note that life A appears in its own denominator, and that the censored lives C and E appear in denominators but never in a numerator.

  3. Compare with other values of β

    At β = 0 every weight is 1, the denominators are just the risk-set sizes 5, 4 and 2, and

    L(0) = (1/5)(1/4)(1/2) = 0.025000
    βL(β)
    0.000.025000
    0.250.026915
    0.500.028159
    0.750.028595
    1.000.028173
    1.250.026941
    1.500.025036

    The likelihood rises, peaks and falls, with the maximum at β̂ ≈ 0.75 — a hazard ratio of e0.75 = 2.12 for smoking. There is no formula that produces it; it is found numerically, and that is what every software package is doing.

    Read the table again and notice how flat the top is: L(0.75) and L(1.00) differ by about 1.5%, and even L(0.50) and L(1.50) are within about 12%. Three deaths cannot distinguish a hazard ratio of 2.1 from one of 2.7, which is the correct conclusion from five lives and a warning against quoting β̂ to three decimal places as though it meant something.

  4. Part two: reading a fitted model

    A Cox model has been fitted to a larger block of lives with two covariates, and has returned

    β̂smoker = 0.45     β̂male = 0.30

    The baseline five-year survival probability is S0(5) = 0.90. All three figures are invented.

  5. The hazard ratios

    smoking alone: e0.45 = 1.5683122
    being male alone: e0.30 = 1.3498588
    both: e0.45+0.30 = e0.75 = 2.1170000

    In words: smoking raises the force of mortality by about 57%, being male by about 35%, and a male smoker carries about 2.12 times the baseline force at every duration. Check the multiplication: 1.5683122 × 1.3498588 = 2.1170000. Ratios multiply, coefficients add, and the two statements agree to seven decimal places as they must.

  6. The five-year survival probability for a male smoker

    Route one, through the baseline survival probability:

    S(5) = 0.902.1170000 = exp(2.1170000 × ln 0.90) = exp(2.1170000 × (−0.1053605))
        = exp(−0.2230482) = 0.8000763

    Route two, through the integrated hazard, which is the same statement with the exponential unpacked:

    H0(5) = −ln 0.90 = 0.1053605
    H(5) = 2.1170000 × 0.1053605 = 0.2230482
    S(5) = exp(−0.2230482) = 0.8000763

    The same figure, because raising the survival function to a power and multiplying the integrated hazard by that power are the same operation written two ways.

  7. And the error worth not making

    A hazard ratio of 2.117 does not turn a survival probability of 0.90 into 0.90 / 2.117 = 0.425, and it does not turn a death probability of 0.10 into 0.2117 either — that second one happens to come out close, at 1 − 0.8001 = 0.1999 against 0.2117, and the closeness is exactly what makes it a trap. Over five years at light mortality the two are within a couple of percentage points; over thirty years, or at heavy mortality, they are not. The correct operation is always to raise the survival probability to the power of the hazard ratio.

  8. Sanity checks

    Every figure is where it should be. The hazard ratios are all above 1, because both coefficients are positive. The survival probability for the higher-risk life, 0.8001, is below the baseline 0.90, as a raised hazard requires.

    And it is a little below 0.902 = 0.81, which is the sharper check. Raising a number below 1 to a higher power makes it smaller, so a hazard ratio above 2 must give a survival probability below the square of the baseline. The ratio is 2.1170 and the answer is 0.8001 against 0.8100 — below, by the right margin. Had the answer come out above 0.81 with a hazard ratio above 2, the exponent would have been applied the wrong way round, and that is the error this check exists to catch.

Where this fits in CS2

This page explains one idea from CS2 Risk Modelling & Survival Analysis. The full CS2 syllabus, with what each part is examined on, sits on the course page, and past-paper style mock exams with full solutions are where you find out whether the idea has stuck under time pressure.

Other CS2 topics explained

Stuck on a term rather than the idea? The actuarial glossary defines the notation used above. If something here is wrong or unclear, tell us — these pages get corrected.