Unit 5, lesson 38

Confidence Intervals for a Proportion

How the Wald, Wilson and Clopper-Pearson intervals estimate a binomial proportion, how their actual coverage differs from the nominal level, and what to report when the count is 0 or n.

  • Video 38
  • Confidence Intervals and Sample Size

A process produces 20 items and 12 of them meet a quality standard. The sample proportion is 0.60.6, but a second run of 20 items might give 10 or 14, so the probability that an item meets the standard is not pinned down. Several interval methods answer which values of that probability fit the data, and with small samples or counts near 00 or nn they give noticeably different answers. This lesson compares the Wald, Wilson and Clopper-Pearson intervals, explains what their coverage means, and shows why a count of zero still leaves real uncertainty.

Key terms

Wald interval

Definition Suppose the number of successes XX in nn trials follows X∼Binomial⁡(n,p)X \sim \operatorname{Binomial}(n, p), which requires a fixed number of independent trials that share one success probability pp, and let p^=X/n\hat{p} = X/n. Write z=z1−α/2z = z_{1 - \alpha/2} for the standard normal quantile with upper tail area α/2\alpha/2, so that z=z0.975≈1.96z = z_{0.975} \approx 1.96 for 95 percent confidence. The Wald interval for pp is

p^±zp^(1−p^)n.\hat{p} \pm z \sqrt{\frac{\hat{p}(1 - \hat{p})}{n}}.

It comes from the normal approximation to the distribution of p^\hat{p}, with the observed p^\hat{p} substituted for the unknown pp in the standard error p(1−p)/n\sqrt{p(1 - p)/n}. Every interval on this page relies on the binomial model, so the model has to match how the data were collected. Outcomes repeated on the same person, a success probability that drifts, or a selected sample break it, and no interval formula repairs that. For a random sample drawn without replacement from a finite population, the binomial model is an approximation that works well when the sample is a small fraction of the population.

In plain words The recipe is estimate plus or minus a critical value times an estimated standard error. For a proportion the plug-in standard error is least reliable with small nn or with p^\hat{p} near 00 or 11. The interval is symmetric about p^\hat{p}, it can reach below 00 or above 11, and when X=0X = 0 or X=nX = n its width is zero.

Example For 12 successes in 20 trials, p^=0.6\hat{p} = 0.6 and

0.6±1.960.6⋅0.420≈0.6±0.2147,\begin{aligned} 0.6 &\pm 1.96\sqrt{\frac{0.6 \cdot 0.4}{20}} \\[0.4em] &\approx 0.6 \pm 0.2147, \end{aligned}

since the estimated standard error is 0.012≈0.1095\sqrt{0.012} \approx 0.1095. The 95 percent Wald interval is about [0.3853,0.8147][0.3853, 0.8147]. With 1 success in 10 trials the same recipe gives 0.1±0.18590.1 \pm 0.1859, and its lower end −0.0859-0.0859 is not a possible probability.

Nominal and actual coverage

Definition The nominal coverage of an interval method is the confidence level 1−α1 - \alpha it is designed for, such as 95 percent. Its actual coverage at a value pp is the probability, computed under the model with that pp as the true value, that the interval produced from the data contains pp. For a method that turns each count xx into an interval [L(x),U(x)][L(x), U(x)], the actual coverage is C(p)=Pp(L(X)≤p≤U(X))C(p) = P_p(L(X) \le p \le U(X)), which equals the sum of binomial probabilities

∑x∈S(p)(nx)px(1−p)n−x,\sum_{x \in S(p)} \binom{n}{x} p^x (1 - p)^{n - x},

where S(p)S(p) is the set of counts whose interval contains pp. Coverage describes the procedure before the data are seen. Once an interval has been computed it either contains pp or it does not, and the 95 percent is not a probability that this particular interval is correct.

In plain words The nominal level is the promise on the label, and the actual coverage is how often its intervals contain pp over many repetitions of the study with the same nn and the same true pp. A count can produce only n+1n + 1 different intervals, so as pp moves the set of covering counts changes in jumps and the actual coverage rises and falls with pp. It cannot equal the nominal level at every pp, so what matters is whether a method stays at or above the nominal level and how far it can drop below. The Wald interval is the extreme case. For X=0X = 0 it is the single point 00, which misses every p>0p > 0. At each p>0p > 0 its actual coverage is therefore at most 1−(1−p)n1 - (1 - p)^n, and this bound tends to 00 as pp approaches 00.

Example Take n=10n = 10 and a true p=0.05p = 0.05. Then X=0X = 0 has probability 0.9510≈0.59870.95^{10} \approx 0.5987, and in that case the Wald interval misses 0.050.05. Checking all eleven possible counts gives the table below, where each coverage is the binomial probability of the listed counts.

95 percent methodCounts whose interval contains 0.050.05Actual coverage
Wald1,2,31, 2, 30.40020.4002
Wilson0,10, 10.91390.9139
Clopper-Pearson0,1,20, 1, 20.98850.9885

At this pp the Wald interval covers only about 40 percent of the time, Wilson falls somewhat short of 95 percent, and Clopper-Pearson exceeds it.

Wilson interval

Definition Under the same binomial model, the Wilson interval, also called the score interval, is the set of all pp in [0,1][0, 1] that pass the normal comparison

∣p^−p∣≤zp(1−p)n,\lvert \hat{p} - p \rvert \le z\sqrt{\frac{p(1 - p)}{n}},

in which the standard error is computed from the candidate pp rather than from p^\hat{p}. Squaring turns this into a quadratic inequality in pp, and its solution is the interval [c−h,c+h][c - h, c + h] with

D=1+z2n,c=p^+z2/(2n)D,A=p^(1−p^)n+z24n2,h=zAD.\begin{gathered} D = 1 + \frac{z^2}{n}, \\[0.4em] c = \frac{\hat{p} + z^2/(2n)}{D}, \\[0.4em] A = \frac{\hat{p}(1 - \hat{p})}{n} + \frac{z^2}{4n^2}, \\[0.4em] h = \frac{z\sqrt{A}}{D}. \end{gathered}

The endpoints always lie in [0,1][0, 1], and when 0<X<n0 < X < n the interval contains p^\hat{p} in its interior. The method still rests on a normal approximation, so its coverage is approximate.

In plain words Instead of letting p^\hat{p} supply the standard error, the Wilson interval asks of each candidate value whether the observed proportion lies within zz standard errors of it, with the standard error computed from the candidate itself. This keeps the endpoints inside [0,1][0, 1] and stops the interval from collapsing at a boundary. The center equals (X+z2/2)/(n+z2)(X + z^2/2)/(n + z^2), a weighted average of p^\hat{p} and 12\tfrac12, so it lies between them and moves closer to p^\hat{p} as nn grows. The shift comes from solving the inequality, not from changing the data. Wilson is a sensible default, but its actual coverage can fall below the nominal level for some values of pp.

Example For 12 successes in 20 trials at 95 percent, z≈1.95996z \approx 1.95996 and z2≈3.8415z^2 \approx 3.8415. Then D≈1.1921D \approx 1.1921, the center is c≈0.5839c \approx 0.5839 and the half-width is h≈0.1973h \approx 0.1973, so the Wilson interval is about [0.3866,0.7812][0.3866, 0.7812]. Compared with the Wald interval [0.3853,0.8147][0.3853, 0.8147], it is shorter here and shifted toward 12\tfrac12.

Clopper-Pearson interval

Definition Under the binomial model, observe X=xX = x and write PpP_p for binomial probabilities computed with success probability pp. For 0<x<n0 < x < n, the equal-tailed Clopper-Pearson interval at level 1−α1 - \alpha is [pL,pU][p_L, p_U], where the endpoints solve

PpL(X≥x)=α2,PpU(X≤x)=α2.\begin{gathered} P_{p_L}(X \ge x) = \frac{\alpha}{2}, \\[0.4em] P_{p_U}(X \le x) = \frac{\alpha}{2}. \end{gathered}

When x=0x = 0 the lower endpoint is 00 and the upper endpoint solves (1−pU)n=α/2(1 - p_U)^n = \alpha/2. When x=nx = n the upper endpoint is 11 and the lower endpoint solves pLn=α/2p_L^n = \alpha/2. Each tail probability changes continuously and strictly with pp, so each equation has exactly one solution. The endpoints can also be computed as quantiles of beta distributions. Under the binomial model the actual coverage of this procedure is at least 1−α1 - \alpha for every pp in [0,1][0, 1]. It is often called the exact binomial interval, because it uses binomial probabilities instead of a normal approximation.

In plain words The lower endpoint is the smallest pp for which a count at least as large as the observed one still has probability at least α/2\alpha/2, and the upper endpoint is the largest pp for which a count at least as small still has probability at least α/2\alpha/2. Exact refers to the coverage guarantee under the model, not to a precise answer. Because counts are discrete, the guarantee is kept with room to spare at most values of pp, so the method is conservative. It covers at least as often as the nominal level and is often wider than the Wilson interval.

Example For 12 successes in 20 trials at 95 percent, the lower endpoint is the pp at which 12 or more successes have probability 0.0250.025, and the upper endpoint is the pp at which 12 or fewer have probability 0.0250.025. Solving numerically gives about [0.3605,0.8088][0.3605, 0.8088], which contains the Wilson interval [0.3866,0.7812][0.3866, 0.7812]. Both are statements about procedures. Neither says that pp lies in its interval with probability 0.950.95 now that the data are fixed.

Boundary proportion

Definition A boundary proportion is an observed p^\hat{p} equal to 00 or 11, which happens when X=0X = 0 or X=nX = n. With X=0X = 0 and level 1−α1 - \alpha, the Wald interval is the single point 00, the Wilson interval is [0,z2/(n+z2)][0, z^2/(n + z^2)], and the Clopper-Pearson interval is [0,1−(α/2)1/n][0, 1 - (\alpha/2)^{1/n}]. With X=nX = n the intervals are the mirror images, reflected about 12\tfrac12. Under the model every p<1p < 1 gives X=0X = 0 positive probability, namely (1−p)n(1 - p)^n, so a zero count does not show that p=0p = 0.

In plain words Seeing no successes makes large values of pp implausible but cannot rule out small positive ones. A method whose width is a multiple of p^(1−p^)\sqrt{\hat{p}(1 - \hat{p})}, such as the Wald interval, sees no variability in the data and reports none, which is the wrong conclusion. A defensible report keeps the lower endpoint at 00 and gives an upper endpoint from a method that works at the boundary, together with the method’s name. Counts close to 00 or nn cause the same problems in a milder form.

Example Suppose 10 trials give no successes. The 95 percent Wald interval is [0,0][0, 0]. The Wilson upper endpoint is 3.8415/13.8415≈0.27753.8415/13.8415 \approx 0.2775, and the Clopper-Pearson upper endpoint is

1−0.0251/10≈0.3085.1 - 0.025^{1/10} \approx 0.3085.

Small positive values of pp remain compatible with ten failures. At p=0.2p = 0.2 the probability of ten failures is 0.810≈0.10740.8^{10} \approx 0.1074, and at p≈0.3085p \approx 0.3085 it has dropped to 0.0250.025, which is exactly how the Clopper-Pearson endpoint is defined. The two upper endpoints differ because the procedures differ, and neither claims that pp equals its upper endpoint. Ten successes in ten trials give the mirror intervals [0.7225,1][0.7225, 1] for Wilson and [0.6915,1][0.6915, 1] for Clopper-Pearson.

Check yourself

  1. An inspection finds that 45 of 100 items meet a standard. Assuming independent items with a common probability pp, find the 95 percent Wald and Wilson intervals for pp.
Show the answer

The sample proportion is p^=0.45\hat{p} = 0.45, and the estimated standard error is 0.45⋅0.55/100≈0.04975\sqrt{0.45 \cdot 0.55/100} \approx 0.04975. The Wald margin is 1.96⋅0.04975≈0.09751.96 \cdot 0.04975 \approx 0.0975, so the Wald interval is about [0.3525,0.5475][0.3525, 0.5475].

For Wilson, D=1+3.8415/100≈1.0384D = 1 + 3.8415/100 \approx 1.0384 and the center is c=(0.45+0.0192)/1.0384≈0.4518c = (0.45 + 0.0192)/1.0384 \approx 0.4518. Next A=0.002475+3.8415/40000≈0.002571A = 0.002475 + 3.8415/40000 \approx 0.002571, so h≈1.96⋅0.05071/1.0384≈0.0957h \approx 1.96 \cdot 0.05071/1.0384 \approx 0.0957. The Wilson interval is about [0.3561,0.5476][0.3561, 0.5476]. With 100 trials and p^\hat{p} far from 00 and 11, the two methods nearly agree.

  1. A supplier tests 20 parts, none of which fails, and reports a 95 percent interval of 00 to 00 for the failure probability. What went wrong, what should the report say instead, and would testing more parts settle the question?
Show the answer

The report used the Wald interval at a boundary. With p^=0\hat{p} = 0 the plug-in standard error is 00, so the interval collapses and claims a certainty the data do not give. Under a binomial model with independent tests, a failure probability of 0.10.1 still produces 20 passes with probability 0.920≈0.12160.9^{20} \approx 0.1216.

A defensible report gives the Wilson interval [0,3.8415/23.8415]≈[0,0.1611][0, 3.8415/23.8415] \approx [0, 0.1611] or the Clopper-Pearson interval [0,1−0.0251/20]≈[0,0.1684][0, 1 - 0.025^{1/20}] \approx [0, 0.1684], and names the method. More independent tests would usually narrow the interval. They would not fix a biased collection process, for example if the supplier chose which parts to test, because then the binomial model with the target failure probability does not describe the data.

  1. For 12 successes in 20 trials, a report states that the Clopper-Pearson interval is exact, so there is exactly a 95 percent probability that pp lies between 0.36050.3605 and 0.80880.8088. Correct both parts of the claim. Use the fact that, for n=20n = 20, the 95 percent Clopper-Pearson interval contains 0.60.6 exactly when the count is between 8 and 16.
Show the answer

The 95 percent describes the procedure over repeated samples, not this one interval. With the data fixed, pp either lies in [0.3605,0.8088][0.3605, 0.8088] or it does not, and a probability statement about pp itself would need a Bayesian analysis with a prior.

The word exact means that under the binomial model the coverage is at least 95 percent for every pp, not that it equals 95 percent. If the true value is p=0.6p = 0.6, the procedure covers it whenever 8≤X≤168 \le X \le 16, and for X∼Binomial⁡(20,0.6)X \sim \operatorname{Binomial}(20, 0.6) that probability is about 0.96300.9630. The method is conservative at this pp.

How this lesson connects