Math calculator

Hazard Ratio Calculator

A hazard ratio, and which formula produced it.

Two formulas, one output

From a log-rank test with χ² = 3.8514 and p = 0.049705. The Peto one-step gives 3.1899 with a 95% interval of 1.0015 to 10.1602 — just excluding 1, exactly as the p-value just clears 0.05. The O/E ratio gives 2.6554, 16.75% lower, and carries no such guarantee.

O₁ = 8.000, E₁ = 4.6798, V = 2.8623

HR = 3.189887

95% interval 1.0015 to 10.1602, z = 1.9625, p = 0.049705. That is the Peto one-step form, exp((O₁ − E₁)/V), which is the one consistent with the log-rank test: log(HR) divided by its standard error IS the log-rank z, so this interval excludes 1 exactly when that test rejects. The simpler (O₁/E₁)/(O₂/E₂) gives 2.655441 — 16.75% lower — with no such guarantee.

Hazard ratio (Peto)

3.18989

consistent with the test

Hazard ratio (O/E)

2.65544

-16.75% from the Peto value

95% interval

1.0015 – 10.1602

excludes 1

Risk ratio

1.33333

a different quantity entirely

The two hazard-ratio formulas with what each guarantees
FormValueFormulaAgrees with the log-rank p?
Peto one-step3.189887exp((O₁ − E₁)/V)always — log(HR)/se is the log-rank z
O/E ratio2.655441(O₁/E₁) ÷ (O₂/E₂)not guaranteed

The two forms converge as the number of events grows — 16.75% apart on twelve-per-arm data and 1.31% apart at two hundred. The disagreement is a small-sample phenomenon, which is exactly the situation in which nobody checks.

A ratio of rates, not of risks Assumes the ratio is constant over time Says nothing about absolute benefit

What this tool shows

From one log-rank output the two standard formulas give 3.1899 and 2.6554 — 16.75% apart. Only the first is consistent with the p-value printed beside it: the Peto one-step exp((O₁−E₁)/V) has log(HR) divided by its standard error exactly equal to the log-rank z, so its interval excludes 1 precisely when the test rejects. On that data the interval is 1.0015 to 10.1602 against p = 0.049705, both just clearing the line.

  • The Peto one-step hazard ratio, exp((O₁ − E₁)/V), with its confidence interval
  • The simpler O/E ratio beside it, and the gap between them as a percentage
  • Why only one of the two is guaranteed to agree with the log-rank p-value
  • The risk ratio on the same counts, which is a different quantity
  • The z and p that follow from the interval, so nothing is quoted from a second source
  • Inputs taken straight off a log-rank table — no raw survival times needed
Both formulas Consistent interval Risk ratio beside it From log-rank output

Not medical advice. A hazard ratio is not a risk ratio.

Updated 13 September 2026 · Works in any browser, no installation

A hazard ratio compares the instantaneous event rate in one group against another, among those still event-free at that moment. It is a ratio of RATES conditional on survival, which is what makes it different from a risk ratio — a ratio of cumulative proportions. The distinction is not pedantic: on the tool’s fourth preset they are 1.3631 and 1.2418 from the same counts, and they diverge further as the outcome becomes more common.

At a glance

Formula shown
Peto one-step: HR = exp((O₁ − E₁)/V) with se(log HR) = 1/√V, so log(HR)/se = (O₁ − E₁)/√V — which is exactly the log-rank z. The interval is exp(log HR ± 1.96/√V). The alternative (O₁/E₁)/(O₂/E₂) is easier to write and is not tied to that pivot, so its interval and the log-rank p-value are computed from different quantities and need not agree.
Scenario support
Reporting a clinical trial result from published O/E and variance figures, meta-analysis of time-to-event trials, recomputing a hazard ratio a paper quoted without an interval, and understanding why a hazard ratio and a risk ratio from the same study differ.
Educational estimate
Planning support from the values you enter — not professional advice.

Only one of the two formulas agrees with the test

Both appear in textbooks and both are called “the hazard ratio from the log-rank test”. They are different estimators, and the difference is not cosmetic.

The Peto one-step is exp((O₁−E₁)/V). Its standard error is 1/√V, so log(HR) divided by that standard error is (O₁−E₁)/√V — which IS the log-rank z. The interval it produces excludes 1 exactly when the test rejects.

The O/E form is (O₁/E₁) ÷ (O₂/E₂). Easier to compute from a published table, and not tied to that pivot — so an interval built around it and the log-rank p-value come from different quantities.

On the shipped preset they are 3.1899 and 2.6554, 16.75% apart. A reader given the second alongside p = 0.049705 has two numbers that do not describe the same inference.

They converge as events accumulate. At twelve subjects per arm the gap is 16.75%; at two hundred per arm with 268 events it is 0.91%, and at five hundred per arm with 547 events, 0.03%. Which means the disagreement is largest in exactly the small studies where nobody checks it.

A hazard ratio is not a risk ratio

They are routinely reported as if interchangeable, and the difference is structural rather than a matter of precision.

A risk ratio compares cumulative proportions: what fraction of each group had the event by the end. It is a single number about a single endpoint in time.

A hazard ratio compares instantaneous rates, conditional on having survived to that moment. It is a rate at each instant, averaged over the follow-up — and the conditioning is what makes them different.

The hazard ratio is further from 1 than the risk ratio, always, when both are above or both below it. On the fourth preset, 1.3631 against 1.2418.

The gap widens as the event becomes common. With a rare outcome the two are nearly equal; with a common one the risk ratio is bounded by 1/baseline risk while the hazard ratio is not, so they can diverge by a great deal.

Which matters for patients, because neither says anything about absolute benefit. A hazard ratio of 0.5 on a 2% baseline risk saves one person in a hundred; the same ratio on a 40% baseline saves twenty. The number needed to treat is the number that carries that.

It assumes the ratio is constant, and often it is not

The whole idea of “the” hazard ratio presumes there is one number to report. That is the proportional-hazards assumption, and it fails in recognisable ways.

When the curves cross, the summary describes neither half. The tool’s third preset comes from a crossing-hazards example: 0.6880 with an interval from 0.2561 to 1.8479. The true ratio was far below 1 early and far above it late.

Treatments with a delayed effect break it routinely. Immunotherapy and vaccines often show nothing for months and then separate, so a single ratio averaged over the whole follow-up understates the eventual benefit.

And a surgical intervention often shows the reverse — early harm from the procedure, later benefit — which the same averaging hides.

The check is a Kaplan-Meier plot and the log-rank running total. If the running observed-minus-expected changes sign, no single ratio is honest, and the right report is the curves plus survival at pre-specified times.

Restricted mean survival difference is the principled alternative, because it makes no proportionality assumption and is in units anyone can read — months of life, not a ratio of rates.

The interval is where the information is

A hazard ratio quoted alone is nearly uninterpretable, and the interval is usually wider than the point estimate suggests.

On the shipped preset the point estimate is 3.1899 and the interval runs 1.0015 to 10.1602. A tenfold hazard is as compatible with that data as a null one.

The interval is symmetric on the LOG scale, not the original one. Which is why it looks lopsided: 3.19 is 3.2 times the lower limit and the upper limit is 3.2 times 3.19.

Its width depends only on the event count, through V. More participants who never have the event do not narrow it, which is the same fact that makes survival trials event-driven.

A borderline interval and a borderline p-value are the same statement, with the Peto form — here 1.0015 and 0.049705 both just clearing the line, which is what consistency looks like.

Where the five inputs come from

This tool takes summary numbers rather than raw survival times, which is deliberate: the commonest use is recomputing a hazard ratio from what a paper printed.

O₁ and O₂ are the observed event counts per arm, which almost every paper reports.

E₁ and E₂ are the expected counts under the null, summed across event times by the log-rank calculation. Papers reporting a log-rank test usually give them; the log-rank calculator produces them from raw times.

V is the accumulated hypergeometric variance, and it is the one most often missing. When it is, V ≈ E₁E₂/(E₁+E₂) is the usual approximation — 8.8% high on the twelve-per-arm preset and 1.1% high at two hundred, so it is a fallback for large trials rather than a substitute.

The two group sizes are optional and are used only for the risk-ratio comparison, which needs a denominator the hazard ratio does not.

Reporting a hazard ratio

Four things, and the second is what this page exists for.

Always give the interval. A hazard ratio without one is a point on a scale whose resolution is unstated, and the resolution is usually poor.

Say which estimator produced it. Peto one-step, O/E ratio and a Cox model give three different numbers, and only the first is guaranteed to agree with a log-rank p-value.

Say whether the hazards looked proportional, and show the curves. A single ratio over crossing hazards is a summary of two opposite findings.

And give an absolute measure beside it. A ratio says nothing about how many people are affected, and the absolute difference or the number needed to treat is what a reader actually needs.

Sources and methodology

References for hazard ratios and the one-step estimator.

Method. The primary estimator is the Peto one-step exp((O₁−E₁)/V) with standard error 1/√V, chosen because it is the form whose interval and the log-rank p-value are the same statement — log(HR)/se reduces algebraically to the log-rank z, and the suite asserts that equality numerically rather than relying on the algebra. The simpler O/E ratio is computed and printed beside it, with the percentage gap, because a hazard ratio quoted next to a p-value that came from a different pivot is a quiet inconsistency rather than a visible one. The interval is symmetric on the log scale and the z and p are derived from the same standard error, so nothing on the page comes from a second source. The risk ratio is computed only when both group sizes are supplied, since it needs a denominator the hazard ratio does not. A zero expected count or a non-positive variance returns no result. That engine is verified on every change against 87 assertions. The count and the per-case breakdown are published on the formula verification page.

Related calculators

Where this goes next:

Log-Rank TestObserved minus expected accumulated at every event time, so the crossing-hazards blind spot is visible: a running total that peaks at +3.2652 and ends at -1.4717 gives p = 0.458065.
Kaplan-MeierSurvival with censoring handled, and the naive count printed beside it: five events in twenty subjects give 25.0000% by the plain count and a 30.1202% cumulative incidence by Kaplan-Meier.
Relative RiskRisk ratio and odds ratio from one table with the divergence between them plotted: they agree to half a percent at a 1% baseline, and at an 80% baseline the odds ratio is exactly half the risk ratio.
Number Needed to TreatNNT from the absolute risk reduction, with the relative figure beside it — two trials reporting the identical “50% reduction” have NNTs of 7 and 1,000, and the common shortcut says 2 for both.
Odds RatioOdds ratio, relative risk, risk difference and number needed to treat from one 2x2 table — because an odds ratio of 6.00 can describe a relative risk of 1.50.
Incidence RateEvents per person-time with the exact Poisson interval, including at zero events: the exact two-sided upper limit is 3.688879 per unit of person-time, not the 3 the one-sided rule of three gives.

More in Math, or browse all calculators.

Educational use disclaimer

An educational tool, not medical advice. A hazard ratio summarises a ratio of instantaneous rates over the whole follow-up, which presumes that ratio was roughly constant — when the curves cross, no single value describes the study. It is also not a risk ratio and carries no information about absolute benefit.

How we calculate · Found an error? email us

Authorship & verification

Written and maintained by , a business operator who builds spreadsheet-based calculators.

What's changed (5 updates)

Published 13 September 2026

  1. Published a hazard-ratio tool that takes the five summary numbers off a log-rank table rather than raw survival times, because the commonest use is recomputing a ratio a paper printed without an interval.
  2. Made the choice of formula explicit and consequential. The Peto one-step exp((O₁−E₁)/V) and the simpler (O₁/E₁)/(O₂/E₂) give 3.1899 and 2.6554 from the same output — 16.75% apart — and only the first has log(HR)/se equal to the log-rank z, so only the first produces an interval that excludes 1 exactly when the test rejects. Asserted numerically across 120 generated trials to better than 1e-12.
  3. Showed the gap closing as events accumulate: 16.75% at twelve per arm, 0.91% at two hundred per arm with 268 events, 0.03% at five hundred per arm with 547. The disagreement is a small-sample phenomenon, which is when nobody checks it.
  4. Printed the risk ratio on the same counts — 1.3631 against 1.2418 on the common-outcome preset — because a hazard ratio is a ratio of instantaneous rates among those still at risk and a risk ratio is a ratio of cumulative totals.
  5. Verified that the interval is exactly symmetric on the log scale across 100 generated inputs, and that the standalone entry point agrees with the log-rank one to machine precision.

Add this calculator to your site

Responsive embed — and private: nothing your visitors type leaves their browser.