Bell Statistics

Non-inferiority calculator: two means

Most "can we ship the cheaper option?" decisions are one-sided: the new thing has to not be worse, and nobody will complain if it turns out better. This calculator plans and reads that test — a margin you are willing to give away, a one-sided p-value, and the confidence bound the claim rests on.

Allon Korem

Written by Allon Korem

Chief Executive Officer

Last updated

Calculator

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

A magnitude. The direction above points it.

Group 1 − group 2. 0 assumes exact parity.

Pooled, from historical data.

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

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

Required sample size for non-inferiority
Per group38,778
Group 238,778
Total77,556
Achieved powerAt the whole-number sample above.80.0%
Textbook closed form, per group(z₁₋ₐ + z₁₋ᵦ)²σ²(1 + 1/k) ÷ Δ², with normal critical values. A lower bound on the exact answer above.38,777
Room to the marginThe distance the study has to work with.0.2500
Assumed true difference0

Collect 77,556 observations in total and the study will conclude that group 1 is not more than 0.250 *below* group 2 80.0% of the time, if the truth is what you assumed. What is being powered is the 0.250 of room between that assumption and the margin — not the margin itself — so an assumed difference that eats into the margin costs sample size very quickly. If you privately expect the new option to be slightly worse, say so in the field above rather than planning against exact parity.

  • Sized for a test that group 1 is not more than the margin *below* group 2, with higher values the better outcome.
Sample size per group against statistical powerReaching 5.1% power takes 2 per group and 96.9% takes 77,522; the 80.0% target is met at 38,778.10,00020,00030,00040,00050,00060,00070,0000%25%50%75%100%PowerSample size — per group80.0% → 38,778

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.1%2
26.4%6,462
41.7%12,922
54.5%19,382
65.0%25,842
73.4%32,302
80.0%38,762
85.1%45,222
89.0%51,682
91.9%58,142
94.1%64,602
95.7%71,062
96.9%77,522
Required sample per group against non-inferiority marginDetecting 0.0700 takes 494,606 and 8.40 takes 36. At the 0.250 currently entered it is 38,778 — the requirement falls roughly as the square of the effect.1001,00010,000100,0002.004.006.008.00Non-inferiority marginRequired sample per group (log scale)0.250 → 38,778

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.0700494,606
0.9242,838
1.78767
2.63351
3.49200
4.34130
5.2091
6.0567
6.9052
7.7641

When to use it

Use a non-inferiority test when the change is worth making for reasons outside the metric, and the metric's job is only to confirm you are not paying too much for it. A recommendation model that costs a tenth as much to serve; a support process that frees three people. The case for shipping is already made, and the experiment exists to bound the damage: the question is not "is it better?" but "how confident am I that it is not worse by more than Δ?".

The trap is reaching for a two-sample t-test and reading a non-significant result as permission. It is not: p > 0.05 means the data did not distinguish the arms, which is also what a test that was too small or too noisy produces. The incentives make it worse than the average inference error, because the team wants to ship and an inconclusive test looks like a green light. Reframing so that shipping requires positive evidence is the point, argued in when being good enough is enough.

Choose non-inferiority over an equivalence test when a surprise in the good direction genuinely needs no protection. That is the common case and it buys a cheaper design, since the whole error budget goes on one side. Go two-sided when being unexpectedly better is itself a warning: a support bot that closes tickets far faster than a human may not be solving them. For a rate, use non-inferiority for two proportions. The framing is the one in one-tailed vs two-tailed tests, with the null shifted to the margin rather than sitting at zero.

Assumptions

The distributional assumptions are the t-test's. The ones that actually sink non-inferiority studies are about the design:

  • You have set the direction correctly. The explicit higher is better / lower is better switch exists because the two hypotheses are mirror images and the wrong one yields a confident, precisely inverted conclusion — a small p-value pointing the wrong way. Revenue and retention are higher-is-better; latency, churn and handling time are lower-is-better.
  • The margin was fixed before the data existed, and it is a commercial quantity: the loss you would knowingly accept in exchange for the saving, in the units of the metric. If nobody will commit to a number in advance, that is worth discovering before you run anything.
  • Independence and approximately normal sample means, as in the two-sample t-test. Long-tailed money metrics are the usual difficulty — see what to do when data is not normally distributed — and a handful of large orders can carry a claim on their own.
  • The comparison is a fair one. Non-inferiority is uniquely vulnerable to sloppiness: contamination, broken assignment or a noisy outcome all pull the observed difference towards zero and therefore towards your desired conclusion. In a superiority test sloppiness costs power; here it buys the answer you wanted.

How the calculation works

One hypothesis test, with the null shifted away from zero. Rather than asking whether the difference could be zero, we ask whether it could be as bad as −Δ, and reject in favour of "better than −Δ". The estimate, Welch's standard error and the degrees of freedom are identical to [the ordinary two-sample test](/calculators/two-sample-t-test); what changes is where the null sits and the fact that only one tail is in play. The expressions below assume higher is better, and flipping the switch mirrors every one of them.

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

The null is that the new arm is worse by at least the margin, so the burden of proof sits on the change rather than on the incumbent.

Test statistic
t = (d − (−Δ)) / SE = (d + Δ) / SE

d is the observed difference, new minus incumbent, and above t₁₋α,df rejects. Note that d can be negative and the test still passes, provided the arm is not worse by Δ.

Standard error (Welch)
SE = √(s₁²/n₁ + s₂²/n₂)

Unpooled, with Welch–Satterthwaite degrees of freedom. Equal variances between an old system and a new one is an assumption with nothing behind it.

Confidence bound
d − t₁₋α,df · SE > −Δ

The one-sided 95% lower bound is the number to report, and it is also the lower limit of the two-sided 90% interval — which is why a non-inferiority readout and a TOST readout at the same α share an edge.

Sample size per arm
n = 2σ²(z₁₋α + z₁₋β)² / (Δ + d₀)²

d₀ is the signed difference you expect, negative if the new arm will probably be slightly worse. Assuming zero gives the cheapest design and the one most likely to disappoint: a shortfall of a third of the margin more than doubles it.

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

The mirror image, for latency, cost per acquisition and churn. Getting it backwards produces not a nonsense number but a plausible one that says the opposite of the truth.

Worked example

You want to replace a heavyweight recommendation model with one that costs a tenth as much to serve. Revenue per session is the guardrail, higher is better, and finance agreed in advance that a drop of up to 25 cents is worth the saving. The test ran three weeks at a 50/50 split, 60,000 sessions per arm.

Direction
Higher is better
Non-inferiority margin (Δ)
$0.25 per session
Incumbent model
n = 60,000, mean $8.40, SD $14.00
Cheap model
n = 60,000, mean $8.32, SD $13.80
Significance level (α)
0.05, one-sided
Standard error
Welch, unpooled

Observed difference −$0.08 per session, standard error $0.080. The statistic is (−0.08 + 0.25) / 0.080 = 2.12, a one-sided p of 0.017, and the 95% lower confidence bound is −$0.21. That bound clears the −$0.25 margin, so non-inferiority is established.

The headline is not that the cheap model performed the same — it lost eight cents a session, and that point estimate is the best guess at what shipping will cost. The claim is narrower: the data rules out a loss as large as 25 cents with 95% confidence, so the saving survives the worst case the evidence permits. The conventional comparison gives a two-sided p of 0.32, which would have been reported as "no difference" and justified nothing. Now flip the direction switch by mistake: the statistic becomes (0.25 + 0.08) / 0.080 = 4.11 and p collapses below 0.0001. Here that happens to land on the same decision, but with a 40-cent drop the correct test returns p = 0.97 — a clear failure — while the flipped one still returns p below 0.0001.

Interpreting the output

Report the confidence bound, not the p-value. "The 95% lower bound on revenue per session is −$0.21, against an agreed margin of −$0.25" is a sentence a finance director can act on. "p = 0.017" is not, and it invites the reading that the model was shown to be as good — a stronger claim than the data supports.

Keep the point estimate in view for that reason. Non-inferiority answers a question about the worst case and says nothing about the expected one, which here is a real if tolerable loss. Multiply it by annual sessions before you celebrate. Our note on why the uplift in A/B tests often differs from real-world results applies with equal force to declines.

A failed test is not proof of inferiority. If the bound lands at −$0.31 against a margin of −$0.25, you have not shown the new model is worse by more than the margin; you have failed to show it is not, which usually means the study was too small. The remedy is more data or a properly renegotiated margin — not a rerun with the direction switch flipped.

Finally, be careful about stacking claims. Each variant judged non-inferior to the last can drift a full margin from the original, and after four such decisions the live system may be materially worse than the one you started with while every test passed. Clinical statisticians call it biocreep; anchor to a preserved baseline. That discipline is what our causal inference work and most of our case studies are about.

Frequently asked questions

Should the one-sided alpha be 0.05 or 0.025?
Regulated clinical work conventionally uses one-sided 0.025, so the non-inferiority claim carries the same error rate as one side of a standard two-sided test. Product teams almost always use one-sided 0.05, which is defensible when the cost of a wrong call is a recoverable revenue dip rather than a patient outcome. The choice is worth about 25% more sample at 0.025, and the only wrong answer is deciding after the result comes in. Pick one, write it in the plan, and use the matching confidence bound in the readout.
What if nobody will commit to a margin?
Then you cannot run the test, and that is genuinely useful information rather than an obstacle. A refusal to name a tolerable loss usually means the trade-off has not been thought through, or that different stakeholders hold incompatible numbers in their heads. A productive way in is to work backwards from the saving: if the change frees 400,000 dollars a year, what annual revenue loss would still leave it worthwhile? Divide by expected sessions and you have a margin with a paper trail behind it.
My new variant looks better. Can I claim superiority instead?
Yes, and this is one of the few places where switching hypotheses after the fact is legitimate. Testing for superiority once non-inferiority is established does not inflate the overall error rate, because the hypotheses are ordered and the superiority test is only reached if the first one passes. The reverse move is not allowed: failing to demonstrate superiority and then declaring non-inferiority against a margin invented afterwards is exactly the manoeuvre the whole framework exists to prevent.
Why is a non-inferiority test cheaper than an equivalence test?
Because only one hypothesis has to be rejected rather than two. In an equivalence test the power requirement is split across both one-sided tests, which pushes the beta term up; here the whole error budget sits on the side you care about. At the same margin, alpha and power, a one-sided non-inferiority design typically needs somewhere around a quarter fewer observations per arm than the two-sided equivalence version. That is a real saving, but it is only available if you would honestly take no action on a surprise in the good direction.
Should I analyse everyone assigned, or only those who actually got the change?
This is the one place where the usual advice reverses. In a superiority test, analysing everyone as assigned is conservative, because non-compliance dilutes the difference towards zero. In a non-inferiority test, dilution towards zero pushes you towards the conclusion you want, so the as-assigned analysis is anti-conservative. The standard recommendation is to run both the as-assigned and the as-treated analysis and require them to agree before making the claim. If they disagree, you have a delivery problem to fix before you have a result to report.

Related calculators

  • Equivalence: two means

    Show two averages are close enough to be interchangeable — set the margin, size the study, run both one-sided tests.

  • Non-inferiority: two proportions

    Show a rate has not dropped by more than you can afford — margin, direction, sample size 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

  • Null hypothesis

    The assumption every test argues against, and the reason you can never prove two things are the same.

Talk to the people who build these for a living

Cost-saving changes need a guardrail with a number on it. We set the margin, size the study and write the decision rule before launch. Causal Inference Analysis

References

  • Wellek, S. (2010). Testing Statistical Hypotheses of Equivalence and Noninferiority (2nd ed.). Chapman & Hall/CRC.
  • 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.