← All resources

Cox Proportional Hazards: Model, Assumptions and Interpretation

13 min read
Cox Proportional Hazards: Model, Assumptions and Interpretation

Cox Proportional Hazards: Model, Assumptions and Interpretation

Two hazard function curves on a research plot

The Cox proportional hazards model is a regression for time-to-event data. It estimates how predictors change the instantaneous risk of an event, such as death, relapse or device failure, without assuming a shape for the baseline risk over time. Fitting it takes one line of R. Defending it to a reviewer takes more: censoring, tied times, the proportional hazards assumption, diagnostics and a report someone else can rerun. This guide covers each of these, and shows where PlotStudio AI, our agentic analytics platform for researchers, fits into that workflow.

Plotstudio
plotstudio.ai
Make Survival Analyses Easier to Review
PlotStudio AI plans and runs real R or Python code, keeping methods, outputs, and statistics available for review.
Visit

TL;DR

  • The Cox model writes the hazard as a baseline hazard multiplied by exp of a linear predictor, so each coefficient becomes a hazard ratio once exponentiated.
  • Its core assumption is that hazard ratios stay constant over time. Check it with scaled Schoenfeld residuals and log(-log) plots, not with a glance at Kaplan-Meier curves alone.
  • If the assumption fails, you can stratify, add time-dependent coefficients, split the time axis, use weighted Cox models or switch to restricted mean survival time.
  • Report the formula, the ties method, hazard ratios with 95% confidence intervals, the diagnostics and the code.
  • PlotStudio AI adds an agentic layer on top of R and Python: it plans the analysis, runs real code and keeps the methodology, outputs and statistics reviewable.

Table of Contents

What the Cox model is and what its formula says

The Cox model relates survival time to one or more predictors. The hazard at time t for a subject with covariates x is h(t|x) = h0(t) × exp(β1x1 + … + βpxp), where h0(t) is the baseline hazard and the βs are the model parameters. The hazard is the instantaneous event rate among people still at risk at time t.

The model is called proportional because, as Cox’s 1972 formulation implies, the ratio of the hazard functions for two cases does not depend on time. Take two patients who differ only in treatment. Whatever the baseline hazard does, the ratio of their hazards is exp(β) at every moment of follow-up.

That design explains the model’s popularity. It is semiparametric: no specific survival distribution has to be assumed, because h0(t) is left unspecified. The coefficients are estimated by partial likelihood, which does not need a form for the baseline hazard. You get an effect size, the hazard ratio, and you can adjust for several covariates at once.

For a deeper walkthrough of the same ground, see our practical guide to Cox regression survival analysis.

What your data must look like

Every row needs three things: a follow-up time, an event indicator and the covariates. The indicator is 1 if the event was observed and 0 if the person was censored, meaning follow-up ended before the event happened (study end, loss to follow-up, withdrawal).

Censoring is where many first analyses go wrong. The method requires that censoring be noninformative. Study termination at a predetermined date is fine; informative censoring can seriously bias survival estimates. If patients drop out because they are getting sicker, treating them as ordinary censored observations breaks the logic of the model. Our article on censoring in survival analysis covers the types and how to recognize them.

Before fitting, check these points:

  1. Time origin. Define one clear start (randomization, diagnosis, admission) and use it for everyone.
  2. Time units. Keep days, months or years consistent across the dataset.
  3. Event definition. Decide how competing events, such as death from another cause, are handled before you look at results.
  4. Covariate coding. Fix reference categories and decide whether continuous variables enter linearly.
  5. Events per variable. A model with many covariates and few events is unstable, so count events, not patients.

Fitting a Cox model in R

In R, the survival package does the work. A minimal model looks like this:

library(survival)
fit <- coxph(Surv(time, status) ~ age + sex + treatment,
             data = d, ties = "efron")
summary(fit)
cox.zph(fit)

Surv() combines the follow-up time and the event indicator. summary(fit) returns coefficients, hazard ratios (the exp(coef) column), confidence intervals and p-values. cox.zph() tests the proportional hazards assumption, which we return to below.

Two details matter for reproducibility. First, tied event times. The Efron method is the default and generally the preferred approach in coxph, so state it in your methods section rather than leaving it implicit. Second, interactions. When an interaction is in the model, its main effects must be in the model too, otherwise the coefficients lose their meaning.

Covariate selection deserves a sentence of its own. The same source advises against automatic stepwise procedures, and its view is that there are no models, only useful ones. Choose covariates from the clinical or scientific question and write the reasoning down. A reviewer asking for method justification is usually asking exactly that.

If you want a full pipeline from Kaplan-Meier curves to the Cox model and plots, our guides to survival analysis in R and survival analysis with R walk through it. If your group works in SAS, there is a SAS version in six steps.

Fitting a Cox model in R

Interpreting hazard ratios, intervals and p-values

The coefficient β is on the log-hazard scale. Exponentiate it and you have the hazard ratio (HR).

  • HR = 1: no association with the hazard.
  • HR above 1: higher hazard, so a higher event rate at any given time among those still at risk.
  • HR below 1: lower hazard.

For a continuous predictor, the HR applies per one-unit increase, so the unit you chose matters. An HR of 1.03 per year of age is an HR of about 1.34 per decade (1.03 raised to the tenth power).

Here is an illustrative example, with invented numbers for teaching purposes. Suppose a trial reports an HR of 0.72 for the treatment arm, with a 95% confidence interval of 0.55 to 0.94. Read it this way: at any point in follow-up, the event rate among treated patients still at risk is about 28% lower than in the control arm, after adjusting for the other covariates. The interval excludes 1, so the p-value is below .05. If the interval had been 0.55 to 1.08, it would cross 1 and the result would not be statistically significant at that level.

Two cautions keep interpretation honest:

  • An HR is not a ratio of survival times, and it is not a risk ratio over the whole follow-up. It compares rates at an instant, assumed constant in ratio over time.
  • The confidence interval tells you more than the p-value. A wide interval around a large HR signals imprecision, which usually means few events.

Our short piece on hazard ratios explained with examples gives more worked readings.

Testing the proportional hazards assumption

The model’s central assumption is that the HR is constant over time. If a treatment works early and fades, or only starts working after a year, a single HR averages over something that is not constant, and the average can mislead.

The main ways to test the assumption are:

Method What you look at Typical use
Kaplan-Meier curves Whether curves cross or diverge unevenly Quick first look for one categorical variable
log(-log) plots Whether lines are roughly parallel Categorical predictors
Scaled Schoenfeld residuals Whether residuals show a trend against time, with a formal test Any covariate in a multivariable model

Scaled Schoenfeld residuals are the most useful in practice, because they work covariate by covariate inside the adjusted model. In R, cox.zph(fit) gives a test per covariate and a global test, and plot() on its result shows the residual trend. A flat line around zero supports proportionality. A visible slope suggests the effect changes over time. With large datasets, the test can flag trivial departures, and with small ones it can miss real ones, so pair the p-value with the plot. We collect more on this in our Schoenfeld residuals articles and proportional hazards articles.

What to do if the assumption fails

The same review lists the options: time-axis division, time-dependent coefficients, stratification, weighted Cox models or restricted mean survival time. In plain terms:

  • Stratify on the offending variable when you do not need its HR. Each stratum gets its own baseline hazard.
  • Split the time axis and estimate a separate HR for early and late follow-up.
  • Add a time-dependent coefficient when the effect changes smoothly with time.
  • Use restricted mean survival time when you want a difference in average event-free time that does not rely on proportional hazards.

Whichever you choose, say in your methods why, and show the diagnostic that led you there.

Reporting a Cox analysis so others can reproduce it

A supervisor who cannot reproduce your numbers is a common cause of late-stage panic. A reproducible report documents the model formula, how tied times were handled (typically Efron), hazard ratios with 95% CIs, diagnostic checks such as Schoenfeld residuals, and visualizations like forest plots or adjusted survival curves. In practice, include:

  1. The exact model formula and the software and package versions.
  2. The definition of time origin, event and censoring.
  3. The number of participants and events in the model.
  4. A table of HRs with 95% CIs, and a forest plot for models with many covariates.
  5. The proportional hazards check, with the plot in a supplement.
  6. The script or notebook that produced all of it.

The last item is the one most often missing. Numbers pasted from the console into a manuscript cannot be audited, whereas a script can be rerun by a reviewer.

Where PlotStudio AI fits in the research toolkit

R, Python, SPSS, SAS and Jupyter provide the statistical computing. They do not tell you which analysis to run, and they do not document your reasoning. PlotStudio AI is designed as an agentic layer next to them, not a replacement: agentic analytics for researchers, where specialized AI agents plan the investigation, write and run real code, inspect intermediate results and synthesize the findings.

For a Cox analysis, that maps onto the steps above in concrete ways:

  • Planning. With Plan Mode, you review and modify the proposed approach before execution, including the methods, assumptions and steps the agent intends to perform. You can confirm the covariates, the handling of ties and the diagnostics you expect to see before any code runs.
  • Execution. PlotStudio AI supports Python and R workflows and is designed for survival analysis, Cox proportional hazards models and multiple-comparison procedures. It writes and runs real code, so the output is code you can read, not a one-shot answer.
  • Conventions. Skills encode how a lab or discipline approaches analysis, including statistical conventions and reporting expectations. A group can write down its rules once, such as how censoring is defined or which diagnostics must accompany every model.
  • Documentation. Completed work is kept as searchable Analysis Pages and can be exported as notebooks and PDF reports, so a supervisor, collaborator or reviewer can inspect how results were produced.
  • Privacy. Analyses can run locally on your machine, which suits clinical researchers who cannot upload patient data to conventional cloud analytics platforms, including those working with GDPR special category data.

If you were never trained to code, or you are learning R under a deadline, this is the practical gain: you work from the question and the plan, and you still end with the code and the diagnostics that a method section needs. The statistical judgment stays yours. You approve the plan and read the results.

The view from our side

Most tools for talking to a dataset are built to answer a question and stop. Survival analysis does not work that way. A single Cox model is the end of a chain: define time and events, examine censoring, choose covariates, fit, test proportionality, respond to a violation, then report. A one-shot answer skips the links that reviewers ask about.

That is why we built PlotStudio AI around the whole workflow. We want a researcher to see the plan, change it, watch real code run, and keep the methodology, statistics and charts together afterwards. We think this is becoming a must-have layer in the modern research toolkit, alongside R, Python, SAS, SPSS and Jupyter. Those tools compute. The agentic layer plans, executes, inspects, validates and documents a complete analysis.

For researchers whose data cannot leave their machine, local execution matters as much as the statistics. For labs that want every student to follow the same conventions, Skills matter. For anyone facing a reviewer, the reproducible record matters most.

Aymen

Try it on your own survival data

PlotStudio AI has a free trial, so you can bring a time-to-event dataset and see the plan, the code and the Cox output together. Paid plans are listed on the pricing page: Managed Credits is $69.99 per month and Bring Your Own Key is $39.99 per month. Researchers can also take Bring Your Own Key at $399.90 per year through the academic page.

Plotstudio

If your group wants a managed deployment, the enterprise page lists a one-off pilot fee of $500.

FAQ

What is the formula for the Cox proportional hazards model?

The hazard at time t is h(t|x) = h0(t) × exp(β1x1 + … + βpxp). Here h0(t) is the baseline hazard, which is left unspecified, and the βs are coefficients estimated by partial likelihood. Exponentiating a coefficient gives its hazard ratio.

How do I run a Cox model in R?

Load the survival package and use coxph(Surv(time, status) ~ covariates, data = d, ties = "efron"). Then read summary() for hazard ratios and confidence intervals, and run cox.zph() to check the proportional hazards assumption. Save the script so the analysis can be rerun.

How do I check the proportional hazards assumption?

Use scaled Schoenfeld residuals, log(-log) plots or Kaplan-Meier curves, as described in a review of testing methods. Schoenfeld residuals are the most informative in a multivariable model, because you read them covariate by covariate. Combine the formal test with the residual plot.

What does a hazard ratio of 0.72 mean?

It means the event rate in one group is 28% lower than in the reference group at any point in follow-up, after adjusting for the other covariates in the model. It does not mean 28% longer survival. Read it together with its 95% confidence interval.

Can I use PlotStudio AI instead of R for a Cox analysis?

PlotStudio AI works alongside R and Python rather than replacing them. It plans and runs the analysis as real code, keeps the methodology and outputs reviewable, and exports notebooks and PDF reports. You stay in control through Plan Mode.

Sources