Cox Regression Explained: How to Run, Read and Report It
Cox proportional hazards regression models the time until an event, such as death, relapse or equipment failure, when some participants have not yet had the event by the end of follow-up. It estimates hazard ratios without assuming a particular shape for the baseline hazard, and it handles censored observations correctly, which ordinary regression cannot do.
What is Cox regression?
The hazard h(t) is the instantaneous event rate at time t among those still at risk. Cox's (1972) model is:
h(t | x) = h0(t) · exp(β1x1 + … + βkxk)
The baseline hazard h0(t) is left unspecified. The coefficients are estimated by maximising the partial likelihood, which compares each person who has the event with everyone still at risk at that moment. The exponentiated coefficient exp(β) is the hazard ratio (HR): HR = 0.5 means that at any time the event rate is half as high per one-unit increase in x (or compared with the reference group).
When should you use it?
Use it for time-to-event outcomes with censoring and one or more covariates: survival after treatment, time to relapse, time to first purchase or time to machine failure. Compare survival curves with Kaplan-Meier and log-rank tests for a single categorical factor, and use Cox regression when you need adjustment or continuous predictors (Collett, 2015). A common planning guide is at least about 10 events per covariate, and the number of events, not the number of participants, governs precision.
Assumptions
- Proportional hazards: the hazard ratio is constant over time. Check with scaled Schoenfeld residuals or a test of time-covariate interaction (Grambsch & Therneau, 1994).
- Non-informative censoring: censored participants have the same future risk as those who stay.
- Independent observations and log-linear covariate effects (check continuous covariates for curvature).
- Correct handling of tied event times (Breslow, Efron or exact methods).
Original example (illustrative)
Question. Does a new therapy lower the hazard of relapse after adjusting for age? Follow-up was capped at 24 months. Data for n = 30 patients (invented; status = 1 relapse, 0 censored; age in years):
Show the full illustrative dataset (CSV, copy into the tool)
months,status,therapy,age 5.5,1,1,68 4.0,1,0,83 9.5,1,0,48 10.7,1,0,57 8.4,1,0,63 24.0,0,1,56 17.7,0,1,46 21.3,0,1,58 24.0,0,1,60 18.3,1,0,63 1.7,1,0,57 10.4,1,1,71 18.1,0,0,62 9.8,1,0,66 24.0,0,1,52 16.5,0,1,40 10.6,1,0,66 17.7,0,1,63 0.3,1,0,66 5.1,1,0,61 4.5,1,0,58 15.5,0,1,58 17.0,0,1,68 20.0,0,1,54 22.1,1,0,58 18.2,0,1,60 8.8,1,1,63 4.3,1,0,78 24.0,0,1,56 1.8,1,0,80
There are 17 relapses among 30 patients (14 in the standard group, 3 in the therapy group). Kaplan-Meier median time to relapse is 8.4 months for standard care and not reached for therapy. The Cox model includes therapy (0/1) and age centred at 60 years.
| Covariate | b | SE | HR | 95% CI for HR | z | p |
|---|---|---|---|---|---|---|
| Therapy | −1.901 | 0.652 | 0.15 | [0.04, 0.54] | −2.91 | .004 |
| Age (per year) | 0.107 | 0.040 | 1.113 | [1.029, 1.205] | 2.66 | .008 |
Likelihood-ratio test of the model: χ²(2) = 2 × (−38.46 − (−50.45)) = 23.98, p < .001. Harrell's concordance index (C) = 0.81, meaning that for 81% of comparable patient pairs the model assigns the higher risk to the patient who relapsed earlier. (An in-sample C overstates how well the model would predict new patients.)
Interpretation. At any time during follow-up, patients on the new therapy had a hazard of relapse that was 0.15 times that of standard care, equivalent to a 85% lower hazard (95% CI for HR [0.04, 0.54]), holding age constant. Each additional year of age multiplied the hazard by 1.113, or about 2.93 per 10 years (95% CI [1.33, 6.45]). Hazard ratios compare instantaneous rates; they are not risk ratios and do not by themselves tell you how many months of relapse-free time the therapy gains. With only 17 events, estimates are imprecise.
How to run Cox regression with StatFAS
Open the Cox Regression Calculator. Arrange a time column, an event indicator (1 = event, 0 = censored) and covariate columns. Check the event coding carefully; reversing it silently answers the wrong question.
Understanding the output
- Hazard ratios with confidence intervals: the main effect size; an interval containing 1 indicates no clear association.
- Likelihood-ratio, Wald and score tests: overall model significance.
- Concordance (C-index): discrimination, with 0.5 meaning chance.
- Proportional-hazards test and Schoenfeld plots: check the key assumption.
- Adjusted survival curves: visualise model-based survival for chosen covariate values.
APA 7 reporting example
A Cox proportional hazards regression showed that the new therapy was associated with a lower hazard of relapse after adjusting for age (HR = 0.15, 95% CI [0.04, 0.54], p = .004). Each additional year of age increased the hazard (HR = 1.113, 95% CI [1.029, 1.205], p = .008). There were 17 events among 30 participants.
Common mistakes and troubleshooting
- Ignoring censoring by analysing time as a plain continuous outcome or by dropping censored patients.
- Skipping the proportional-hazards check. If hazards cross, a single HR is misleading; consider time-varying effects or stratification.
- Too few events for the number of covariates, which gives unstable estimates.
- Reading HR as relative risk or as a ratio of survival times.
- Immortal-time or informative-censoring bias from how time zero or follow-up was defined.
Limitations and alternatives
If hazards are not proportional, stratified Cox models, time-varying coefficients, restricted mean survival time or parametric accelerated-failure-time models may be better. Competing risks need specialised methods. For a binary outcome at a fixed time, logistic regression is simpler but ignores timing. For event counts see negative binomial regression, and for choosing among models see the regression guide.
Conclusion
Cox regression is the standard method for time-to-event data with censoring. Report hazard ratios with intervals and the number of events, check proportional hazards, and be clear that the HR describes relative event rates over time.
1.
statfas-cox-regression-interface.png, alt: "StatFAS Cox Regression Calculator interface"2.
statfas-cox-regression-example-data.png, alt: "Example data entered in the StatFAS Cox Regression Calculator"3.
statfas-cox-regression-settings.png, alt: "Cox Regression Calculator settings in StatFAS"4.
statfas-cox-regression-result.png, alt: "Cox Regression Calculator results generated in StatFAS"Frequently asked questions
What does a hazard ratio of 0.60 mean?
At any point in time, the event rate in one group (or per unit of the covariate) is 60% of the rate in the reference group, a 40% lower hazard. It is a ratio of instantaneous rates, not of cumulative risks.
What does 'proportional hazards' mean?
It means that the ratio of hazards between groups is constant over time, so the hazard curves differ by a fixed multiplicative factor. It can be checked with Schoenfeld residuals.
How many events do I need?
A common planning guide is around 10 events per covariate, but the required number depends on effect size and desired precision. Total sample size matters less than the number of events.
References
- Cox, D. R. (1972). Regression models and life-tables. Journal of the Royal Statistical Society: Series B, 34(2), 187–220.
- Collett, D. (2015). Modelling survival data in medical research (3rd ed.). CRC Press.
- Grambsch, P. M., & Therneau, T. M. (1994). Proportional hazards tests and diagnostics based on weighted residuals. Biometrika, 81(3), 515–526.