The Cox Proportional Hazards Model

Regression for survival times that leaves the baseline hazard unspecified. Derives Cox's partial likelihood as a product of conditional probabilities of who fails at each event time, and again as the profile likelihood of a model whose baseline hazard is left free, which also yields Breslow's estimator of the cumulative baseline hazard; proves the score, the information and the concavity of the log partial likelihood; derives the likelihoods for tied times (exact discrete, Breslow, Efron); proves that the score test at zero is the log-rank test, with the hypergeometric variance under the exact likelihood; derives the score test of proportional hazards from a time-varying coefficient, with Schoenfeld residuals and log-minus-log curves; and proves that omitting an independent covariate pulls the marginal hazard ratio away from the conditional one (below it when the conditional ratio exceeds 1), even in a randomized comparison, with an example in which it crosses 1. Worked on 4,114 adults of NHANES 1999 to 2000 followed for mortality to 2019, by smoking, diabetes, age and sex. Worked problems on a six-subject dataset solved by hand under three treatments of ties, a combined hazard ratio with its interval, and a marginal hazard computed exactly.

Of 4,114 adults aged 20 to 84 who were examined in the National Health and Nutrition Examination Survey (NHANES) of 1999 to 2000 (National Center for Health Statistics, 2002), 1,240 had died by the end of 2019, according to the linkage of the survey to the National Death Index (National Center for Health Statistics, 2022). At the examination 865 of them smoked cigarettes, 1,081 had smoked and quit, and 2,168 had never smoked; 416 had been told by a doctor that they had diabetes. Of the current smokers 31.3% died, against 24.2% of the never smokers; but 41.2% of the former smokers died, and they were on average 56.6 years old at the examination, against 44.3 for current smokers. Men made up 57.3% of current and 60.4% of former smokers, against 36.7% of never smokers. How can the effect of smoking on the risk of death be measured, holding age, sex and diabetes fixed, without first deciding how the risk of death of an adult changes over twenty years of follow-up?

Cox (1972) answered with a model in which the covariates multiply the hazard by a fixed factor and the hazard's shape over time is left entirely free. The Cox proportional hazards model says that a person with covariates $\mathbf{x}$ has hazard

$$h(t \mid \mathbf{x}) = h_0(t)\exp(\mathbf{x}^{\mathsf T}\boldsymbol\beta),$$

where $h_0$ is an unspecified baseline hazard, the hazard of a person with $\mathbf{x} = \mathbf{0}$, and $\boldsymbol\beta$ is a vector of coefficients. The hazard, the survival function and the cumulative hazard are defined, and their relations proved, in Censoring, Survival Functions and Hazards; this article uses that article's notation and its likelihood of censored data.

First we say what the model claims and what a hazard ratio means. Then we derive the partial likelihood twice: as a product of conditional probabilities of who fails, and as the profile likelihood when the baseline hazard is left free, which also gives Breslow's estimator of the baseline. Next come the score, the information and the treatment of tied times, the proof that the score test at zero is the log-rank test, and the large-sample theory, which is cited. Then we fit the NHANES cohort, estimate survival curves, check the proportional hazards assumption and change the time scale. Finally we prove a property that surprises many users: leaving out a covariate that is independent of the treatment changes the hazard ratio, even in a randomized trial. The article assumes Maximum Likelihood Estimation and The Likelihood Ratio, Wald and Score Tests, and it is part of Survival Analysis.

The model and what a hazard ratio says

Write $T$ for the survival time and $\mathbf{x} = (x_1, \ldots, x_p)^{\mathsf T}$ for covariates measured at the start of follow-up. The model has two parts. The baseline hazard $h_0(t) \ge 0$ may be any function of time. The covariates act through the risk score $r(\mathbf{x}) = \exp(\mathbf{x}^{\mathsf T}\boldsymbol\beta)$, which does not depend on time. Two people with covariates $\mathbf{x}$ and $\mathbf{x}'$ have the hazard ratio

$$\frac{h(t \mid \mathbf{x})}{h(t \mid \mathbf{x}')} = \exp\{(\mathbf{x} - \mathbf{x}')^{\mathsf T}\boldsymbol\beta\},$$

the same at every time $t$. That constancy is the proportional hazards assumption. For a covariate that is an indicator, such as current smoking, $e^{\beta_j}$ is the hazard ratio between people who differ only in that covariate. For a measured covariate such as age in decades, $e^{\beta_j}$ is the ratio for a difference of one unit.

What does a hazard ratio say about survival? The cumulative hazard is $H(t \mid \mathbf{x}) = \int_0^t h(u \mid \mathbf{x})\,du = H_0(t)\,r(\mathbf{x})$, with $H_0(t) = \int_0^t h_0(u)\,du$. For a continuous survival time, $S = \exp(-H)$ (Censoring, Survival Functions and Hazards, Theorem 1). Hence

$$S(t \mid \mathbf{x}) = \exp\{-H_0(t)\,r(\mathbf{x})\} = S_0(t)^{\exp(\mathbf{x}^{\mathsf T}\boldsymbol\beta)},$$

where $S_0 = \exp(-H_0)$ is the baseline survival function. The survival curves of the model are powers of one curve. They never cross, and the hazard ratio fixes the exponent but not the curve.

Example (a hazard ratio is not a risk ratio). The fitted model below gives a man aged 60 without diabetes who has never smoked a probability 0.124 of dying within ten years, and the same man who smokes 0.260, with a hazard ratio of 2.27 for current smoking. The ratio of the two risks is 2.09, not 2.27. Since $1 - S_0^{\,c}$ is concave in $c$ and equals zero at $c = 0$, a risk multiplied by the hazard ratio overstates the risk of the higher-hazard person, and the gap grows as the risks grow. The two ratios agree only when the risks are small, where $1 - S_0^c \approx c\,H_0$.

The partial likelihood

The model has a parameter of interest, $\boldsymbol\beta$, and a nuisance that is a whole function, $h_0$. The idea of the partial likelihood is to condition on everything that carries information about $h_0$ and little about $\boldsymbol\beta$: the times at which failures occur. What remains is the identity of the person who fails at each such time, and its probability does not involve $h_0$ at all.

The data are $(y_i, \delta_i, \mathbf{x}_i)$ for $i = 1, \ldots, n$: the observed time $y_i = \min(T_i, C_i)$, the event indicator $\delta_i = \mathbf{1}\{T_i \le C_i\}$ and the covariates. Survival times are independent between people, and censoring is independent given the covariates ($T_i \perp\!\!\!\perp C_i \mid \mathbf{x}_i$), as defined in Censoring, Survival Functions and Hazards. The distinct event times are $t_{(1)} < \cdots < t_{(k)}$ and the risk set at time $t$ is $R(t) = \{i : y_i \ge t\}$, the people still under observation just before $t$. Write $r_i = \exp(\mathbf{x}_i^{\mathsf T}\boldsymbol\beta)$.

Theorem 1 (the partial likelihood). Suppose the baseline hazard is continuous and no two events occur at the same time, and let $(j)$ denote the person who fails at $t_{(j)}$. Given the history of failures and censorings before $t_{(j)}$, and given that exactly one person fails at $t_{(j)}$, the probability that it is person $(j)$ is

$$\frac{h(t_{(j)} \mid \mathbf{x}_{(j)})}{\sum_{l \in R(t_{(j)})} h(t_{(j)} \mid \mathbf{x}_l)} = \frac{r_{(j)}}{\sum_{l \in R(t_{(j)})} r_l}.$$

The product of these probabilities over the event times is Cox's partial likelihood,

$$L_P(\boldsymbol\beta) = \prod_{j=1}^k \frac{\exp(\mathbf{x}_{(j)}^{\mathsf T}\boldsymbol\beta)}{\sum_{l \in R(t_{(j)})} \exp(\mathbf{x}_l^{\mathsf T}\boldsymbol\beta)}.$$

Proof. Fix $j$, write $t = t_{(j)}$ and $R = R(t)$, and consider the short interval $[t, t + \Delta)$. The history before $t$ determines $R$. By the definition of the hazard, a person $l \in R$ fails in the interval with probability $h(t \mid \mathbf{x}_l)\Delta + o(\Delta)$, given survival to $t$. Independent censoring means that censoring events in the interval do not change these probabilities. Different people are independent. So the probability that person $i$ fails in the interval and no one else in $R$ does is

$$h(t \mid \mathbf{x}_i)\Delta \prod_{l \in R,\, l \ne i}\{1 - h(t \mid \mathbf{x}_l)\Delta\} + o(\Delta) = h(t \mid \mathbf{x}_i)\Delta + o(\Delta),$$

and the probability that exactly one person fails is the sum of these over $i \in R$. Dividing, and letting $\Delta \to 0$, the conditional probability that the one failure is person $i$ is $h(t \mid \mathbf{x}_i)/\sum_{l \in R} h(t \mid \mathbf{x}_l)$. Substituting $h(t \mid \mathbf{x}) = h_0(t)r(\mathbf{x})$, the factor $h_0(t)$ cancels between numerator and denominator. Multiplying over $j$ gives $L_P$. $\square$

Two things are discarded. The times of the failures themselves, given the history, carry information about $h_0$ and only indirectly about $\boldsymbol\beta$. The censored people contribute only through their membership in risk sets. Cox (1972) obtained this likelihood as a conditional likelihood, and Cox (1975) defined partial likelihood in general and showed, in the words of his abstract, "that the usual large-sample properties of maximum likelihood estimates and tests apply when partial likelihood is used". The rigorous form of that statement for the Cox model is cited below.

The censored people need independent censoring for Theorem 1. If people left the study because they were about to die, the risk set just before $t$ would be missing exactly the people whose hazard was highest, and the conditional probability would no longer be the ratio of risk scores.

The partial likelihood as a profile likelihood

Is the partial likelihood a likelihood at all? A second derivation answers yes, for a model in which the baseline is allowed to be anything, including a step function. The plan is to write the full likelihood of $(\boldsymbol\beta, H_0)$, maximize over $H_0$ for fixed $\boldsymbol\beta$, and substitute. The maximizing $H_0$ is Breslow's estimator, and what is left is $L_P$.

The likelihood of censored data with a continuous baseline is $\prod_i h(y_i \mid \mathbf{x}_i)^{\delta_i}S(y_i \mid \mathbf{x}_i)$, by Censoring, Survival Functions and Hazards, section "The likelihood of censored data" (the censoring distribution's factor does not involve the parameters and is dropped). With proportional hazards this is

$$\prod_{i=1}^n \{h_0(y_i)\,r_i\}^{\delta_i}\exp\{-r_i H_0(y_i)\}.$$

Maximizing over a continuous $h_0$ fails: a baseline with a tall narrow spike at each event time makes the likelihood as large as we please. The remedy, due to Johansen (1983), is to let $H_0$ be any nondecreasing function with $H_0(0) = 0$, possibly with jumps, and to replace the density factor $h_0(y_i)$ by the jump $\Delta H_0(y_i) = H_0(y_i) - H_0(y_i^-)$. The extended likelihood is

$$L(\boldsymbol\beta, H_0) = \prod_{i=1}^n \{r_i\,\Delta H_0(y_i)\}^{\delta_i}\exp\{-r_i H_0(y_i)\}.$$

Johansen's abstract states that in this model the maximum likelihood estimators of the parameters are Cox's estimate and a Nelson–Aalen-type estimate of the measure, and that the partial likelihood "becomes a partially maximized likelihood". We prove it for the form above, allowing ties.

Theorem 2 (the profile likelihood and Breslow's estimator). Fix $\boldsymbol\beta$. Among all nondecreasing $H_0$ with $H_0(0) = 0$, the extended likelihood is maximized by the step function with jumps only at the event times,

$$\hat H_0(t; \boldsymbol\beta) = \sum_{j :\, t_{(j)} \le t} \frac{d_j}{\sum_{l \in R(t_{(j)})} r_l},$$

where $d_j$ is the number of events at $t_{(j)}$. The maximized value is

$$\max_{H_0} L(\boldsymbol\beta, H_0) = e^{-D}\prod_{j=1}^k d_j^{\,d_j} \times \prod_{j=1}^k \frac{\prod_{i \in D_j} r_i}{\left(\sum_{l \in R(t_{(j)})} r_l\right)^{d_j}},$$

where $D_j$ is the set of people who fail at $t_{(j)}$ and $D = \sum_j d_j$. With no ties ($d_j = 1$) the second product is Cox's $L_P(\boldsymbol\beta)$ and the first factor is the constant $e^{-D}$.

Proof. If $\Delta H_0(t_{(j)}) = 0$ at some event time, every person failing there contributes the factor 0, so a maximizer has a jump $\alpha_j > 0$ at each $t_{(j)}$. Any other increase of $H_0$, at a time that is not an event time or spread continuously, adds nothing to the factors $\Delta H_0(y_i)^{\delta_i}$ and can only increase some $H_0(y_i)$, which lowers $\exp\{-r_iH_0(y_i)\}$. Removing it does not decrease the likelihood, so we may take $H_0$ to be the step function with jumps $\alpha_1, \ldots, \alpha_k$. Then $H_0(y_i) = \sum_{j :\, t_{(j)} \le y_i}\alpha_j$, and the log-likelihood is

$$\sum_i \delta_i\,\mathbf{x}_i^{\mathsf T}\boldsymbol\beta + \sum_{j=1}^k d_j\ln\alpha_j - \sum_i r_i\sum_{j :\, t_{(j)} \le y_i}\alpha_j = \sum_i \delta_i\,\mathbf{x}_i^{\mathsf T}\boldsymbol\beta + \sum_{j=1}^k\left\{d_j\ln\alpha_j - \alpha_j\sum_{l \in R(t_{(j)})} r_l\right\}.$$

The rearrangement uses that person $l$ is counted in the jump at $t_{(j)}$ exactly when $y_l \ge t_{(j)}$, that is when $l \in R(t_{(j)})$. Each term in braces is a strictly concave function of $\alpha_j > 0$ alone, maximized where its derivative $d_j/\alpha_j - \sum_{R(t_{(j)})} r_l$ vanishes, at $\hat\alpha_j = d_j/\sum_{l \in R(t_{(j)})} r_l$. Substituting gives $d_j\ln d_j - d_j\ln\sum_{R(t_{(j)})}r_l - d_j$ for term $j$, and exponentiating gives the stated maximum. $\square$

The estimator $\hat H_0(t) = \hat H_0(t; \hat{\boldsymbol\beta})$ is Breslow's estimator of the cumulative baseline hazard, a Nelson cumulative hazard estimator with each person weighted by the risk score, which goes by combinations of the names Nelson, Aalen and Breslow (Therneau, 2024, vignette "Software validation"). At $\boldsymbol\beta = \mathbf{0}$ every $r_l = 1$ and it reduces to the Nelson–Aalen estimator $\sum_{t_{(j)} \le t} d_j/n_j$ of The Kaplan–Meier Estimator. The script checks that identity on the cohort. Theorem 2 also shows where the factor $(\sum r_l)^{d_j}$ for tied deaths comes from: it is the profile likelihood's own treatment of ties, the Breslow likelihood below.

Score, information and the estimating equation

The log partial likelihood is a sum of log-ratios, and its derivatives have a statistical reading: observed covariates minus their expected values. Here is the result, written with ties handled as in Theorem 2 (the Breslow form), which covers the no-ties case.

For each event time define the weights $w_l(t; \boldsymbol\beta) = r_l/\sum_{m \in R(t)} r_m$ on the risk set, the weighted mean

$$\bar{\mathbf{x}}(t; \boldsymbol\beta) = \sum_{l \in R(t)} w_l(t; \boldsymbol\beta)\,\mathbf{x}_l,$$

and the weighted covariance matrix $V(t; \boldsymbol\beta) = \sum_{l \in R(t)} w_l\,(\mathbf{x}_l - \bar{\mathbf{x}})(\mathbf{x}_l - \bar{\mathbf{x}})^{\mathsf T}$. If one person in the risk set is drawn with probabilities $w_l$, these are the mean and covariance of the covariates of the person drawn.

Proposition 1 (score and information). The log partial likelihood $\ell_P(\boldsymbol\beta) = \sum_j \left\{\sum_{i \in D_j}\mathbf{x}_i^{\mathsf T}\boldsymbol\beta - d_j\ln\sum_{l \in R(t_{(j)})} r_l\right\}$ has gradient and negative Hessian

$$\mathbf{U}(\boldsymbol\beta) = \sum_{j=1}^k\left\{\sum_{i \in D_j}\mathbf{x}_i - d_j\,\bar{\mathbf{x}}(t_{(j)}; \boldsymbol\beta)\right\}, \qquad \mathcal{I}(\boldsymbol\beta) = \sum_{j=1}^k d_j\,V(t_{(j)}; \boldsymbol\beta).$$

The information $\mathcal{I}(\boldsymbol\beta)$ is positive semidefinite for every $\boldsymbol\beta$, so $\ell_P$ is concave. If for every nonzero vector $\mathbf{a}$ some risk set at an event time contains two people with different values of $\mathbf{a}^{\mathsf T}\mathbf{x}$, then $\ell_P$ is strictly concave, and it has at most one maximizer.

Proof. The derivative of $\ln\sum_l r_l$ is $\sum_l r_l\mathbf{x}_l/\sum_m r_m = \bar{\mathbf{x}}$, since $\partial r_l/\partial\boldsymbol\beta = r_l\mathbf{x}_l$. That gives $\mathbf{U}$. Differentiating $\bar{\mathbf{x}} = \sum_l r_l\mathbf{x}_l/\sum_m r_m$ by the quotient rule gives $\sum_l w_l\mathbf{x}_l\mathbf{x}_l^{\mathsf T} - \bar{\mathbf{x}}\bar{\mathbf{x}}^{\mathsf T} = V$, so the Hessian is $-\sum_j d_jV(t_{(j)})$. For any $\mathbf{a}$, $\mathbf{a}^{\mathsf T}V\mathbf{a} = \sum_l w_l(\mathbf{a}^{\mathsf T}\mathbf{x}_l - \mathbf{a}^{\mathsf T}\bar{\mathbf{x}})^2 \ge 0$, a weighted variance. It is positive when the risk set contains two people with different $\mathbf{a}^{\mathsf T}\mathbf{x}$, because all weights are positive. Under the stated condition $\mathbf{a}^{\mathsf T}\mathcal{I}\mathbf{a} > 0$ for every $\mathbf{a} \ne \mathbf{0}$, and a strictly concave function has at most one maximizer. $\square$

The estimating equation $\mathbf{U}(\hat{\boldsymbol\beta}) = \mathbf{0}$ says that, summed over the event times, the covariates of the people who failed equal the covariates expected of a person drawn from the risk set with probabilities proportional to their risk scores. It is solved by Newton–Raphson, $\boldsymbol\beta \leftarrow \boldsymbol\beta + \mathcal{I}(\boldsymbol\beta)^{-1}\mathbf{U}(\boldsymbol\beta)$, which concavity makes reliable. On the cohort it converged from zero in 6 iterations.

At most one maximizer is not the same as one. If one value of a covariate is associated with every failure that could tell the groups apart, the likelihood keeps rising as a coefficient goes to infinity. This monotone likelihood happens in small samples and with rare categories; Problem 2 shows a case.

Tied times

The NHANES times are whole months of follow-up, from the examination to death or to 31 December 2019. Death times are continuous, but recorded this way the 1,240 deaths fall on only 243 distinct months, with up to 16 deaths in one month. Theorem 1 assumed no ties. Three likelihoods are in use for tied times, and the plain-words difference is in how the $d$ tied people are imagined to be chosen from the risk set: all at once, one at a time with replacement, or one at a time with an averaged correction.

Exact discrete likelihood. Suppose time is genuinely discrete, and at each time the conditional odds of failure are proportional: $h_j(\mathbf{x})/\{1 - h_j(\mathbf{x})\} = e^{\alpha_j}\exp(\mathbf{x}^{\mathsf T}\boldsymbol\beta)$, where $h_j(\mathbf{x})$ is the probability of failing at $t_{(j)}$ given survival to it. SAS's documentation calls this the discrete logistic model (SAS Institute, TIES= option).

Proposition 2 (the exact discrete likelihood). Under the discrete logistic model, given the risk set $R$ at $t_{(j)}$ and that $d_j$ of its members fail there, the probability that the failures are exactly the set $D_j$ is

$$\frac{\prod_{i \in D_j} r_i}{\sum_{S \subseteq R,\ |S| = d_j}\ \prod_{i \in S} r_i}.$$

Proof. Members of the risk set fail independently, person $l$ with probability $h_j(\mathbf{x}_l)$. The probability that exactly the set $S$ fails is $\prod_{i \in S}h_j(\mathbf{x}_i)\prod_{l \in R \setminus S}\{1 - h_j(\mathbf{x}_l)\} = \prod_{l \in R}\{1 - h_j(\mathbf{x}_l)\}\prod_{i \in S}e^{\alpha_j}r_i$, since $h/(1 - h) = e^{\alpha_j}r$. Conditioning on $|S| = d_j$ divides by the sum of these over all sets of size $d_j$. The factor $\prod_{l \in R}\{1 - h_j(\mathbf{x}_l)\}\,e^{d_j\alpha_j}$ is common to every term and cancels. $\square$

The denominator is the elementary symmetric polynomial of degree $d_j$ in the risk scores. It has $\binom{n_j}{d_j}$ terms, but the recursion of Gail, Lubin and Rubinstein (1981), adding one member of the risk set at a time, computes it in about $n_j d_j$ steps; the script uses it. With one failure per time the expression is Theorem 1's ratio.

Breslow's likelihood replaces the denominator by $(\sum_{l \in R} r_l)^{d_j}$, the probability of drawing the $d_j$ failures, in a given order, one at a time with replacement from the whole risk set (the probability of the set in any order is $d_j!$ times larger, a constant that does not affect inference). Theorem 2 produced exactly this form. It is the default in SAS, which attributes it to Breslow (1974).

Efron's likelihood (Efron, 1977) draws without replacement, but since the order of the tied failures is unknown, each failure removes on average a fraction of every tied person's risk score:

$$\prod_{i \in D_j} r_i \Big/ \prod_{m=0}^{d_j - 1}\left\{\sum_{l \in R} r_l - \frac{m}{d_j}\sum_{i \in D_j} r_i\right\}.$$

It is the default in R's survival package (Therneau, 2024, help page of coxph). Kalbfleisch and Prentice (1973) obtained a different exact likelihood for continuous times recorded with ties, a marginal likelihood that averages over the orders in which the tied failures could have occurred; SAS's EXACT option computes it. For grouped continuous times that is the target, and the discrete likelihood of Proposition 2 estimates a log odds ratio of the discrete hazard rather than a log hazard ratio. The two nearly coincide when the hazard in each interval is small, as it is here, with monthly death probabilities well under 1%.

On the cohort the choice hardly matters. With the model of the next sections (age, sex, smoking and diabetes), the Breslow coefficients are 0.885, 0.266, 0.819, 0.109 and 0.622, the Efron coefficients 0.887, 0.267, 0.820, 0.109 and 0.623, and the exact discrete coefficients 0.889, 0.268, 0.823, 0.109 and 0.625. The largest difference from Efron is 0.0015 for Breslow and 0.0034 for the exact likelihood, a small fraction of every standard error. With heavy ties the methods separate. On the six-subject data of Problems 1 and 2 they give 1.4753, 1.6769 and no finite estimate. On the rat carcinogen data of the SAS documentation (40 rats, two groups, several tied deaths), the script reproduces SAS's Breslow estimate −0.59590 with standard error 0.34840, and R's Efron and exact estimates −0.56864 and −0.62949.

The score test at zero is the log-rank test

At $\boldsymbol\beta = \mathbf{0}$ every risk score is 1 and the weighted mean of a risk set is its plain mean. The score at zero is then the observed sum of covariates of the people who fail minus the sum expected if failures were chosen at random from the risk set. For a group indicator this is observed minus expected deaths, the numerator of the log-rank test of The Log-Rank Test. The variance is what decides which tie method reproduces the log-rank test exactly.

Theorem 3 (the score test at zero is the log-rank test). Let $x$ be a single covariate, let $n_j$ be the size of the risk set at $t_{(j)}$, $\bar x_j$ the plain mean of $x$ over it and $\sigma_j^2 = n_j^{-1}\sum_{l \in R(t_{(j)})}(x_l - \bar x_j)^2$ its variance with divisor $n_j$. Under the exact discrete likelihood,

$$U(0) = \sum_{j=1}^k\left(\sum_{i \in D_j} x_i - d_j\bar x_j\right), \qquad \mathcal{I}(0) = \sum_{j=1}^k d_j\,\frac{n_j - d_j}{n_j - 1}\,\sigma_j^2,$$

with the convention that a term with $n_j = 1$ is zero. Under Breslow's likelihood $U(0)$ is the same and $\mathcal{I}(0) = \sum_j d_j\sigma_j^2$. If $x$ is the indicator of group 1, with $n_{1j}$ members of group 1 at risk, $n_{0j} = n_j - n_{1j}$, and $d_{1j}$ failures in group 1 at $t_{(j)}$, then $U(0) = O - E$ with $O = \sum_j d_{1j}$ and $E = \sum_j d_jn_{1j}/n_j$, and the exact-likelihood score statistic $U(0)^2/\mathcal{I}(0)$ is the log-rank statistic $(O - E)^2/V$ with the hypergeometric variance

$$V = \sum_{j=1}^k \frac{n_{1j}\,n_{0j}\,d_j\,(n_j - d_j)}{n_j^2\,(n_j - 1)}.$$

Proof. Take one event time and drop the index $j$. Write $x_S = \sum_{i \in S}x_i$ for a set $S$. The log of the factor in Proposition 2 is $\beta x_{D} - \ln\sum_{|S| = d}e^{\beta x_S}$. Its derivative in $\beta$ is $x_D - \sum_S x_Se^{\beta x_S}/\sum_S e^{\beta x_S} = x_D - E_\beta[x_{\mathcal S}]$, where $\mathcal S$ is a random set of size $d$ chosen with probability proportional to $e^{\beta x_S}$. Differentiating again, as in Proposition 1, the negative second derivative is $\operatorname{Var}_\beta(x_{\mathcal S})$. At $\beta = 0$ every set of size $d$ is equally likely, so $\mathcal S$ is a simple random sample of $d$ of the $n$ people at risk, drawn without replacement.

Write $Z_l = \mathbf{1}\{l \in \mathcal S\}$, so $x_{\mathcal S} = \sum_l x_lZ_l$. Each person is in the sample with probability $d/n$, so $E[x_{\mathcal S}] = d\bar x$. Two different people are both in it with probability $d(d-1)/\{n(n-1)\}$. Hence $\operatorname{Var}(Z_l) = d(n-d)/n^2$ and, for $l \ne m$, $\operatorname{Cov}(Z_l, Z_m) = d(d-1)/\{n(n-1)\} - d^2/n^2 = -d(n-d)/\{n^2(n-1)\}$. Then

$$\operatorname{Var}(x_{\mathcal S}) = \frac{d(n-d)}{n^2}\sum_l x_l^2 - \frac{d(n-d)}{n^2(n-1)}\left\{\Big(\sum_l x_l\Big)^2 - \sum_l x_l^2\right\} = \frac{d(n-d)}{n(n-1)}\sum_l x_l^2 - \frac{d(n-d)}{n^2(n-1)}\Big(\sum_l x_l\Big)^2,$$

which is $d\,\frac{n-d}{n-1}\,\sigma^2$. Summing over event times gives $U(0)$ and $\mathcal{I}(0)$. For Breslow's likelihood, Proposition 1 at $\beta = 0$ gives the same $U(0)$, since $\bar x(t; 0)$ is the plain mean, and $\mathcal{I}(0) = \sum_j d_j\sigma_j^2$, since $V(t; 0)$ is the plain variance $\sigma^2$. For an indicator, $\sum_{i \in D_j}x_i = d_{1j}$, $\bar x_j = n_{1j}/n_j$ and $\sigma_j^2 = (n_{1j}/n_j)(1 - n_{1j}/n_j) = n_{1j}n_{0j}/n_j^2$, which turns the two formulas into $O - E$ and $V$. $\square$

Without ties, $d_j = 1$ and the two variances agree, so with continuous times both likelihoods give the log-rank test. For a vector of covariates, apply the theorem to the single covariate $\mathbf{a}^{\mathsf T}\mathbf{x}$ for each fixed vector $\mathbf{a}$: it gives $\mathbf{a}^{\mathsf T}\mathbf{U}(\mathbf{0})$ and $\mathbf{a}^{\mathsf T}\mathcal{I}(\mathbf{0})\mathbf{a}$, and since a symmetric matrix is determined by its quadratic form, $\mathcal{I}(\mathbf{0}) = \sum_j d_j\frac{n_j - d_j}{n_j - 1}\Sigma_j$, with $\Sigma_j$ the covariance matrix (divisor $n_j$) of $\mathbf{x}$ over the risk set. For indicators of $K - 1$ of $K$ groups this is the covariance of the $K$-sample log-rank test. The Log-Rank Test derives the test from its own starting point, a sequence of two-by-two tables.

Efron's likelihood is not covered. At $\beta = 0$ its $m$-th factor uses the mean of the risk set with the tied failures partly removed, so $U(0)$ depends on which people tied and differs from $O - E$. On the data of Problem 3 it is $13/12$ against $O - E = 1$.

On the cohort, with diabetes as the group, 273 people with diabetes died against 92.05 expected, so $O - E = 180.95$. The hypergeometric variance is 84.83 and the log-rank statistic 385.97, equal to the exact-likelihood score statistic to rounding error, as the script asserts; R's survdiff prints 385.9684. Breslow's variance is 84.96, giving 385.39. Efron's score is 181.08 and its score statistic 386.47. With up to 16 deaths among about 4,000 people at risk, the factor $(n_j - d_j)/(n_j - 1)$ is within half a percent of 1, and all three tests agree that people with diabetes died at a higher rate.

Large-sample theory

The theorems of Asymptotics of the Maximum Likelihood Estimator assume independent, identically distributed observations, and the partial likelihood is not a product of independent terms: the risk sets share people. Its large-sample theory needed new tools.

Tsiatis (1981) established, as his abstract states, strong consistency and asymptotic normality of the maximum partial likelihood estimate, and the asymptotic normality of the estimators of the cumulative hazard and survival function, with their limiting variances. Andersen and Gill (1982) recast the model for counting processes, which "permits a statistical regression analysis of the intensity of a recurrent event allowing for complicated censoring patterns and time dependent covariates", and gave proofs "using martingale techniques for the asymptotic properties of the estimators" (abstract). The conclusion used here, under their conditions: $\hat{\boldsymbol\beta}$ is approximately normal with mean $\boldsymbol\beta$ and covariance matrix $\mathcal{I}(\hat{\boldsymbol\beta})^{-1}$, so that the partial likelihood behaves as an ordinary likelihood. The Wald, likelihood ratio and score tests of The Likelihood Ratio, Wald and Score Tests then apply with $\ell_P$ in place of $\ell$, and a 95% interval for a hazard ratio is $\exp(\hat\beta_j \pm 1.96\,\widehat{\mathrm{SE}}_j)$, with the standard error from $\mathcal{I}(\hat{\boldsymbol\beta})^{-1}$.

How much is lost by ignoring the information about $\boldsymbol\beta$ in the failure times? Efron (1977) showed by an information calculation that Cox's method "has full asymptotic efficiency under conditions which are likely to be satisfied in many realistic situations" (abstract). When the model is wrong, $\hat{\boldsymbol\beta}$ still converges, to a value defined by the limit of the estimating equation (Struthers and Kalbfleisch, 1986), and Lin and Wei (1989) gave a robust "sandwich" covariance estimate for that case. The last section uses the first of these facts.

The cohort, fitted

Back to the 4,114 adults. Age is in decades from 60, so the baseline is a woman aged 60 who has never smoked and has no diagnosed diabetes. Time is months since the examination. The fit uses Efron's likelihood. Of the 1,945 men and 2,169 women, 1,240 died; follow-up of the survivors ran to a median of 239 months, and to 249 months at most.

Covariate $\hat\beta$ SE Hazard ratio 95% interval
Age, per 10 years 0.887 0.024 2.43 2.32 to 2.54
Male 0.267 0.059 1.31 1.16 to 1.47
Current smoker 0.820 0.078 2.27 1.95 to 2.64
Former smoker 0.109 0.067 1.12 0.98 to 1.27
Diabetes 0.623 0.069 1.86 1.63 to 2.13

The log partial likelihood rose from $\ell_P(\mathbf{0}) = -10{,}082.69$ to $\ell_P(\hat{\boldsymbol\beta}) = -8{,}984.29$. The likelihood ratio statistic for all five coefficients is 2,196.8, the Wald statistic 1,566.8 and the score statistic 2,109.5, each on 5 degrees of freedom. The coefficients and log-likelihoods of all three tie methods, and the standard errors of this fit, agree with R's coxph (survival 3.8-3) to the ten significant digits compared.

Read as hazard ratios: at any time during follow-up, among people of the same age, sex and diabetes status, current smokers died at 2.27 times the rate of never smokers. Each decade of age multiplied the death rate by 2.43. Diabetes multiplied it by 1.86. Former smokers had a hazard ratio of 1.12, with an interval that includes 1.

Example (adjustment reverses the order of the smoking groups). Fitted with the two smoking indicators alone, the hazard ratios are 1.38 for current smokers and 1.93 for former smokers, unadjusted. Former smokers appear to fare worst. They are twelve years older on average than current smokers, as the opening noted; once age is in the model, the order reverses. This is confounding by age in the sense of Confounding and Causal Diagrams, and the Cox model adjusts for it in the same way as a regression of any other kind. Whether the adjusted ratio of 2.27 is the causal effect of smoking depends on the other common causes left out, which the survey cannot settle.

The NHANES design is ignored here. The survey's sampling weights, strata and clusters are not used, so the estimates describe these 4,114 people, not the U.S. population; Survey Weights and the Horvitz–Thompson Estimator shows what the weights would change. NCHS also perturbed the public files: "Synthetic data were substituted for follow-up time or underlying cause of death for select records. Information regarding vital status was not perturbed" (National Center for Health Statistics, 2022). A single person's time may therefore be synthetic, though the death indicators are not.

The baseline hazard, estimated

The coefficients compare people. To predict survival we need the baseline too, and Theorem 2 supplies it. Breslow's estimator, computed with Efron's correction for ties (at a time with $d$ tied deaths, the jump is $\sum_{m=0}^{d-1}1/\{\sum_R r_l - (m/d)\sum_{D} r_i\}$), gives $\hat H_0(120) = 0.1014$ at ten years. The predicted survival of a person with covariates $\mathbf{x}$ is $\hat S(t \mid \mathbf{x}) = \exp\{-\hat H_0(t)\exp(\mathbf{x}^{\mathsf T}\hat{\boldsymbol\beta})\}$. For a man aged 60 the predicted probabilities of surviving ten years are:

Smoking, diabetes Ten-year survival
Never smoked, no diabetes 0.876
Current smoker, no diabetes 0.740
Never smoked, diabetes 0.781
Current smoker, diabetes 0.571

These are the model's predictions for people with those covariates, not observed proportions. They inherit the proportional hazards assumption, which the next section checks. Tsiatis (1981) gives the asymptotic normality of $\hat H_0$ and $\hat S$; the variance formulas, which add the uncertainty of $\hat{\boldsymbol\beta}$ to that of the baseline, are not derived here.

Checking proportional hazards

The model's one strong assumption is that each hazard ratio is constant over time. Two checks are standard. The first is graphical and needs no fitted model. The second is a score test against a coefficient that drifts with time.

Log-minus-log curves. Under proportional hazards $H(t \mid \mathbf{x}) = H_0(t)\,r(\mathbf{x})$, so

$$\ln\{-\ln S(t \mid \mathbf{x})\} = \ln H_0(t) + \mathbf{x}^{\mathsf T}\boldsymbol\beta.$$

For groups that differ in one indicator and nothing else, the curves of $\ln\{-\ln\hat S(t)\}$ against $\ln t$ are parallel, a vertical distance $\beta$ apart. If the hazard ratio changes with time, the distance changes, and curves that cross mean hazards that cross. The figure plots the Kaplan–Meier estimate by smoking group.

Log-minus-log Kaplan–Meier curves for never, former and current smokers in the NHANES cohort, against log months since the examination. Notice that the curves are not parallel: the gaps between the groups narrow over follow-up. Notice also that former smokers lie above current smokers. These curves are unadjusted, and the groups differ in age.
Log-minus-log Kaplan–Meier curves for never, former and current smokers in the NHANES cohort, against log months since the examination. Notice that the curves are not parallel: the gaps between the groups narrow over follow-up. Notice also that former smokers lie above current smokers. These curves are unadjusted, and the groups differ in age.

The unadjusted curves are not parallel. The gap between current and never smokers is 0.67 at one year, 0.52 at five, 0.35 at ten and 0.32 at twenty; between former and never smokers it falls from 1.34 to 0.67. Does that refute the model? Not by itself. The groups differ in age and sex, and a comparison of groups that differ in another risk factor need not have proportional hazards even when the model holds given all the covariates: the last section proves this for an omitted covariate. One likely reason here, not checked on this page, is that within each group the older members die first, and the groups lose them at different rates. With several covariates the plot would have to be drawn within strata of the others, which quickly runs out of data. A test that uses the fitted model, and so adjusts for the other covariates, is needed.

A time-varying coefficient and its score test. Embed the model in a larger one in which coefficient $j$ may drift with a chosen function $g(t)$ of time:

$$h(t \mid \mathbf{x}) = h_0(t)\exp\{\mathbf{x}^{\mathsf T}\boldsymbol\beta + g(t)\,\mathbf{x}^{\mathsf T}\boldsymbol\theta\}.$$

Proportional hazards is $\boldsymbol\theta = \mathbf{0}$. The larger model is a Cox model with covariates $\mathbf{x}$ and $g(t)\mathbf{x}$, whose values change with time but are known at each event time, so its partial likelihood is that of Theorem 1 with the covariate values at $t_{(j)}$. By Proposition 1 (written with Breslow's ties; with Efron's, which the script uses, the mean is averaged over the tied deaths), its score for $\boldsymbol\theta$ at $(\hat{\boldsymbol\beta}, \mathbf{0})$ is

$$\mathbf{U}_\theta = \sum_{j}\ g(t_{(j)})\sum_{i \in D_j}\{\mathbf{x}_i - \bar{\mathbf{x}}(t_{(j)}; \hat{\boldsymbol\beta})\}.$$

The vectors $\mathbf{s}_i = \mathbf{x}_i - \bar{\mathbf{x}}(t_i; \hat{\boldsymbol\beta})$, one for each person who fails, are the Schoenfeld residuals (Schoenfeld, 1982). They sum to $\mathbf{U}(\hat{\boldsymbol\beta}) = \mathbf{0}$. The score for $\boldsymbol\theta$ is their sum weighted by $g$ of the event time: if the residuals of covariate $j$ trend upward in $g(t)$, the covariate's effect grows over time. Since $\boldsymbol\beta$ is estimated, the score test uses the variance of $\mathbf{U}_\theta$ adjusted for it, the information block $\mathcal{I}_{\theta\theta} - \mathcal{I}_{\theta\beta}\mathcal{I}_{\beta\beta}^{-1}\mathcal{I}_{\beta\theta}$ of the larger model at $(\hat{\boldsymbol\beta}, \mathbf{0})$. The statistic $\mathbf{U}_\theta^{\mathsf T}(\mathcal{I}_{\theta\theta} - \mathcal{I}_{\theta\beta}\mathcal{I}_{\beta\beta}^{-1}\mathcal{I}_{\beta\theta})^{-1}\mathbf{U}_\theta$ is referred to the chi-squared distribution with $p$ degrees of freedom, or with 1 for a single covariate.

Grambsch and Therneau (1994) showed that the coefficient's path $\beta_j(t)$ can be seen by smoothing a plot of scaled residuals against time, and that many published tests of proportional hazards are related to time-weighted score tests of this kind and can be seen as a weighted least-squares line through the residual plot (abstract). The scaled residuals are $\hat{\boldsymbol\beta} + D\,\mathcal{I}(\hat{\boldsymbol\beta})^{-1}\mathbf{s}_i$, with $D$ the number of events; their mean over the events is $\hat{\boldsymbol\beta}$, and a trend in them estimates a trend in $\beta_j(t)$. R's cox.zph reports score tests of this form (Therneau, 2024, help page of cox.zph). The script computes the statistic from the exact score and information of the larger model, and its results agree with cox.zph to every printed digit for $g(t) = t$ and for its default $g(t) = 1 - \hat S(t-)$, one minus the pooled Kaplan–Meier estimate just before $t$.

With the Kaplan–Meier transform on the cohort:

Covariate Chi-squared (1 df) p-value
Age 0.22 0.64
Male 1.67 0.20
Current smoker 1.92 0.17
Former smoker 0.54 0.46
Diabetes 1.19 0.28
All five (5 df) 6.17 0.29

With $g(t) = t$ the global statistic is 6.44. Nothing here suggests that a hazard ratio drifted over twenty years of follow-up.

Scaled Schoenfeld residuals for current smoking against months since the examination, one point for each of the 1,240 deaths, with their mean in bins of 30 months and the fitted coefficient 0.820 as a horizontal line. Notice that the binned means scatter around the line, the later ones somewhat lower: no trend that the test can detect (p = 0.17).
Scaled Schoenfeld residuals for current smoking against months since the examination, one point for each of the 1,240 deaths, with their mean in bins of 30 months and the fitted coefficient 0.820 as a horizontal line. Notice that the binned means scatter around the line, the later ones somewhat lower: no trend that the test can detect (p = 0.17).

A test that fails to reject is not proof of proportionality. The tests have power only against departures that correlate with the chosen $g$, and no power calculation for this cohort is given here. The only evidence on this page is the simulation of the last section, in which hazards are certainly not proportional and the test rejected in 13% of the trials.

Time-varying covariates

The larger model of the last section already used covariates that change with time. The same device handles covariates measured repeatedly, such as blood pressure at later visits, or a treatment started partway through follow-up. The data are split into intervals $(a, b]$ over which each person's covariates are constant, and a person is in the risk set at $t$ when $a < t \le b$ for one of their intervals. Theorem 1's argument goes through with $\mathbf{x}_i(t)$ in place of $\mathbf{x}_i$, because it only used the hazards just before each event time. This counting-process form is the setting of Andersen and Gill (1982).

One caution is about meaning rather than computation. A covariate that is itself a consequence of the illness, such as a laboratory value measured as the person approaches death, makes the hazard ratio a description of an association along the way, not an effect of the covariate. Covariates fixed at the start, as here, or external to the person, avoid that problem.

Age as the time scale

Time since the examination is one clock. Age is another, and for a survey cohort it is often the better one. Korn, Graubard and Midthune (1997) recommend age as the time scale for follow-up of a health survey, with time on study adequate under conditions they give. With age as the clock, the baseline hazard is a function of age, so age needs no functional form in $\mathbf{x}$. A person enters the risk set at the age at examination, not at birth. This delayed entry (left truncation) is handled by the same intervals: person $i$ is at risk at age $t$ when their age at examination is below $t$ and their age at exit is at least $t$.

The examination age in months (NHANES variable RIDAGEEX) is missing for 12 of the cohort, leaving 4,102 adults. With age as the time scale and male sex, smoking and diabetes as covariates, the hazard ratios are 1.32 for men, 2.30 for current smokers, 1.13 for former smokers and 1.90 for diabetes. With time on study and age in the model, on the same 4,102 adults, they are 1.31, 2.27, 1.12 and 1.87. The two clocks tell the same story in this cohort: letting the baseline absorb age, instead of modeling it as linear in decades, changed the other hazard ratios by under 2%.

Non-collapsibility: omitting an independent covariate

Suppose a randomized trial assigns treatment $X$ by a coin toss, and a second factor $Z$, say a genetic variant, also affects the hazard but is never measured. Randomization makes $Z$ independent of $X$, so $Z$ cannot confound the comparison. The Cox model fitted to $X$ alone nevertheless estimates a different hazard ratio from the one in the model with both. The reason is that the hazard ratio is a ratio among survivors, and the groups lose their high-risk members at different speeds.

Theorem 4 (the marginal hazard ratio when a covariate is omitted). Let $X \in \{0, 1\}$ and let $Z$ be independent of $X$ with $W = e^{\gamma Z}$ not constant and $E[W] < \infty$. Given $X = x$ and $Z$, let $T$ have hazard $h_0(t)e^{\beta x}W$, with $h_0$ continuous. Define $m(u) = E[We^{-uW}]/E[e^{-uW}]$ for $u \ge 0$. Then the hazard of $T$ given $X = x$ alone, written $\bar h_x$ to distinguish it from the baseline $h_0$, is

$$\bar h_x(t) = h_0(t)\,e^{\beta x}\,m\big(e^{\beta x}H_0(t)\big),$$

the function $m$ is strictly decreasing, and the marginal hazard ratio is

$$\frac{\bar h_1(t)}{\bar h_0(t)} = e^{\beta}\,\frac{m(e^{\beta}H_0(t))}{m(H_0(t))}.$$

If $\beta > 0$ it is strictly below $e^\beta$ at every $t$ with $H_0(t) > 0$; if $\beta < 0$ it is strictly above; if $\beta = 0$ it is 1. It equals $e^\beta$ at $t = 0$, and if $W$ takes finitely many values it tends to $e^\beta$ as $H_0(t) \to \infty$.

Proof. Given $X = x$ and $W$, the cumulative hazard is $e^{\beta x}WH_0(t)$, so $P(T > t \mid X = x, W) = \exp\{-e^{\beta x}H_0(t)W\}$. Independence of $Z$ and $X$ means that $W$ has the same distribution in both groups, so $S_x(t) = E[\exp\{-uW\}]$ at $u = e^{\beta x}H_0(t)$. The hazard is $\bar h_x(t) = -\frac{d}{dt}\ln S_x(t)$. By the chain rule with $du/dt = e^{\beta x}h_0(t)$ (continuity of $h_0$ gives $dH_0/dt = h_0$), and differentiating under the expectation, $\bar h_x(t) = e^{\beta x}h_0(t)\,E[We^{-uW}]/E[e^{-uW}]$. The interchange holds for any $W \ge 0$: for $u \ge u_0 > 0$, $0 \le We^{-uW} \le 1/(eu_0)$ and $0 \le W^2e^{-uW} \le 4/(e^2u_0^2)$ (the maxima over $W$ are at $W = 1/u$ and $W = 2/u$), so dominated convergence (Billingsley's interchange results, as cited in Random Variables and Distribution Functions, section "What measure theory would add") allows differentiating $E[e^{-uW}]$ and $E[We^{-uW}]$ under the expectation at every $u > 0$; at $u = 0$ the right derivative of $E[e^{-uW}]$ is $-E[W]$, finite by assumption, by monotone convergence, since $(1 - e^{-uW})/u$ increases to $W$ as $u \downarrow 0$. Only right derivatives at 0 are needed, because $u = e^{\beta x}H_0(t) \ge 0$. The function $m$ is continuous at 0, by dominated convergence with $We^{-uW} \le W$, which is integrable, so $m' < 0$ on $(0, \infty)$ makes $m$ strictly decreasing on $[0, \infty)$. For the monotonicity, write $E_u$ for expectation under the reweighted distribution with weights proportional to $e^{-uW}$. Then $m(u) = E_u[W]$ and

$$m'(u) = -\frac{E[W^2e^{-uW}]}{E[e^{-uW}]} + \left(\frac{E[We^{-uW}]}{E[e^{-uW}]}\right)^2 = -\operatorname{Var}_u(W) < 0,$$

since $W$ is not constant under the reweighted distribution either. If $\beta > 0$ then $e^\beta H_0(t) > H_0(t)$ when $H_0(t) > 0$, so $m(e^\beta H_0(t)) < m(H_0(t))$ and the ratio is below $e^\beta$. If $\beta < 0$ the inequality reverses, and if $\beta = 0$ the two arguments coincide. At $t = 0$ both arguments are 0. As $u \to \infty$ the reweighted distribution of a $W$ with finitely many values puts all its mass on the smallest value $w_{\min}$, so $m(u) \to w_{\min}$ for both arguments and the ratio tends to $e^\beta$. $\square$

In words, the people with high $W$ die first in both groups, but faster in the group with the higher hazard. Among the survivors at any moment, the treated group has fewer high-risk people left than the control group, and its hazard is pulled down relative to the control group's.

Example (the marginal ratio need not stay above 1). Theorem 4 says on which side of $e^\beta$ the marginal ratio lies, not on which side of 1. For a gamma-distributed $W$ with shape $\kappa$ and rate $\lambda$, $E[e^{-uW}] = \{\lambda/(\lambda + u)\}^\kappa$ and $m(u) = \kappa/(\lambda + u)$, so the marginal ratio is $e^\beta(\lambda + H_0)/(\lambda + e^\beta H_0)$. For $\beta > 0$ and $H_0 > 0$ it is below $e^\beta$, because $\lambda + H_0 < \lambda + e^\beta H_0$, and above 1, because $e^\beta(\lambda + H_0) - (\lambda + e^\beta H_0) = (e^\beta - 1)\lambda > 0$: the marginal ratio is attenuated toward 1. With a strongly heterogeneous $W$ it can cross 1. Let $W$ be 1 or 1,000 with probability $\frac12$ each and $e^\beta = 1.1$. Then the ratio $e^\beta m(e^\beta u)/m(u)$ is 1.022 at $u = H_0(t) = 0.001$, 0.922 at 0.002 and 0.725 at 0.005: the treated group, which has the higher hazard given $W$, has the lower marginal hazard, because it has lost its frail members sooner.

Example (a numerical case). Let $h_0 = 1$, $\beta = \ln 2 = 0.693$, $\gamma = \ln 4$ and $P(Z = 1) = 1/2$. The marginal hazard ratio is 2.000 at $t = 0$, 1.812 at $t = 0.1$, 1.577 at 0.25, 1.477 at 0.5, 1.764 at 1, 1.985 at 2 and 2.000 at 5 (to three decimals). Its minimum is 1.470, at $t = 0.44$. The marginal hazards are not proportional, although the conditional ones are.

The marginal hazard ratio of treatment when an independent binary covariate (hazard ratio 4, prevalence one half) is omitted, against time, with the conditional hazard ratio 2 as a horizontal line. Notice that the marginal ratio starts at 2, dips to 1.470 at t = 0.44 and returns toward 2 as the high-risk members of both groups die out.
The marginal hazard ratio of treatment when an independent binary covariate (hazard ratio 4, prevalence one half) is omitted, against time, with the conditional hazard ratio 2 as a horizontal line. Notice that the marginal ratio starts at 2, dips to 1.470 at t = 0.44 and returns toward 2 as the high-risk members of both groups die out.

What does a Cox fit of $X$ alone estimate? The estimator converges to the root $\beta^*$ of the limit of the estimating equation, by the result of Struthers and Kalbfleisch (1986). With no censoring and the groups of equal size, that equation replaces the sums of Proposition 1 by expectations over the distribution of event times:

$$\tfrac12 = \int_0^\infty \frac{\tfrac12 S_1(t)e^{\beta^*}}{\tfrac12 S_0(t) + \tfrac12 S_1(t)e^{\beta^*}}\cdot\tfrac12\{f_0(t) + f_1(t)\}\,dt,$$

where $S_x$ and $f_x$ are the marginal survival function and density of group $x$. The left side is the expected share of all subjects who are group-1 failures (all fail eventually, so it is half), and the right side is the expected weighted mean of $x$ in the risk set at a failure. The script solves it by numerical integration: $\beta^* = 0.539$, a hazard ratio of 1.715 against the conditional 2. With administrative censoring at $t = 1$ (the left side becomes $\tfrac12\{1 - S_1(1)\}$, the expected share of all subjects who are group-1 failures by $t = 1$, and the integral stops there) the limit is 0.528, a hazard ratio of 1.696: the target of the estimator also depends on the censoring.

In 30 simulated trials (seeds 71,000,001 to 71,000,030), each with 2,000 people, no censoring and the model of the example, the Cox estimate with $X$ alone had median 0.540 (interquartile range 0.518 to 0.562). With $Z$ in the model it had median 0.691 (0.669 to 0.713), close to $\ln 2 = 0.693$. The score test of the last section with the Kaplan–Meier transform, applied to the fit of $X$ alone, had median chi-squared 1.3 (0.5 to 2.9) and exceeded the 5% critical value in a share 0.13 of the trials. The non-proportionality is real but hard to see in 2,000 people, probably because the marginal ratio departs from its average for only part of the follow-up.

This is not bias in the usual sense. The marginal hazard ratio of the trial and the conditional one given $Z$ are different quantities, and each fit estimates its own. The odds ratio of Relative Risk and Odds Ratio has the same property, as the example below shows. The risk difference and the risk ratio, by contrast, are collapsible: averaging $p(x, Z)$ over $Z$, whose distribution does not depend on $x$, gives marginal risks whose difference is the average of the conditional differences, and whose ratio equals a common conditional ratio. Gail, Wieand and Piantadosi (1984) studied the general case and state in their abstract that omitting covariates gives no asymptotic bias when the regression of the response on treatment and covariates is "linear or exponential", that in regular cases this condition is necessary, and that for moderately censored exponential data the exponential survival model was less biased than Cox's when covariates were omitted. Non-collapsibility differs from confounding, which Confounding and Causal Diagrams treats: confounding needs $Z$ to be related to $X$, and here it is not.

Example (a non-collapsible odds ratio). Let $P(Z = 1) = \frac12$, let the untreated risks be 0.2 when $Z = 0$ and 0.8 when $Z = 1$, and let treatment double the odds in both strata, so the treated risks are $1/3$ and $8/9$. The marginal risks are 0.5 untreated and 0.6111 treated, a marginal odds ratio of $(0.6111/0.3889)/(0.5/0.5) = 1.571$, below the common conditional odds ratio 2, although $Z$ is independent of treatment.

What is proved here, what is cited, and what the experiments show

Proved on this page: the survival function of the model as a power of the baseline survival function; the partial likelihood as a product of conditional probabilities of which person fails (Theorem 1); the profile likelihood of the model with a free baseline, Breslow's estimator, and the identity of the profile with Cox's partial likelihood without ties and with Breslow's likelihood with ties (Theorem 2); the score, the information and the concavity of the log partial likelihood (Proposition 1); the exact discrete likelihood for ties (Proposition 2); the score test at zero as the log-rank test, with the hypergeometric variance for the exact likelihood and the variance without the finite-population factor for Breslow's (Theorem 3); the score for a time-varying coefficient as a weighted sum of Schoenfeld residuals; the parallel log-minus-log curves; the marginal hazard ratio when an independent covariate is omitted, and its position relative to $e^\beta$ (Theorem 4).

Cited: the large-sample properties of partial likelihood (Cox, 1975), and for the Cox model the consistency and asymptotic normality of $\hat{\boldsymbol\beta}$ and of the estimated cumulative hazard and survival function (Tsiatis, 1981; Andersen and Gill, 1982); the full asymptotic efficiency of the partial likelihood under conditions (Efron, 1977); the convergence of $\hat{\boldsymbol\beta}$ under a misspecified model to the root of the limiting estimating equation (Struthers and Kalbfleisch, 1986) and the robust variance (Lin and Wei, 1989); the scaled residual plot and the relation among tests of proportional hazards (Grambsch and Therneau, 1994); the recursion for the exact likelihood (Gail, Lubin and Rubinstein, 1981); the marginal likelihood for ties (Kalbfleisch and Prentice, 1973); the conditions for no bias from omitted covariates (Gail, Wieand and Piantadosi, 1984); the choice of time scale (Korn, Graubard and Midthune, 1997). Each of these is cited at the strength of its abstract, which is what was read.

What the experiments show: the fitter of this unit reproduces the closed-form validation data of Therneau, the SAS documentation's rat example and R's coxph and cox.zph on the cohort. On the NHANES cohort the three tie methods differ by at most 0.0034 in any coefficient; the score tests show no departure from proportional hazards; the two time scales agree to within 2% in the hazard ratios. In the simulated trials the Cox estimate without the omitted covariate centered on the limit computed from the estimating equation, and the test of proportional hazards rejected in 13% of them at the 5% level. These are observations on one cohort and one simulation design.

Worked problems

The problems are posed on a six-subject dataset from Therneau's validation suite for survival software (Therneau, 2024, vignette "Software validation", test data 1; the vignette says portions of it appeared as an appendix of Therneau and Grambsch, 2000), chosen because every quantity has a closed form, and on this article's NHANES cohort and non-collapsibility example. The script tools/experiments/statistics/cox-proportional-hazards-model.py checks every number.

The six subjects, as (time, status, $x$): (1, 1, 1), (1, 0, 1), (6, 1, 1), (6, 1, 0), (8, 0, 0), (9, 1, 0). Status 1 is a death. Write $r = e^\beta$.

Problem 1 (Breslow's likelihood by hand). Write the Breslow log partial likelihood, find $\hat\beta$, and compute Breslow's estimate of the cumulative baseline hazard at times 1, 6 and 9.

Solution. At time 1 all six are at risk (the censoring at time 1 counts as at risk), three with $x = 1$, so the denominator is $3r + 3$ and the death has $x = 1$. At time 6 four are at risk, one with $x = 1$, denominator $r + 3$, and two die, with $x = 1$ and $x = 0$. At time 9 only the last subject is at risk, and the factor is 1. Hence

$$\ell_P(\beta) = \{\beta - \ln(3r + 3)\} + \{\beta + 0 - 2\ln(r + 3)\} = 2\beta - \ln(3r + 3) - 2\ln(r + 3).$$

By Proposition 1, $U(\beta) = (1 - \frac{r}{r+1}) + (1 - \frac{r}{r+3}) + (0 - \frac{r}{r+3}) = \frac{-r^2 + 3r + 6}{(r+1)(r+3)}$. The root of $r^2 - 3r - 6 = 0$ with $r > 0$ is $r = (3 + \sqrt{33})/2 = 4.3723$, so $\hat\beta = 1.4753$. Since $\ell_P$ is strictly concave (both values of $x$ are at risk at times 1 and 6), this is the unique maximizer. Breslow's estimator (Theorem 2) has jumps $1/(3r + 3)$ at time 1, $2/(r + 3)$ at time 6 and $1/1$ at time 9. So $\hat H_0(1) = 0.0620$, $\hat H_0(6) = 0.0620 + 0.2713 = 0.3333$ and $\hat H_0(9) = 1.3333$. The value at time 6 is exactly $1/3$: $\frac{1}{3(r+1)} + \frac{2}{r+3} = \frac{7r + 9}{3(r^2 + 4r + 3)}$, and $r^2 = 3r + 6$ turns the denominator into $3(7r + 9)$.

Problem 2 (Efron's and the exact likelihoods on the same data). Find $\hat\beta$ under Efron's likelihood and under the exact discrete likelihood.

Solution. Efron's likelihood changes only the second of the two tied deaths at time 6: of the tied pair, each keeps half its risk score, so the second denominator is $r + 3 - \frac12(r + 1) = (r + 5)/2$. Then $U(\beta) = (1 - \frac{r}{r+1}) + (1 - \frac{r}{r+3}) + (0 - \frac{r}{r+5})$. Over the common denominator this is $\frac{-r^3 + 23r + 30}{(r+1)(r+3)(r+5)}$, and the cubic's positive root is $r = 5.3487$, so $\hat\beta = 1.6769$. The exact likelihood at time 6 is $r \cdot 1$ over the sum of the products of all pairs from the risk scores $(r, 1, 1, 1)$, which is $3r + 3$. So $\ell_P(\beta) = 2\{\beta - \ln(3r + 3)\}$, with derivative $2/(r + 1) > 0$ for every $\beta$. The likelihood increases forever toward its supremum $-2\ln 3 = -2.1972$, and there is no finite estimate. The reason is visible in the proof of Theorem 3, where each factor's derivative is $x_D - E_\beta[x_{\mathcal S}]$. At time 1 the one failure has $x = 1$, and at time 6 the failing pair contains the only subject at risk with $x = 1$. At both times the failures carry the largest $x_D$ that any set of their size could, so $x_D - E_\beta[x_{\mathcal S}] > 0$ for every $\beta$. This is the monotone likelihood of Proposition 1's discussion. The three methods give 1.4753, 1.6769 and infinity on six subjects, an extreme instance of their disagreement under heavy ties.

Problem 3 (the score tests at zero). Compute the score statistic at $\beta = 0$ under Breslow's likelihood and under the exact likelihood, and the log-rank statistic directly.

Solution. At $\beta = 0$, time 1 has $n = 6$, $n_1 = 3$, $d = 1$, $d_1 = 1$; time 6 has $n = 4$, $n_1 = 1$, $d = 2$, $d_1 = 1$; time 9 has $n = 1$, $n_1 = 0$. So $O - E = (1 - \frac12) + (1 - 2 \cdot \frac14) + 0 = 1$. By Theorem 3, Breslow's information is $1 \cdot \frac14 + 2 \cdot \frac{3}{16} = \frac58$, and the score statistic is $1/(5/8) = 1.6$. The hypergeometric variance is $\frac{3 \cdot 3 \cdot 1 \cdot 5}{36 \cdot 5} + \frac{1 \cdot 3 \cdot 2 \cdot 2}{16 \cdot 3} = \frac14 + \frac14 = \frac12$, so the log-rank statistic and the exact-likelihood score statistic are both $1/(1/2) = 2.0$. Efron's score at zero is not $O - E$. At time 6, with every risk score 1, its first factor uses the plain mean $\frac14$. Its second factor keeps half of each tied subject: the weights are $\frac12, \frac12, 1, 1$, with total 3, and the weighted sum of $x$ is $\frac12$, so the mean is $\frac16$ instead of $\frac14$. Then $U(0) = (1 - \frac12) + (1 - \frac14 - \frac16) = \frac{13}{12} = 1.0833$, against $O - E = 1$.

Problem 4 (a combined hazard ratio with its interval). From the NHANES fit, find the hazard ratio of a current smoker with diabetes against a never smoker without diabetes of the same age and sex, with a 95% interval. The estimated covariance of the two coefficients is $2.53 \times 10^{-4}$.

Solution. The log hazard ratio is $\hat\beta_{\text{current}} + \hat\beta_{\text{diabetes}} = 0.820 + 0.623$, a hazard ratio of 4.23. Its variance is $\widehat{\operatorname{Var}}(\hat\beta_c) + \widehat{\operatorname{Var}}(\hat\beta_d) + 2\widehat{\operatorname{Cov}}(\hat\beta_c, \hat\beta_d) = 0.078^2 + 0.069^2 + 2 \times 0.000253$ (with unrounded standard errors in the script), a standard error of 0.106. The interval is $\exp(1.443 \pm 1.96 \times 0.106)$, from 3.43 to 5.21. The model's multiplicative form is what makes the combined ratio the product of the two; whether the effects of smoking and diabetes really multiply could be checked by adding their product as a covariate.

Problem 5 (a marginal hazard by hand). In the non-collapsibility example ($h_0 = 1$, $\beta = \ln 2$, $\gamma = \ln 4$, $P(Z = 1) = \frac12$), compute the two marginal hazards and their ratio at $t = 0.5$.

Solution. In group 0 the two kinds of people have hazards 1 and 4. By Theorem 4's proof, $\bar h_0(0.5) = (e^{-0.5} + 4e^{-2})/(e^{-0.5} + e^{-2}) = 1.547$, the average hazard weighted by who is still alive. In group 1 the hazards are 2 and 8, and at $t = 0.5$ the survival weights are $e^{-1}$ and $e^{-4}$, so $\bar h_1(0.5) = (2e^{-1} + 8e^{-4})/(e^{-1} + e^{-4}) = 2.285$. The ratio is 1.477, against the conditional 2. By $t = 0.5$ the treated group has lost far more of its high-risk members ($e^{-4}$ of them survive against $e^{-2}$ in the control group), so its average hazard is pulled down further.

Summary

Result Statement
Model $h(t \mid \mathbf{x}) = h_0(t)e^{\mathbf{x}^{\mathsf T}\boldsymbol\beta}$; $S(t \mid \mathbf{x}) = S_0(t)^{e^{\mathbf{x}^{\mathsf T}\boldsymbol\beta}}$
Partial likelihood $\prod_j r_{(j)}/\sum_{R(t_{(j)})}r_l$, conditional probabilities of who fails (Theorem 1)
Profile likelihood maximizing over a free $H_0$ gives Breslow's $\hat H_0(t) = \sum_{t_{(j)} \le t}d_j/\sum_{R}r_l$ and leaves $L_P$ (Theorem 2)
Score, information $\sum_j(\sum_{D_j}\mathbf{x}_i - d_j\bar{\mathbf{x}}_j)$; $\sum_j d_jV_j$; $\ell_P$ concave (Proposition 1)
Ties exact discrete (elementary symmetric polynomial), Breslow $(\sum r)^{d}$, Efron averaged (Proposition 2)
Score test at 0 $O - E$; exact likelihood gives the hypergeometric variance, the log-rank test (Theorem 3)
Proportional hazards log-minus-log curves parallel; score test for $\beta + \theta g(t)$ from Schoenfeld residuals
Omitted covariate marginal hazard ratio below $e^\beta$ for $\beta > 0$, equal at $t = 0$ (Theorem 4)
NHANES 1999–2000 hazard ratios 2.43 per decade of age, 2.27 current smoking, 1.86 diabetes, 1.31 male

What we have learned

The Cox model separates what a regression of survival needs, a comparison of people, from what it can leave alone, the shape of the hazard over time. The partial likelihood is the product of the probabilities of who failed among those at risk; it is also the profile likelihood when the baseline is free, and the baseline then comes out as Breslow's estimator. At zero its score is observed minus expected, and with the exact likelihood its score test is the log-rank test. On twenty years of NHANES follow-up, in a model that assumes the same ratio at every age, current smokers died at 2.27 times the rate of never smokers of the same age, sex and diabetes status, an association the survey alone cannot make causal, and the proportionality in follow-up time that the model assumes held up under test. The hazard ratio is a conditional quantity among survivors, and omitting even an independent covariate changes it.

Leaving the baseline free costs something: the model says nothing about the shape of the hazard, and survival predictions rest on a step function. When the shape is known, or nearly so, a model that specifies it can be more precise. Parametric Survival Models fits the exponential, Weibull, Gompertz and other families to the same cohort, and measures what the extra assumption buys and what it costs when it is wrong.

References