Method · Statistics Library

Cox proportional-hazards regression

Cox regression relates one or more predictors to time-to-event data with censoring, estimating a hazard ratio for each predictor without assuming any particular shape for the baseline risk over time.

Topic indexA reference reading outside the guided chapter sequence

Understand the idea

Survival analysis deals with data like 'this patient was event-free for at least 18 months, then we lost track of them': you know they survived that long, but not what eventually happened. That partial information is called censoring, and it is exactly what the Cox model is built to handle. Instead of predicting a single number, it estimates how much each predictor multiplies the instantaneous RISK of the event happening at any given moment (the hazard) relative to the comparison group (the reference level, or one unit lower).

That multiplier is the hazard ratio. A hazard ratio of 2 for a treatment means treated patients face roughly double the instantaneous risk of the event compared to untreated patients at any given moment, all else equal: shorter survival. A hazard ratio of 0.5 means half the risk: longer survival, a protective effect. A hazard ratio of exactly 1 means no association at all.

The remarkable thing about the Cox model is what it does NOT need to assume: it never commits to a specific shape for how risk changes over time in general (rising, falling, whatever), only that whatever that baseline shape is, each predictor scales it by the same constant factor throughout follow-up. That 'same factor throughout' assumption is called proportional hazards, and it is the model's central promise, one worth checking, not simply trusting.

Cox regression, also called the Cox proportional hazards model, is the most common survival regression.

Practitioner explanation

KernelStats fits the standard partial-likelihood Cox model with a selectable tie-handling method (Efron, the default and generally preferred; Breslow, simpler but biased with many ties). Hazard ratios are exp(beta) with a 95% CI from exponentiating the Wald interval on beta (exp(beta_hat +/- 1.96*SE)), and Wald z-tests per predictor. Categorical predictors are dummy-encoded against a reference level chosen as the first level ALPHABETICALLY, the same convention R uses by default, and changing the reference level changes which pairwise comparisons are displayed, not the model's fit. The card also reports the whole-model likelihood-ratio, Wald and score tests against a model with no predictors, and the concordance (the share of comparable pairs the model ranks in the right order, 0.5 being chance) with its standard error, as R's summary(coxph) does.

When a predictor perfectly (or near-perfectly) separates who has the event from who does not, the partial likelihood keeps rising as the coefficient grows without bound, so no finite maximum-likelihood estimate exists; KernelStats detects this (the separation flag on the card) and reports the hazard ratio and its interval as NOT REPORTABLE rather than printing whatever arbitrary huge number the optimizer happened to stop at, a genuinely different, more honest posture than silently returning a meaningless coefficient.

The proportional-hazards assumption is ACTUALLY TESTED with the Grambsch-Therneau score test that R's cox.zph computes with its defaults: at the fitted coefficients, it tests whether each predictor's effect drifts with time measured on the Kaplan-Meier scale g(t) = 1 − Ŝ(t−), with ties handled as in the fit. The card gives one chi-square per predictor (df = that predictor's coefficients, so a categorical predictor is tested as a whole) and a global chi-square for all of them together; the predictor with the smallest p-value is highlighted, and that smallest p-value is explicitly NOT adjusted for the several predictors checked. With fewer than four events, every event at the same time, a predictor whose estimate diverges (separation), or a test that cannot be computed (residuals with no variation over time), the check reports 'not assessed' rather than a false pass: an un-run check is not evidence the assumption holds, exactly as the product states.

When to use it

Consider it when

Time-to-event data with right-censoring (a follow-up time and a 0/1 event indicator) needs to be related to one or more predictors, adjusting for each other, without committing to a specific parametric shape for the baseline hazard.

Use caution when

You have no covariates and just want to describe or compare survival curves directly (use Kaplan-Meier and the log-rank test instead), the proportional-hazards assumption is clearly violated and cannot be worked around with stratification or a time-varying coefficient, or you need a fully parametric model to extrapolate the baseline hazard beyond the observed follow-up period (a Weibull or exponential AFT model is the appropriate tool).

Formulas and symbols

Cox proportional-hazards model

h(t∣x)=h0(t) exp⁡(β1x1+⋯+βpxp)h(t \mid x) = h_0(t)\,\exp(\beta_1 x_1 + \dots + \beta_p x_p)

h0(t) the completely unspecified baseline hazard (the semiparametric part); only the ratio of hazards across covariate values is modeled.

Hazard ratio

HRj=exp⁡(βj)\text{HR}_j = \exp(\beta_j)

The multiplicative change in hazard for a one-unit increase in x_j, holding other covariates fixed. HR > 1 shorter survival; HR < 1 longer (protective).

Grambsch-Therneau proportional-hazards diagnostic

χj2=uj⊤ I−1uj,g(t)=1−S^(t−)\chi^2_j = u_j^{\top}\,\mathcal{I}^{-1}u_j,\quad g(t) = 1 - \hat S(t^-)

Score test, at the fitted coefficients, of letting each predictor's effect drift with time measured on the Kaplan-Meier scale g(t) = 1 − Ŝ(t−): u_j is the score for that drift and 𝓘 its information. One chi-square per predictor (df = its coefficients) and a global chi-square for all together; ties handled as in the fit. A small p-value signals that the hazard ratio changes over follow-up. Reported per predictor, unadjusted for multiplicity when several are checked.

Assumptions and checks

  • Proportional hazards. If the hazard ratio for a predictor actually changes over follow-up time (the effect is stronger early or late rather than constant), the single reported hazard ratio is only an average over a changing effect and can be misleading about what happens at any specific time point.

    In KernelStats: The Grambsch-Therneau score test on the Kaplan-Meier time scale: a chi-square per predictor and a global chi-square for all together, with the smallest per-predictor p-value highlighted on the card and not adjusted for multiplicity; explicitly reported as 'NOT ASSESSED' rather than a false pass when the test cannot run (fewer than four events, every event at the same time, a diverging coefficient, or a test that cannot be computed).

  • Informative censoring (subjects are censored FOR reasons related to their prognosis, e.g. sicker patients dropping out) biases the hazard ratios; the Kaplan-Meier and Cox machinery both assume censoring is unrelated to a subject's underlying risk.

    In KernelStats: Not checked by KernelStats: assumed from the study design; reported directly on the card as a standing 'Non-informative censoring' reminder.

  • Independence of observations. Cox regression assumes each subject's event/censoring time is independent of every other subject's; clustered data (e.g. multiple body sites per patient, patients within the same hospital) violate this and understate the true standard errors of the hazard ratios.

    In KernelStats: Not checked by KernelStats: assumed from the study design; reported directly on the card as a standing 'Independent survival times' reminder. A clustered design needs a frailty model or a robust (sandwich) variance estimator, neither of which this function provides.

  • With too few events relative to the number of predictors, hazard-ratio estimates and their standard errors become unstable, and can be strongly biased away from the true value.

    In KernelStats: Checked directly: the card reports events per predictor coefficient and flags it as a warning below the common 10-events-per-predictor rule of thumb.

Alternatives

  • Kaplan-Meier Survival Curve. You want to describe or compare survival curves directly without adjusting for covariates.
  • Censored Weibull Reliability (Life-Data) Fit. You need a fully parametric baseline hazard to extrapolate survival beyond the observed follow-up period.

Worked example

Scenario

Bearing life in hours (60 bearings, 51 failures, 9 still running and censored), with lubricant (Standard as the reference, or Synthetic) and load in kN as predictors, Efron ties.

Result

Synthetic HR = 0.591, 95% CI [0.338, 1.034], p = .065; load HR = 1.054 per kN, 95% CI [1.006, 1.106], p = .029. Whole model: likelihood-ratio χ²(2) = 8.95, p = .011; concordance 0.622. Proportional-hazards check: lubricant χ²(1) = 0.81, p = .368; load χ²(1) = 3.56, p = .059; global χ²(2) = 4.68, p = .096.

Interpretation

Each extra kN of load multiplies the failure hazard by about 1.05, holding lubricant fixed. Synthetic lubricant goes with a hazard about 41% lower, but its interval runs from 0.34 to 1.03, so the data are compatible with anything from a large reduction to a slight increase. The proportional-hazards check finds no clear evidence of a drift over time; load comes closest (p = .059), so it is worth plotting before treating its hazard ratio as constant across the whole follow-up.

Dataset: bearing_life.csv

Common misconceptions

Misconception

A hazard ratio of 2 means the treated group is twice as likely to eventually experience the event.

Correction

A hazard ratio describes the RATE at which the event occurs among those still at risk at any given moment, not the eventual probability of the event occurring at all. A hazard ratio of 2 means events happen roughly twice as fast in the treated group at any given moment, which over a long enough follow-up can still result in similar EVENTUAL event proportions if follow-up differs or competing risks are present: rate and eventual probability are related but different quantities.

Misconception

If the proportional-hazards check is not flagged as violated, the assumption is confirmed to hold.

Correction

When the check cannot run at all (fewer than four events, every event at the same time, a predictor whose estimate runs off to infinity, or residuals with no variation over time), KernelStats reports 'not assessed', not a pass. An unrun check is not evidence the assumption holds, and even a passing check with adequate data is only an absence of evidence against the assumption, not proof of it.

Read more: Misconception: a non-significant result proves there is no effect

References

  1. Regression models and life-tables, Cox, D. R. (1972), Journal of the Royal Statistical Society, Series B, 34(2), 187-220.
  2. Modeling Survival Data: Extending the Cox Model, Therneau, T. M. and Grambsch, P. M. (2000).