Free tool · Reference · 2x2 tableUpdated October 17, 2026

Relative risk and odds ratio calculator for a 2x2 table

Enter four counts and get relative risk, odds ratio, risk difference, number needed to treat and 95% intervals by the log method, with a worked example and a plain-language rule for when the odds ratio overstates the risk ratio.

  • RR, OR, risk difference and NNT
  • Log-method 95% intervals
  • Zero-cell and small-count notes

Free sandbox · No credit card · 21 CFR Part 11 aligned

Demo: responders 30/100 on treatment, 15/100 on control

Relative risk (95% CI)

2.00 (1.15 to 3.48)

Odds ratio (95% CI)

2.43 (1.21 to 4.87)

Risk difference / NNT

15 pts / 7

Treatment: responders30/100

30%

Control: responders15/100

15%

The OR (2.43) is further from 1 than the RR (2.00) because response is not rare.

The short answer

  • From a 2x2 table with cells a, b (treated: event, no event) and c, d (control): RR = [a/(a+b)] / [c/(c+d)], OR = (a × d) / (b × c), risk difference = a/(a+b) − c/(c+d), and NNT = 1 / risk difference.
  • Worked example: 30 of 100 respond on treatment and 15 of 100 on control. RR 2.00 (95% CI 1.15 to 3.48), OR 2.43 (1.21 to 4.87), risk difference 15 percentage points (3.6 to 26.4), NNT 7 (about 4 to 28).
  • Intervals for RR and OR are built on the log scale: exp(ln RR ± 1.96 × SE), with SE(ln RR) = √[1/a − 1/(a+b) + 1/c − 1/(c+d)] and SE(ln OR) = √[1/a + 1/b + 1/c + 1/d].
  • The OR is always further from 1 than the RR. They are nearly equal when the outcome is rare (under about 10%) and diverge when it is common: a true RR of 1.5 gives an OR of 2.25 when the control risk is 40%.
  • A zero cell makes the OR undefined or infinite. A 0.5 continuity correction (Haldane–Anscombe) is a common fix, but it is a patch, and exact methods are preferable with few events. Ask a statistician.

The 2x2 table

Worked example: treatment response, 100 per arm

The event is "responder". The counts are demo data.

Event (responder)No eventTotalRisk
Treatment30 (a)70 (b)1000.30
Control15 (c)85 (d)1000.15

RR = 0.30 / 0.15 = 2.00. OR = (30 × 85) / (70 × 15) = 2550 / 1050 = 2.43. Risk difference = 0.15.

The calculation

Each measure, its interval and what it answers

The four measures answer different questions from the same table. Relative risk (risk ratio) asks "how many times as likely is the event in the treated group?": here 2.00. Odds ratio compares the odds of the event, odds being the event count over the non-event count, 30/70 against 15/85, which is 2.43. Risk difference (absolute risk reduction or increase) asks "how many more events per 100 people?": 15. Number needed to treat is its reciprocal, the number of people treated for one additional responder: 1 / 0.15 = 6.67, rounded up to 7 by convention (Laupacis, Sackett and Roberts, 1988). The number needed to treat calculator covers the interpretation and the interval in more detail.

For the intervals, take the natural log, add and subtract 1.96 standard errors, and exponentiate. For the RR, SE(ln RR) = √(1/30 − 1/100 + 1/15 − 1/100) = 0.283, so the interval is exp(0.693 ± 1.96 × 0.283) = 1.15 to 3.48. For the OR, SE(ln OR) = √(1/30 + 1/70 + 1/15 + 1/85) = 0.355, giving exp(0.887 ± 1.96 × 0.355) = 1.21 to 4.87. The risk difference uses a plain normal interval, SE = √[0.30 × 0.70/100 + 0.15 × 0.85/100] = 0.058, so 0.15 ± 0.114, or 0.036 to 0.264. The NNT interval is the reciprocal of those limits, 1/0.264 to 1/0.036, about 4 to 28. When the risk-difference interval would include zero, the NNT interval does not exist in the usual sense (it passes through infinity), which is why papers report it carefully.

These are Wald-type intervals, adequate with a reasonable number of events in every cell. With few events they can be too narrow or too wide, and a statistician may prefer Newcombe, exact or profile-likelihood methods. Take the same 100-per-arm design but with 8 responders versus 2: the RR is 4.00 (0.87 to 18.4) and the OR is 4.26 (0.88 to 20.6). The point estimates look dramatic, the intervals include 1, and a single patient moving from one cell to another would change the picture. Report intervals alongside the estimates, and read an estimate from a handful of events with suspicion.

When the OR overstates the RR

The odds ratio that corresponds to a true relative risk of 1.5

OR = RR × (1 − control risk) / (1 − RR × control risk). The table fixes RR at 1.5 and varies the risk in the control group.

Control riskTreated risk (RR 1.5)Odds ratioOR is higher than RR by
1%1.5%1.510.5%
5%7.5%1.543%
10%15%1.596%
20%30%1.7114%
40%60%2.2550%

Illustrative values from the identity above. The same pattern holds below 1: an RR of 0.5 corresponds to an OR of 0.497 at 1% control risk and 0.375 at 40%.

Choosing and reporting

Which measure to report, and how not to misread an odds ratio

The odds ratio is not wrong, but it is easy to misread. Readers interpret "OR 2.25" as "2.25 times as likely", which is true of the risk ratio, not the odds ratio. In the 40% control-risk row, an OR of 2.25 describes a risk that is only 1.5 times higher (60% against 40%). The gap is small below about 10% and large above 20%, so for common outcomes such as response, remission or retention, a trial that reports an odds ratio should also give the risks in each arm. Zhang and Yu (1998) showed how often OR-based text overstates the effect in cohort data with common outcomes.

Design determines what is estimable. A randomised trial or cohort study follows exposed and unexposed groups and can estimate the RR, the risk difference and the NNT directly. A case-control study samples by outcome, so risks are not available; the OR is estimable and approximates the RR only if the outcome is rare in the source population. Logistic regression returns adjusted odds ratios, and if the outcome is common you may want a log-binomial or modified Poisson model for an adjusted RR instead. Those choices belong in the statistical analysis plan, with a statistician.

A zero cell is a different problem. Suppose 0 of 50 patients on treatment and 5 of 50 on control have the event (a 2x2 table with a = 0). The odds ratio is zero, its standard error is infinite and the log method fails. Adding 0.5 to every cell gives an OR of 0.082 with a 95% interval of 0.004 to 1.52, and the risk difference is −0.10 (Wald −0.18 to −0.02, which is itself unreliable with a zero count). The correction changes the answer, and the choice of correction should be stated. With zeros present, exact tests and exact confidence intervals are the better route.

Three further points keep the 2x2 table honest. First, the table counts people with the event at a fixed time and ignores when events happened; if follow-up differs between arms or the endpoint is time to event, a hazard ratio from a survival analysis is the right measure, and the survival sample size calculator belongs to that design. Second, define who is in the denominator: the intention-to-treat population, with a rule for missing outcomes, gives a different table from a completers-only count, and the difference is exactly what the dropout discussion in the dropout-adjusted sample size calculator is about. Third, if randomisation was stratified or the data come from several centres, a single pooled table can mislead, and a stratified estimate such as Mantel–Haenszel is preferable. Reporting guidance for randomised trials (CONSORT) asks for the absolute and the relative effect for binary outcomes, which is why this page gives all four measures together.

Count the events cleanly before you compute the ratio

Build the eCRFs, edit checks and visit schedule in the free sandbox with every feature. No credit card, no time limit. You pay only when you go live with real participants.

Build your study free

Getting the 2x2 table from the study

Turning eCRF data into the four cells

A ratio is only as reliable as the event definition behind the four counts. In Capture, the event is built as a field on an eCRF, often a single-choice responder flag or a derived value, and a calculated field can derive the classification (for example "percent change in score of at least 30%") from two entered values and show it read-only, so every site applies the same rule. Range and custom edit checks raise an auto-query when entries conflict, query management tracks them to resolution, and the field-level audit trail records the old value, new value and reason for any change, so the events counted at database lock can be traced.

Randomised allocation is recorded through randomization, blinded roles never receive treatment-arm values, and the export supplies the arm and the event flag in a wide CSV or Excel file with a data dictionary for tabulation, or as SDTM datasets (SAS XPT with Define-XML). For safety outcomes the same table applies to adverse-event incidence, and the adverse event reporting software page describes how events are captured. If the endpoint is a rate you must plan, the two-proportions sample size calculator sizes the study, and the Cohen’s kappa calculator checks whether two reviewers classify events consistently before you count them.

Decision rule

Which measure to use and report

Randomised trial or cohort, binary outcome

Report the risk in each arm, the RR with its interval and the risk difference. Add the NNT when the difference is clearly non-zero.

Case-control study

Report the OR with its interval; do not call it a risk ratio or compute risks from the sample.

Outcome common (control risk above about 10%)

Prefer RR and risk difference; if an OR is reported, show the arm risks beside it.

Any cell below about 5 events

Treat Wald intervals with caution and ask for an exact or Newcombe interval.

A zero cell

State the correction used, or use an exact method; do not report the corrected OR as if it were observed.

Adjusted analysis

Pre-specify the model (logistic, log-binomial, modified Poisson) in the SAP and confirm with a statistician.

FAQ

Questions teams ask before they switch

Something not covered here? Ask us directly.

What is the difference between relative risk and odds ratio?

Relative risk compares the probability of the event in two groups (30% against 15% gives 2.00). The odds ratio compares the odds (30/70 against 15/85 gives 2.43). They are close when the event is rare and diverge as it becomes common.

How do I calculate relative risk from a 2x2 table?

With a and b the event and non-event counts in the exposed or treated group and c and d in the comparison group: RR = [a/(a+b)] / [c/(c+d)]. In the worked example it is 0.30 / 0.15 = 2.00.

How is the 95% confidence interval for RR calculated?

On the log scale: exp(ln RR ± 1.96 × SE), with SE(ln RR) = √[1/a − 1/(a+b) + 1/c − 1/(c+d)]. For the example, SE is 0.283 and the interval is 1.15 to 3.48. The odds ratio interval uses SE(ln OR) = √(1/a + 1/b + 1/c + 1/d).

When does the odds ratio overstate the relative risk?

When the outcome is common. At 1% control risk an RR of 1.5 corresponds to an OR of 1.51; at 40% control risk the same RR corresponds to an OR of 2.25. Below about 10% the two are close. Always give the risks in each arm.

How do I get the number needed to treat?

NNT = 1 / absolute risk difference, rounded up. A 15-point difference gives 6.67, so 7. The interval is the reciprocal of the risk-difference limits (here about 4 to 28) and is only well defined if the risk-difference interval excludes zero.

What do I do if a cell is zero?

The odds ratio is undefined with a zero cell. A 0.5 continuity correction (Haldane–Anscombe) gives a finite estimate, but it alters the result and should be disclosed. Exact methods are preferable when events are few; discuss with a statistician.

Can I use these formulas for a case-control study?

You can compute the OR and its interval, but risks, RR, risk difference and NNT are not estimable from a design that samples by outcome. The OR approximates the RR only when the outcome is rare in the source population.

Is this calculator validated?

No. The worked values were reproduced with an independent script, but this page is a reference aid, not validated software. A statistician should confirm the interval method and any adjusted analysis before results are reported.

Capture the events, then calculate the effect

Build the eCRFs, edit checks and visit schedule in the free sandbox with every feature. No credit card, no time limit. You pay only when you go live with real participants.

Build your study free