Hazard Ratio Calculator
Paste one row per time period with the events and the number at risk in a treatment and a control group. The calculator returns the average hazard ratio, its confidence intervals at the level you choose, the chi-square statistic and the p-value.
Related calculators
Created by the Reeliy Editorial Team. Last updated: Oct 19, 2026
Using the hazard ratio calculator
The tool compares how fast events happen in a treatment group and a control group. Instead of a single 2×2 table it takes one row per time period, for example one row per week or per month of follow-up. Each row needs exactly five numbers, separated by spaces, commas or tabs:
- the time (a label for the period; it is not used in the arithmetic)
- events in the treatment group during the period
- number at risk in the treatment group at the start of the period
- events in the control group during the period
- number at risk in the control group at the start of the period
Copying the five columns straight from a spreadsheet works, as long as you leave out the header row and use a dot for decimals. Censored subjects, those who left the study without an event, must be removed from the number at risk in the next period, otherwise the groups look larger than they really were. Pick a confidence level (95 by default) and press the button.
The output is the hazard ratio, a two-sided confidence interval, a left-sided and a right-sided interval, the two-sided p-value and the chi-square statistic with one degree of freedom.
These are statistical estimates of the data you enter, not medical advice. See the disclaimer.
What is a hazard ratio?
The hazard is the instantaneous rate at which events occur among the people still event-free at a given moment. The hazard ratio (HR, also called relative hazard) divides the hazard in the treatment group by the hazard in the control group. Viewed within a single short period it behaves like a risk ratio, which is why it is sometimes described as an instantaneous relative risk.
This calculator reports the average hazard ratio over all periods. For each period it works out how many events each group would be expected to have if the two groups were identical, sharing the period's events in proportion to how many people each group has at risk:
expected in treatment = events in period × at risk (treatment) ÷ total at risk
Adding the observed events (O) and the expected events (E) over all periods gives one pair per group, and the estimate is the ratio of the two observed-to-expected ratios:
HR = (O_treatment ÷ E_treatment) ÷ (O_control ÷ E_control)
The chi-square statistic adds up how far each group's observed count is from its expected count: χ² = Σ (O − E)² ÷ E over the two groups, compared with a chi-square distribution with one degree of freedom. This is the same idea as the log-rank test, which is why the p-value is a log-rank style p-value.
How to interpret a hazard ratio
- HR = 1: the two groups have the same event rate over time.
- HR < 1: events happen more slowly in the treatment group. An HR of 0.5 means that, at any moment, a treated person who has not yet had the event is about half as likely to have it next as a comparable control.
- HR > 1: events happen faster in the treatment group.
If the event is something good, such as recovery, the reading flips: an HR above 1 is then favourable. Swapping which group you call treatment inverts the ratio, so 0.5 becomes 2.
Be careful with two things. The HR is an average over follow-up and says nothing about how large the gain is in time: two pairs of survival curves can share an HR of 0.5 and still differ greatly in median survival. And it does not mean the treated group is half as likely to experience the event overall; it is a statement about rates, not about the share of people affected at the end.
Worked example
Three monthly rows: month 1 has 3 events among 60 at risk in the treatment group and 5 among 58 in the control group; month 2 has 2 of 55 against 4 of 52; month 3 has 1 of 50 against 3 of 47.
| Month | Events (all) | At risk (all) | Expected, treatment | Expected, control |
|---|---|---|---|---|
| 1 | 8 | 118 | 8 × 60 ÷ 118 = 4.068 | 8 × 58 ÷ 118 = 3.932 |
| 2 | 6 | 107 | 6 × 55 ÷ 107 = 3.084 | 6 × 52 ÷ 107 = 2.916 |
| 3 | 4 | 97 | 4 × 50 ÷ 97 = 2.062 | 4 × 47 ÷ 97 = 1.938 |
Totals: observed 6 in treatment and 12 in control; expected 9.214 and 8.786. Then HR = (6 ÷ 9.214) ÷ (12 ÷ 8.786) = 0.6512 ÷ 1.3658 ≈ 0.4768, and χ² = (6 − 9.214)² ÷ 9.214 + (12 − 8.786)² ÷ 8.786 ≈ 2.296, which gives p ≈ 0.130. The standard error of ln(HR) is √(1/9.214 + 1/8.786) ≈ 0.4715, so the 95% interval is exp(ln 0.4768 ± 1.96 × 0.4715), about 0.189 to 1.201. The interval contains 1: with this little data, the apparent benefit is not statistically distinguishable from no effect.
Hazard ratio versus risk ratio
A risk ratio compares the share of people who have had the event by a fixed end point. A hazard ratio compares event rates continuously and uses the timing of events and the people who were lost to follow-up. Two studies can end with the same cumulative risk and very different hazard ratios if events cluster early in one of them. When you only have final counts, the relative risk calculator or the odds ratio calculator is the right tool; when you know when events happened, use hazard ratios.
For a regression-based hazard ratio that adjusts for age, dose or other covariates you need a Cox proportional hazards model. The simple observed-over-expected estimate used here is usually very close to the Cox result when there are only two groups.
Standard error and confidence interval formula
Like ratios of odds or risks, the hazard ratio is skewed, so the interval is built on the log scale and converted back:
SE = √(1/E_treatment + 1/E_control)
interval = exp( ln(HR) ± z × SE )z = 1.96 for a 95% two-sided interval
A left-sided interval gives only a lower limit and a right-sided interval gives only an upper limit. They use the one-sided critical value, 1.645 at the 95% level, rather than 1.96, and are appropriate only when a difference in one direction was the sole question before you looked at the data. Otherwise use the two-sided interval. See the confidence interval calculator for intervals on other quantities.
Assumptions and common mistakes
- No events in one group. If the control group (or the treatment group in every row) has no events the ratio cannot be formed; the calculator reports a division by zero.
- Forgetting censoring. Number at risk should shrink for dropouts, not only for events.
- Independent groups. Subjects must belong to one group only, and periods should not overlap.
- Few events. Intervals from a handful of events are very wide, and the normal approximation behind them is rough.
- Proportional hazards. The average HR is easiest to interpret when the true ratio is roughly constant over time. The test still works if it is not, but a single number then hides the pattern; plot the survival curves.
Frequently asked questions
What does a hazard ratio of 0.5 mean?
At any point in follow-up, among people who have not yet had the event, those in the treatment group experience it at about half the rate of those in the control group. It describes the rate of events, not the percentage of people affected, and not how much longer people survive.
Is a hazard ratio the same as relative risk?
Not exactly. Relative risk compares cumulative proportions at a fixed time, while the hazard ratio compares instantaneous event rates over the whole follow-up. They are similar for rare events and short follow-up.
What do I enter for number at risk?
The number of people in the group who are still being followed and event-free at the start of the period. Subtract anyone who dropped out or was censored in earlier periods.
How do I know whether the hazard ratio is significant?
Look at whether the confidence interval includes 1 and at the p-value. If the two-sided interval excludes 1, or the p-value is below your chosen threshold such as 0.05, the data are inconsistent with equal hazards at that level.
References
- Bland JM, Altman DG. The logrank test. BMJ 2004;328:1073.
- Cox DR. Regression models and life-tables. Journal of the Royal Statistical Society, Series B 1972;34:187-220.
- Peto R, Pike MC, Armitage P, et al. Design and analysis of randomized clinical trials requiring prolonged observation of each patient. II. Analysis and examples. British Journal of Cancer 1977;35:1-39.
Cite this calculator and page
If you use this page in your work, you can cite it as:
Reeliy Editorial Team. (2026). Hazard Ratio Calculator. Reeliy. https://reeliy.com/calculators/hazard-ratio-calculator“Hazard Ratio Calculator.” Reeliy, 2026, https://reeliy.com/calculators/hazard-ratio-calculator.