Unit 6, lesson 46

One-Proportion Tests

How the exact binomial test and the one-proportion z test with the null standard error test a claimed success probability, why p-values from counts are discrete, and how two-sided exact p-values depend on a stated rule.

  • Video 46
  • Tests for Means and Proportions

Sixteen of twenty independently tested components pass a quality check, a sample proportion of 0.8. Before testing, a pass probability of 0.5 was set as the benchmark, and the question was whether the true pass probability is higher. The count is a whole number from 0 to 20, so its distribution under the benchmark can be computed exactly, while the familiar normal approximation is a shortcut that needs conditions. This lesson computes both, explains why the hypothesized value goes into the standard error, and shows why p-values from counts move in steps.

Key terms

Exact binomial test

Definition Suppose the number XX of successes comes from nn independent trials that share one success probability pp, so that X∼Binomial⁡(n,p)X \sim \operatorname{Binomial}(n, p). To test H0:p=p0H_0: p = p_0 for a fixed p0p_0 with 0<p0<10 < p_0 < 1, the exact binomial test uses the null distribution Binomial⁡(n,p0)\operatorname{Binomial}(n, p_0) itself, with probabilities

f0(k)=(nk)p0k(1−p0)n−kf_0(k) = \binom{n}{k} p_0^k (1 - p_0)^{n-k}

for k=0,1,…,nk = 0, 1, \dots, n. For an observed count xx, the p-values against H1:p>p0H_1: p > p_0 and against H1:p<p0H_1: p < p_0 are

P0(X≥x)=∑k=xnf0(k),P0(X≤x)=∑k=0xf0(k),\begin{gathered} P_0(X \ge x) = \sum_{k=x}^{n} f_0(k), \\[0.4em] P_0(X \le x) = \sum_{k=0}^{x} f_0(k), \end{gathered}

where P0P_0 denotes probability computed under H0H_0. The word exact means that no approximating distribution is used. The result is only as trustworthy as the binomial model of independent trials with a common probability.

In plain words Under the null hypothesis the count has a known distribution, so the p-value is found by adding the probabilities of all counts at least as extreme as the observed one, the observed count included.

Example For 1616 passes in 2020 trials with p0=0.5p_0 = 0.5 and the upper alternative, every sequence of 2020 results has null probability 1/220=1/1,048,5761/2^{20} = 1/1{,}048{,}576. The numbers of sequences with 1616, 1717, 1818, 1919 and 2020 passes are 48454845, 11401140, 190190, 2020 and 11, which add to 61966196, so

P0(X≥16)=61961,048,576≈0.005909.\begin{aligned} P_0(X \ge 16) &= \frac{6196}{1{,}048{,}576} \\[0.4em] &\approx 0.005909 . \end{aligned}

The test rejects at the 0.050.05 level and at the 0.010.01 level. If the components came from batches with different pass probabilities, or if failures tended to occur together, the binomial null model would be wrong, and the exact p-value would be an exact answer for the wrong model.

Two-sided exact binomial p-values

Definition For the two-sided alternative H1:p≠p0H_1: p \ne p_0, a rule must say which counts are at least as extreme as the observed xx in either direction. Three common rules give the following p-values.

  • Doubling the smaller of the two one-sided p-values P0(X≤x)P_0(X \le x) and P0(X≥x)P_0(X \ge x), with the result capped at 11.
  • Adding f0(k)f_0(k) over all counts kk with f0(k)≤f0(x)f_0(k) \le f_0(x), the counts that are no more likely under the null than the observed one.
  • Adding f0(k)f_0(k) over all counts kk with ∣k−np0∣≥∣x−np0∣\lvert k - np_0 \rvert \ge \lvert x - np_0 \rvert, the counts at least as far from the null mean as the observed one.

When p0=0.5p_0 = 0.5 the null distribution is symmetric and the three rules agree. For other values of p0p_0 they can differ, so a report names the rule it used.

In plain words A two-sided test needs a rule for what counts as equally surprising on the other side, and when the null distribution is lopsided, reasonable rules disagree. Doubling a one-sided p-value is one convention among several, not the definition.

Example For 1616 of 2020 with p0=0.5p_0 = 0.5, every rule gives

P0(X≤4)+P0(X≥16)≈0.011818.\begin{aligned} &P_0(X \le 4) + P_0(X \ge 16) \\[0.4em] &\quad \approx 0.011818 . \end{aligned}

Now take n=20n = 20, p0=0.3p_0 = 0.3 and x=10x = 10, where the null mean is 66. The upper tail is P0(X≥10)≈0.0480P_0(X \ge 10) \approx 0.0480, so doubling gives about 0.09590.0959. The counts no more likely than 1010 are 00, 11, 22 and 1010 through 2020, and their total null probability is about 0.08340.0834. The distance rule picks the same counts here, since ∣k−6∣≥4\lvert k - 6 \rvert \ge 4 means k≤2k \le 2 or k≥10k \ge 10. Both values are legitimate two-sided p-values, but they are not interchangeable.

Discrete p-value

Definition A p-value computed from a discrete statistic, such as a count, can take only certain values, at most one for each possible observation. For the upper-tail binomial test the possible p-values are the tail sums P0(X≥c)P_0(X \ge c) for c=0,1,…,nc = 0, 1, \dots, n. A test that rejects when p≤αp \le \alpha then rejects exactly when x≥c∗x \ge c^*, where c∗c^* is the smallest count with P0(X≥c∗)≤αP_0(X \ge c^*) \le \alpha, and its actual type I error probability is P0(X≥c∗)P_0(X \ge c^*), which is at most α\alpha and often well below it. If even P0(X=n)=p0nP_0(X = n) = p_0^n exceeds α\alpha, no count leads to rejection.

In plain words Moving the observed count from 1616 down to 1515 adds a whole bar of probability to the tail, so the p-value jumps instead of sliding. A test at the 55 percent level may then use only part of its 55 percent allowance for false rejections. Each p-value is still an exact tail probability, but only a limited set of values can occur.

Example For n=20n = 20 and p0=0.5p_0 = 0.5, the upper tails nearest 0.050.05 are P0(X≥14)≈0.0577P_0(X \ge 14) \approx 0.0577 and P0(X≥15)≈0.0207P_0(X \ge 15) \approx 0.0207. A one-sided test at α=0.05\alpha = 0.05 therefore rejects exactly when X≥15X \ge 15, and its actual type I error probability is about 0.02070.0207, not 0.050.05. With only n=3n = 3 trials and the same p0=0.5p_0 = 0.5, even 33 passes out of 33 gives P0(X≥3)=0.125P_0(X \ge 3) = 0.125, so a one-sided test at 0.050.05 cannot reject whatever happens.

Null standard error

Definition For the sample proportion p^=X/n\hat{p} = X/n from nn independent trials, under H0:p=p0H_0: p = p_0 the mean of p^\hat{p} is p0p_0 and its standard deviation is the null standard error

SE⁡0(p^)=p0(1−p0)n,\operatorname{SE}_0(\hat{p}) = \sqrt{\frac{p_0(1 - p_0)}{n}},

computed from the hypothesized value rather than from the data. The estimated standard error p^(1−p^)/n\sqrt{\hat{p}(1 - \hat{p})/n}, used in the Wald confidence interval for pp, estimates the standard deviation of p^\hat{p} at the unknown true pp instead. The two are different quantities, and putting the estimated one into a test statistic gives a different test.

In plain words A test asks how the sample proportion would vary if the null hypothesis were true, and the null hypothesis already says how much that is. Nothing about the spread has to be estimated.

Example For n=20n = 20 and p0=0.5p_0 = 0.5, the null standard error is 0.25/20≈0.1118\sqrt{0.25/20} \approx 0.1118. The estimate-based value 0.8×0.2/20≈0.0894\sqrt{0.8 \times 0.2 / 20} \approx 0.0894 is smaller, and dividing the difference 0.30.3 by it would give z≈3.354z \approx 3.354 instead of the 2.6832.683 of the next card. If all 2020 components had passed, the estimate p^=1\hat{p} = 1 would make the estimate-based standard error 00 and the ratio undefined, while the null standard error would stay 0.11180.1118.

One-proportion z test

Definition The one-proportion z test, also called the score test for a proportion, tests H0:p=p0H_0: p = p_0 with the statistic

z=p^−p0p0(1−p0)/nz = \frac{\hat{p} - p_0}{\sqrt{p_0(1 - p_0)/n}}

and compares it with the standard normal distribution, using P(Z≥z)P(Z \ge z), P(Z≤z)P(Z \le z) or P(∣Z∣≥∣z∣)P(\lvert Z \rvert \ge \lvert z \rvert) for the upper, lower and two-sided alternatives. It approximates the exact binomial test and needs the same model of independent trials with a common probability. The approximation is usually judged adequate when the expected numbers of successes and failures under the null, np0np_0 and n(1−p0)n(1 - p_0), are both at least about 1010, a rule of thumb that does not bound the error. A continuity correction replaces the count xx by x−0.5x - 0.5 for the upper tail and by x+0.5x + 0.5 for the lower tail. It often brings the normal value closer to the exact one, with no guarantee.

In plain words The z test replaces the binomial bars with a smooth normal curve that has the null mean and the null standard error. It is a shortcut that works well when the binomial distribution is close to normal in shape, and the exact test remains available when it is not.

Example For 1616 of 2020 with p0=0.5p_0 = 0.5, the expected counts np0=10np_0 = 10 and n(1−p0)=10n(1 - p_0) = 10 meet the rule of thumb, and

z=0.8−0.50.5×0.5/20≈2.683.\begin{aligned} z &= \frac{0.8 - 0.5}{\sqrt{0.5 \times 0.5 / 20}} \\[0.4em] &\approx 2.683 . \end{aligned}

The upper tail P(Z≥2.683)≈0.00365P(Z \ge 2.683) \approx 0.00365 is smaller than the exact 0.005910.00591. With the continuity correction the count 1616 becomes 15.515.5, and since the null mean of XX is 1010 and its null standard deviation is 5\sqrt{5},

zc=15.5−105≈2.460,P(Z≥zc)≈0.00695,\begin{aligned} z_c &= \frac{15.5 - 10}{\sqrt{5}} \\[0.4em] &\approx 2.460, \\[0.4em] P(Z \ge z_c) &\approx 0.00695, \end{aligned}

which is closer to the exact value in this case. The three numbers come from three methods, and a report says which one it gives.

Check yourself

  1. In 1010 independent trials of a task, 99 succeed. Test H0:p=0.5H_0: p = 0.5 against H1:p>0.5H_1: p > 0.5, an alternative fixed in advance, with the exact binomial test. Does the test reject at the 0.050.05 level, and at the 0.010.01 level?
Show the answer

Under the null hypothesis each of the 210=10242^{10} = 1024 sequences of results has probability 1/10241/1024. The counts at least as extreme as 99 are 99 and 1010, reached by (109)+(1010)=10+1=11\binom{10}{9} + \binom{10}{10} = 10 + 1 = 11 sequences, so

P0(X≥9)=111024≈0.0107.\begin{aligned} P_0(X \ge 9) &= \frac{11}{1024} \\[0.4em] &\approx 0.0107 . \end{aligned}

The test rejects at the 0.050.05 level but not at the 0.010.01 level. The expected count np0=5np_0 = 5 is below the usual threshold of 1010, which is one more reason to use the exact test here.

  1. In 100100 independent trials, 6060 succeed, and the two-sided test of H0:p=0.5H_0: p = 0.5 was planned. A classmate computes the z statistic with the standard error p^(1−p^)/n\sqrt{\hat{p}(1 - \hat{p})/n}. What is wrong, and what are the correct z statistic and p-value?
Show the answer

The z test measures the distance from p0p_0 in units of the null standard error, so the hypothesized value belongs under the square root. The expected counts np0=50np_0 = 50 and n(1−p0)=50n(1 - p_0) = 50 support the normal approximation, and

SE⁡0=0.5×0.5100=0.05,z=0.6−0.50.05=2,\begin{aligned} \operatorname{SE}_0 &= \sqrt{\frac{0.5 \times 0.5}{100}} \\[0.4em] &= 0.05, \\[0.4em] z &= \frac{0.6 - 0.5}{0.05} = 2, \end{aligned}

with the two-sided p-value P(∣Z∣≥2)≈0.0455P(\lvert Z \rvert \ge 2) \approx 0.0455. The classmate’s standard error 0.6×0.4/100≈0.0490\sqrt{0.6 \times 0.4 / 100} \approx 0.0490 gives z≈2.041z \approx 2.041 and p≈0.0412p \approx 0.0412, the result of a different test. The exact two-sided binomial p-value, on which all three rules agree because p0=0.5p_0 = 0.5, is about 0.05690.0569, and the continuity-corrected approximation gives about 0.05740.0574. So near the 0.050.05 threshold the decision depends on the method, which is why a report names the method and gives the p-value itself.

  1. A process is supposed to fail with probability 0.010.01. In 2020 independent runs it fails twice. Test H0:p=0.01H_0: p = 0.01 against H1:p>0.01H_1: p > 0.01, fixed in advance. Should you use the z test or the exact binomial test, and what does the resulting p-value describe?
Show the answer

The expected number of failures under the null is 20×0.01=0.220 \times 0.01 = 0.2, far below any usual threshold, so the null distribution is piled up at 00 and strongly skewed, and the z test is not appropriate. The exact upper tail is

P0(X≥2)=1−0.9920−20(0.01)(0.99)19≈0.01686.\begin{aligned} &P_0(X \ge 2) \\[0.4em] &\quad = 1 - 0.99^{20} \\[0.4em] &\qquad - 20(0.01)(0.99)^{19} \\[0.4em] &\quad \approx 0.01686 . \end{aligned}

The z statistic would be (0.1−0.01)/0.01×0.99/20≈4.045(0.1 - 0.01)/\sqrt{0.01 \times 0.99 / 20} \approx 4.045, with a normal upper tail of about 0.0000260.000026, roughly 650650 times too small. The exact p-value is the probability, under a model of independent runs that each fail with probability 0.010.01, of at least 22 failures in 2020 runs. It is not the probability that the failure rate is 0.010.01.

How this lesson connects