Cox Proportional Hazards Regression calculator
Fit Cox proportional hazards regression models online. Calculate hazard ratios, confidence intervals, and test proportionality assumptions.
What it does
Models how covariates shift the risk of an event over time, without assuming any particular shape for the underlying risk. Coefficients exponentiate to hazard ratios: a hazard ratio of 2 means roughly twice the rate of events at any given moment, not twice the total risk and not half the survival time.
When to use it
Time-to-event data where you want the effect of one variable adjusted for others.
Cautions
- Proportional hazards is an assumption, and the whole model rests on it: the hazard ratio is taken to be the same at every point in follow-up. In plain terms, the groups' survival curves should stay roughly parallel and must not cross.
- You do not have to eyeball it. Inference Stats runs the Grambsch-Therneau test (the equivalent of R's cox.zph, validated against lifelines) and reports it with the fit, so a violation is flagged rather than left for you to notice.
- If it fails, do not report a single hazard ratio — it averages an effect that genuinely changes over time, and the average may describe no period of the study. Switch to restricted mean survival time, which needs no such assumption and reports a difference in event-free months that a reader can act on, or fit the covariate as time-varying.
- A hazard ratio is not a risk ratio and is not a difference in survival time.
- Events per variable is the binding constraint on how many covariates you can include, not the number of subjects.
Alternatives
- Log-rank test — you only need an unadjusted comparison between groups
- Fine-Gray / cumulative incidence — a competing event is present and you want real-world probability rather than cause-specific hazard
How to read the output
- Hazard ratio (HR) and its 95% CI
- The multiplicative change in the instantaneous event rate per one-unit increase in the predictor, holding the others fixed. Above 1 is faster, below 1 is slower; an interval excluding 1 means the direction is determined. A HR is not a risk ratio and not a ratio of survival times. HR 0.5 does not mean half the events or twice the survival. Translate it for a reader by showing the two survival curves, or by quoting the difference in restricted mean survival in real time units.
- Schoenfeld test (proportional-hazards assumption)
- Cox assumes each HR is constant over follow-up. This tests that per covariate and globally: a small p means the effect changes with time, so the single HR is an average over a moving target. A significant global test does not invalidate the fit, but it does invalidate the sentence 'the hazard ratio was X'. Report the effect over intervals, stratify by the offending variable, or switch to RMST. The residual plot shows the shape of the drift — a clear trend is more informative than the p-value.
- Efron partial likelihood, n
- The estimation method and the number of complete rows used. The partial likelihood uses only the ORDER of the event times, which is why no shape has to be assumed for the baseline hazard. n here is complete cases for the covariates you ticked. Adding a covariate with scattered missingness silently shrinks the sample the whole model is fitted on.
- Non-convergence
- Reported when the fit fails, which usually means monotone likelihood — a covariate that separates the event perfectly. The estimates on a non-converged fit are not usable. Remove or rescale the offending covariate; a categorical level in which everyone (or nobody) had the event is the common cause.
- Stratified baseline, when set
- Each stratum gets its own baseline hazard, and the covariate effects are pooled across them. A stratifying variable gets no hazard ratio, by construction. If you need its effect estimated, it must be a covariate rather than a stratum.
- The number-at-risk table
- How many patients remain under observation at each time point. It is the honest scale of the curve above it. Read the curve only as far as the numbers support. The right-hand tail is estimated from a handful of patients — a step there moves the line a long way and means almost nothing. If the table reads 4, 2, 1, do not quote survival at that time.
How this calculator is validated · Which statistical test should I use?