Statistics Quest

Tests for one proportion (z-test and exact binomial test)

Tests whether a population proportion equals p₀, by the score z-test (large samples) or the exact binomial test (any size).

z=p^−p0p0(1−p0)/n=x−np0np0(1−p0)z = \frac{\phat - p_0}{\sqrt{p_0(1-p_0)/n}} = \frac{x - np_0}{\sqrt{np_0(1-p_0)}}
Score z-test: the SE uses the null value p₀, not p̂. Its matching interval is the Wilson interval.
x,nx, n
Number of successes and trials.
p^\phat
Sample proportion x/nx/n.
p0p_0
Proportion stated by H₀ (0 < p₀ < 1).
ptwo-sided=∑k: P(X=k)≤P(X=x)P(X=k),X∼Binomial(n,p0)p_{\text{two-sided}} = \sum_{k:\ P(X=k) \le P(X=x)} P(X = k),\qquad X \sim \text{Binomial}(n, p_0)
Exact binomial test: the two-sided p-value sums the probabilities of all outcomes no more likely than the observed one (R's rule); one-sided p-values are binomial tails.
P(X=k)P(X=k)
Binomial probability (nk)p0k(1−p0)n−k\binom{n}{k}p_0^k(1-p_0)^{n-k}.

When to use

A binary outcome (yes/no) from n independent trials and a benchmark proportion: a claimed defect rate, a historical pass rate, 50% for "no preference". Use the exact test for small samples or when np0np_0 or n(1−p0)n(1-p_0) is below about 10; the z-test is the usual large-sample choice.

Assumptions

  • Independent trials with a common probability of success (random sample).
  • z-test: np0≥10np_0 \ge 10 and n(1−p0)≥10n(1-p_0) \ge 10 (a common rule of thumb).

How to interpret

  • The z-test is reported with a Wilson interval and the exact test with a Clopper–Pearson interval (each is the interval that inverts its test). The engine's z-test uses no continuity correction by default.
  • The exact test is conservative: its actual Type I error rate is at most α, often less.

Common mistakes

  • Using p^\phat instead of p0p_0 in the test's SE.
  • Doubling a one-sided exact p-value: the exact two-sided rule is different (sum of probabilities ≤ the observed).
  • Applying the z-test to 3 successes out of 15.

Example

14 of 20 customers prefer the new design; H0:p=0.5H_0: p = 0.5. z-test: p^=0.70\phat = 0.70, z=(0.70−0.5)/0.25/20=1.79z = (0.70 - 0.5)/\sqrt{0.25/20} = 1.79, p=0.074p = 0.074, Wilson 95% CI 0.481 to 0.855. Exact binomial test: p=0.115p = 0.115, Clopper–Pearson CI 0.457 to 0.881. Neither gives significant evidence at α = 0.05; 20 customers are too few to pin down the preference.