Bell Statistics

Non-inferiority calculator: two proportions

Plan and read the test that asks whether a new variant's conversion, retention or opt-in rate is worse by more than you are prepared to accept. Supply the margin in percentage points and the direction that counts as worse; the calculator returns the sample size, then the one-sided p-value and the confidence bound.

Allon Korem

Written by Allon Korem

Chief Executive Officer

Last updated

Calculator

Says what “worse” means. There is no safe default.

A proportion, so 0.34 is 34%.

0.015 is 1.5 percentage points.

p₁ − p₂. 0 assumes exact parity.

n₂ ÷ n₁. 1 is an even split.

One-sided. 0.05 in product work, 0.025 in trials.

A planning assumption only. Published tables use the pooled form.

Required sample size for non-inferiority
Per group12,333
Group 212,333
Total24,666
Achieved powerAt the whole-number sample above.80.0%
Textbook closed form, per group(z₁₋ₐ + z₁₋ᵦ)² × the chosen variance term ÷ Δ², rounded up. The same model as above, without the integer search.12,333
Assumed rate, group 134.00%
Assumed rate, group 234.00%
Assumed true differencep₁ − p₂ as a share of the reference rate.0.0%
Room to the marginThe distance the study has to work with, on the margin's scale.0.01500

You need 24,666 observations in total for the study to conclude that group 1's rate is not more than 0.0150 (1.50%) *below* group 2's 80.0% of the time, if the truth is what you assumed. The quantity being powered is the 0.0150 of room between that assumption and the margin, not the margin on its own — so an assumed shortfall of even a fifth of the margin adds half again to the sample. For a change made to save money the honest assumption is usually not exact parity, and it belongs in the field above rather than in a footnote.

  • Sized for a test that group 1's rate is not more than the margin *below* group 2's, with a higher rate the better outcome.
Sample size per group against statistical powerReaching 5.2% power takes 1 per group and 96.9% takes 24,515; the 80.0% target is met at 12,333.5,00010,00015,00020,0000%25%50%75%100%PowerSample size — per group80.0% → 12,333

Drag the dashed line — or focus it and use the arrow keys — to change the target power and resize the study.

Show these numbers as a table
Power at each sample size per group
PowerSample size
5.2%1
26.5%2,061
41.8%4,121
54.6%6,181
65.1%8,241
73.5%10,301
80.1%12,361
85.2%14,421
89.1%16,481
92.0%18,541
94.2%20,601
95.8%22,661
Required sample per group against non-inferiority marginDetecting 0.68% takes 60,008 and 20.40% takes 67. At the 1.50% currently entered it is 12,333 — the requirement falls roughly as the square of the effect.1001,00010,0002.00%4.00%6.00%8.00%10.00%12.00%14.00%16.00%18.00%20.00%Non-inferiority marginRequired sample per group (log scale)1.50% → 12,333

Drag the dashed line — or focus it and use the arrow keys — to change non-inferiority margin.

Show these numbers as a table
Required sample per group against non-inferiority margin
Non-inferiority marginRequired sample per group
0.68%60,008
2.70%3,799
4.73%1,243
6.75%610
8.77%361
10.79%239
12.82%169
14.84%127
16.86%98
18.88%78

When to use it

This is the guardrail test for rate metrics. You are shortening a signup flow, dropping a field from a form, replacing a vendor's widget with your own — the change pays for itself in speed or maintenance, and the only question is whether conversion or retention takes a hit big enough to cancel that out. Non-inferiority makes it answerable: name the hit you could absorb, then require positive evidence that the true loss is smaller.

Running a standard A/B test instead and shipping on a non-significant result is the failure this page exists to prevent. Non-significance is a statement about your sample size, not about the rates, and guardrails are structurally prone to being underpowered: usually an afterthought on a change already approved, given a slice of traffic and a fortnight. The less carefully you run one, the likelier the reassuring answer — see when being good enough is enough.

Use two-sided equivalence for two proportions when moving in the good direction would also be a red flag: an opt-in rate that jumps after a consent redesign may mean the new wording is not doing its job. Use non-inferiority for two means for continuous outcomes. If the same users saw both variants the counts are correlated, and McNemar's test is the right starting point. If the question is only how precisely you have measured one rate, use a proportion confidence interval.

Assumptions

Two arms of independent Bernoulli trials, a normal approximation to their difference, and three design conditions that matter more than the arithmetic:

  • The direction switch matches your metric. Conversion, retention and opt-in are higher-is-better; churn, bounce, refund and error rates are lower-is-better. Set it wrong and the test still returns a clean p-value: it is testing the opposite hypothesis, and nothing in the output reveals it.
  • The margin is agreed in writing before launch, in the units the plan is written in. One percentage point on a 34% rate is a 3% relative loss; on a 3% rate it is a third of the business. Decide absolute or relative once, and do not let the readout switch framings to make the bound clear.
  • Independence, one observation per randomised unit. Repeat sessions from the same user shrink the standard error, which moves the bound towards the margin you are trying to clear — that is, towards passing. See randomization: the ABCs of A/B testing.
  • Enough events per arm for the normal approximation, rarely the binding constraint in a properly sized study. Very rare outcomes are the exception, and Fisher's exact test is the better place to start.
  • Nothing in the execution blurs the two arms. Contamination, mis-assignment and a noisy outcome definition all drag the observed difference towards zero, which in a superiority test costs power and here hands you the conclusion you hoped for.

How the calculation works

The estimate is the plain difference in observed rates, and the null is shifted to the margin rather than sitting at zero. There is a genuine choice of standard error here that the means case does not have: the simple version substitutes the observed rates, while Farrington–Manning uses the rates that maximise the likelihood subject to the difference being exactly the margin. The second is what the sample-size formula is calibrated against. Everything below assumes higher is better.

Hypotheses (higher is better)
H₀: p₁ − p₂ ≤ −Δ vs H₁: p₁ − p₂ > −Δ

p₁ is the new variant. The null says it is worse by at least the margin, so the change has to earn its way past — the reverse of the usual burden of proof.

Test statistic, sample standard error
z = (d + Δ) / √(p̂₁(1−p̂₁)/n₁ + p̂₂(1−p̂₂)/n₂)

Unpooled: under the null the rates differ by Δ, so a pooled estimate would be estimating something the hypothesis does not claim exists.

Test statistic, Farrington–Manning
z = (d + Δ) / √(p̃₁(1−p̃₁)/n₁ + p̃₂(1−p̃₂)/n₂)

p̃₁ and p̃₂ are maximum-likelihood estimates constrained to p̃₁ − p̃₂ = −Δ, available in closed form. The default here, and the version whose type I error stays closest to nominal at moderate sample sizes.

Confidence bound
d − z₁₋α · SE > −Δ

Report this rather than the p-value: the one-sided 95% lower bound is the number a stakeholder can weigh against the saving, and it coincides with the lower limit of the two-sided 90% interval.

Sample size per arm
n = (z₁₋α + z₁₋β)² · [p₁(1−p₁) + p₂(1−p₂)] / (Δ + d₀)²

d₀ is the signed difference you expect, negative if the variant will probably lose a little. Leaving it at zero produces the cheapest design and the one most likely to run out of room.

Lower is better
z = (Δ − d) / SE, bound: d + z₁₋α · SE < Δ

For churn, refunds, bounce and error rates: same margin, same α, hypotheses reflected. A wrong switch converts a failed guardrail into a passed one without changing anything you would notice.

Worked example

Onboarding currently ends with a four-minute product video. You want to replace it with a 40-second interactive tour, cheaper to maintain and to localise. Day-7 retention is the guardrail: it sits at 34%, and product has agreed that losing up to 1.5 percentage points is an acceptable price. You are willing to assume the tour performs about as well as the video.

Direction
Higher is better
Baseline day-7 retention
34.0%
Non-inferiority margin (Δ)
1.5 percentage points
Assumed true difference (d₀)
0.0 percentage points
Significance level (α)
0.05, one-sided
Power (1 − β)
0.80

About 12,300 users per arm, roughly 24,700 in total. At a one-sided α of 0.025 the same design asks for about 15,700 per arm, and assuming the tour loses 0.3 points rather than nothing pushes it to about 19,200.

The third number is the one to argue about before launch. A 0.3-point assumed shortfall is a fifth of the margin and adds more than half again to the sample, because power depends on the gap between the truth and the margin, not on the margin alone. If your honest expectation is that the shorter tour will be slightly worse — and for a change made to save money it usually is — planning against exact parity is planning to run out of room. What makes guardrails expensive is that the margin people can live with is almost always far tighter than the improvement they would have chased.

Interpreting the output

The claim you have earned is bounded and directional: with 95% confidence the new rate is not lower than the old by more than Δ. That is not "the rates are the same", and it says nothing about the upside. Quote the bound and the margin together and the sentence survives being forwarded: "the 95% lower bound is −0.9 points against an agreed margin of −1.5".

Keep the point estimate beside it. If the observed difference is −0.8 points, that is your best guess at what shipping costs, and on a large base it may be substantial even though the test passed. A guardrail confirms the loss is survivable; it does not make it disappear. The gap between test-time and real-world effects is covered in why the uplift in A/B tests often differs from real-world results.

If the bound misses the margin you have not proved harm — you have failed to rule it out, and only one of those justifies abandoning the change. Usually the honest reading is that the test was too small, and the options are more traffic, a longer window, or a genuine renegotiation with the people who set the margin. What is not an option is relaxing it after seeing the bound.

Watch the drift across successive changes too. Each variant judged non-inferior to the one before gives away a further margin, and four such decisions can leave the experience meaningfully worse than the original while every test passed. Compare against a preserved baseline, not the previous winner. If you want that built into a programme rather than reinvented per test, that is what our A/B testing practice does — get in touch.

Frequently asked questions

Does it matter whether I use the Farrington-Manning standard error?
It matters at small and moderate sample sizes and barely at all once you are into the thousands per arm. The constrained maximum-likelihood version estimates the two rates under the assumption that they differ by exactly the margin, which is what the null hypothesis actually asserts, and its type I error rate stays much closer to the nominal level than the version that plugs in the observed rates. Because it is no harder to compute, there is little reason to prefer the simpler one. If the two methods disagree about the conclusion, treat that as a sign the study is too small rather than as a choice between answers.
Can I state the margin as a relative percentage instead of percentage points?
Yes, and on low base rates you usually should. A relative margin of 5% on a 3% conversion rate is 0.15 percentage points, which is a very different test from a flat one-point margin that would allow the rate to fall by a third. The important thing is consistency: convert the relative margin into percentage points once, at the base rate agreed in the plan, and use that figure throughout. Recomputing the margin from the observed control rate at analysis time makes the margin a function of the data, which is the thing you were trying to avoid.
Can I run this as a guardrail alongside a primary success metric?
That is the most common use of it, and the structure is sound: the primary metric is tested for superiority, the guardrail for non-inferiority, and shipping requires both. Note that the two do not share an error budget in the usual way, because the errors point in opposite directions and a correction that protects one makes the other more permissive. The practical advice is to name at most two or three guardrails, size the test against whichever needs the most data, and treat the rest as monitoring rather than as tests with decision rules attached.
I already ran a normal A/B test and it came back flat. Can I test non-inferiority on that data?
You can compute the bound, and it will tell you something real about what the data rules out. What you cannot do is treat the result as a pre-planned non-inferiority test, because the margin would be chosen after seeing the outcome and the sample size was never set to give the claim a reasonable chance. Use it diagnostically: if the bound comfortably clears a margin the business would have set anyway, that is genuine reassurance, and if it does not, you have learned that the flat result was uninformative rather than encouraging.
What if a small loss is fine but a large one is catastrophic?
That is precisely the shape non-inferiority is built for, and it is why the output is a confidence bound rather than a point estimate. The bound is a statement about the worst case the data still permits, so setting the margin where the loss stops being absorbable gives you exactly the protection you described. If the cost curve is steeply non-linear rather than having a single cliff, consider a staged rollout with a stopping rule on the bound, so exposure grows only as the bound tightens.

Related calculators

  • McNemar's test

    Paired yes/no data — only the pairs that disagree carry any information, and this sizes on them.

  • Non-inferiority: two means

    Show an average is not meaningfully worse — one margin, one direction, one-sided p-value and confidence bound.

  • Equivalence: two proportions

    Prove two rates are close enough to swap — margin in percentage points, sample size, then both one-sided tests.

Terms on this page

  • Minimum detectable effect

    The smallest lift you designed to catch — a business decision that gets outsourced to statistics.

  • Guardrail metric

    A metric that can veto a launch but never justify one, and why that asymmetry is the whole point.

  • Statistical power

    The probability your test finds a real effect — and why most tests that report nothing were never able to.

Talk to the people who build these for a living

Guardrail metrics only protect you if the test behind them was sized to. We plan the margin, the power and the decision rule together. Causal Inference Analysis

References

  • Farrington, C. P., & Manning, G. (1990). Test statistics and sample size formulae for comparative binomial trials with null hypothesis of non-zero risk difference or non-unity relative risk. Statistics in Medicine, 9(12), 1447-1454.
  • Piaggio, G., Elbourne, D. R., Pocock, S. J., Evans, S. J. W., & Altman, D. G. (2012). Reporting of noninferiority and equivalence randomized trials: extension of the CONSORT 2010 statement. JAMA, 308(24), 2594-2604.
  • Chow, S.-C., Shao, J., Wang, H., & Lokhnygina, Y. (2018). Sample Size Calculations in Clinical Research (3rd ed.). Chapman & Hall/CRC.