What this calculator gives you

From a 2×2 table it gives every common measure of association: the risk in each group, the relative risk, the absolute risk difference, the number needed to treat (NNT) and the odds ratio, each with a confidence interval, plus chi-square and Fisher’s exact test. Use it for trials, cohort studies and any comparison of two proportions. For case-control studies, where risks cannot be estimated, use the odds ratio calculator.

Worked example

In a trial, 12 of 150 patients on a new treatment developed an infection, against 30 of 150 on the standard treatment.

Relative or absolute?

A 60% relative reduction sounds impressive whether the risk falls from 20% to 8% or from 0.02% to 0.008%. The absolute difference and the NNT show what it means in practice, which is why many journals ask for both. See relative risk vs odds ratio.

Methods

Accuracy

RR, OR and their intervals match statsmodels’ Table2x2, the Newcombe and Wald intervals match statsmodels’ confint_proportions_2indep, and the p-values match SciPy, on 37 tables.

Frequently asked questions

How do I calculate relative risk?

Divide the risk in the exposed group by the risk in the unexposed group. With 12 of 150 against 30 of 150: 0.08 / 0.20 = 0.40.

What is the number needed to treat?

The number of people who must receive the treatment instead of the control for one more person to benefit. It is 1 divided by the absolute risk difference, rounded up.

When should I use the odds ratio instead?

In case-control studies, where you choose people by outcome and cannot estimate risks, and in logistic regression. Otherwise the relative risk is easier to interpret.

What if a cell is zero?

The relative risk or odds ratio would be 0 or infinite, so the calculator adds 0.5 to every cell before computing them, and you should report Fisher's exact test.