Skip to content

BCompare groups · Guide test 287

Farrington–Manning test

Tests a specified difference in two binary success probabilities, including noninferiority margins, using constrained null variance estimation.

Runs in CodeSplashPython example validatedR example validated

Do it in CodeSplash

In the app, set it up in Analyze with this method:

In Two independent proportions (z, Fisher, Boschloo, Barnard, non-inferiority), choose Hypothesis = Equivalence or choose Hypothesis = Non-inferiority.

Do it in CodeSplash Run this test on your own data, in Python or R.

Bench

Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.

Bench · Farrington–Manning test

150
150
0.45
0.42
0.10

Group 1 counts as no worse if p₁ − p₂ stays above −margin.

0.050

Your data

Edit the counts
Group 170 of 150 · 0.467
Group 263 of 150 · 0.420

If H₀ were true

z = 2.57
  1. The reference: how z varies across samples when H₀ is true.
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .005).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The estimate against the bounds

L = −0.10 · p = .005

Bar: the 95% one-sided interval. Shaded: where the effect must lie to reject H₀. The interval's lower end clears −margin: compatible with no meaningful loss.

The formula

Z=p^1−p^2−δ0p~1(1−p~1)/n1+p~2(1−p~2)/n2,δ0=−marginZ=\frac{\hat p_1-\hat p_2-\delta_0}{\sqrt{\tilde p_1(1-\tilde p_1)/n_1+\tilde p_2(1-\tilde p_2)/n_2}},\qquad \delta_0=-\text{margin}

With your numbers

p^1−p^2=0.05, δ0=−0.10,p~1=0.39, p~2=0.49,Z=2.57\hat p_1-\hat p_2 = 0.05,\ \delta_0 = -0.10,\quad \tilde p_1 = 0.39,\ \tilde p_2 = 0.49,\quad Z = 2.57
p~1, p~2\tilde p_1,\ \tilde p_2
restricted MLEs: the closest success rates with p₁ − p₂ = δ₀
δ0\delta_0
the non-inferiority boundary, −margin

The verdict

z = 2.57, p = .005

p ≤ α = .050: reject H₀

The variance is taken at the boundary, which keeps the level closer to α than the Wald version. The margin must come from clinical or practical reasoning, set in advance.

Statistic
2.569
p-value
0.0051
Farrington–Manning test on 70/150 vs 63/150: z = 2.57, p = .005. The p-value is below α = .050, so the data are hard to reconcile with H0.

Farrington–Manning test on 70/150 vs 63/150: z = 2.57, p = .005. The p-value is below α = .050, so the data are hard to reconcile with H₀.

Question and hypotheses

H0: two binomial proportions differ by a boundary δ0; used for noninferiority/equivalence.

Assumptions

Independent binomial samples; adequate sample size for constrained score approximation; prespecified clinical/scientific margin.

Formula

Z=p^1−p^2−δ0p~1(1−p~1)/n1+p~2(1−p~2)/n2Z=\frac{\widehat p_1-\widehat p_2-\delta_0}{\sqrt{\widetilde p_1(1-\widetilde p_1)/n_1+\widetilde p_2(1-\widetilde p_2)/n_2}}

Parameters and notation

p̃1,p̃2 maximize the binomial likelihood subject to p̃1−p̃2=δ0. Risk-ratio versions impose a ratio constraint instead.

Structure of the method

Maximize the two-binomial likelihood subject to the nonzero null risk-difference constraint, then use those constrained probabilities in the score-test variance. The numerator uses the observed risk difference minus the boundary. Risk-ratio variants require a different constrained relationship and should not reuse the difference calculation.

Estimated and nuisance parameters

Estimate unrestricted sample proportions and constrained null probabilities, with one free nuisance probability under the difference constraint. The margin, sample sizes, effect scale and alternative direction are design inputs. Numerical optimization bounds must ensure both constrained probabilities lie in [0,1].

Settings and design choices

Prespecify risk difference versus ratio, one- versus two-sided testing, noninferiority orientation and any finite-sample correction. The Python example disables its score correction to align with the displayed uncorrected variance. A two-sided example at δ0=0.1 illustrates boundary testing, not by itself a complete equivalence procedure.

Fitting and adaptation

Fit the constrained likelihood at each required boundary and check optimizer convergence, feasibility and boundary solutions. Equivalence requires both directional boundary tests; noninferiority uses the prespecified relevant one. For sparse data, compare an appropriate exact or improved small-sample method as a separately identified sensitivity analysis.

Sensitivity and robustness

Rare events, proportions near zero/one and unequal allocation can make the normal approximation fragile. Pooling a common equality-null probability for a nonzero difference is incorrect. Confidence intervals should be obtained by inversion of a compatible procedure, and post hoc margins cannot turn an inconclusive comparison into valid noninferiority evidence.

How to use and calibrate

Use a one-sided normal tail at a noninferiority boundary or two score tests for equivalence.

Example application

Assess whether a response rate is no worse than control by more than a specified margin.

Interpretation and pitfalls

Watch out

Using a pooled equality-null probability for a nonzero margin gives the wrong variance. Direction and risk-difference/ratio scale must be explicit.

What changed in edition 2

  • New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.

Python and R

Restricted-binomial-likelihood Farrington–Manning score test for risk difference 0.1; no Miettinen–Nurminen finite-sample variance correction.

Python · native

Validated — Executed successfully in the validation environment · needs numpy, scipy, statsmodels

import numpy as np
from scipy import stats
rng = np.random.default_rng(2026)
from statsmodels.stats.proportion import test_proportions_2indep
print(test_proportions_2indep(18,30,9,30,value=.1,compare="diff",method="score",correction=False,alternative="two-sided"))
Output
Proportions2indepTestResult(statistic=np.float64(1.56768657279557), pvalue=np.float64(0.116954296787526), compare='diff', method='score', diff=np.float64(0.3), ratio=np.float64(2.0), odds_ratio=np.float64(3.499999999999999), variance=np.float64(0.016275768877180685), alternative='two-sided', value=0.1, prop1_null=np.float64(0.4920045963692835), prop2_null=np.float64(0.39200459636928353))
R

Validated — Executed successfully in the validation environment · needs Base/standard library

x1<-18;n1<-30;x2<-9;n2<-30;delta<-.1
ll<-function(p2) dbinom(x1,n1,p2+delta,log=TRUE)+dbinom(x2,n2,p2,log=TRUE)
p2<-optimize(ll,c(max(0,-delta)+1e-10,min(1,1-delta)-1e-10),maximum=TRUE)$maximum;p1<-p2+delta
z<-(x1/n1-x2/n2-delta)/sqrt(p1*(1-p1)/n1+p2*(1-p2)/n2)
print(c(z=z,p=2*pnorm(-abs(z))))
Output
        z         p 
1.5656168 0.1174384

Sources

Statistics guide v4 (historical):
Python: Executed successfully in the validation environment · R: Executed successfully in the validation environment
Reference's record:
Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Unavailable local dependencies: statsmodels. Python: Not run in the reference's review: Unavailable local dependencies: statsmodels. No installation attempted. R: Reviewed but not run: R wasn't available to the reference's authors.

From the CodeSplash statistics guide (v4), entry 287, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT287.