Misplaced Pages

Binomial proportion confidence interval

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
(Redirected from Agresti–Coull interval) Statistical confidence interval for success counts

In statistics, a binomial proportion confidence interval is a confidence interval for the probability of success calculated from the outcome of a series of success–failure experiments (Bernoulli trials). In other words, a binomial proportion confidence interval is an interval estimate of a success probability   p   {\displaystyle \ p\ } when only the number of experiments   n   {\displaystyle \ n\ } and the number of successes   n s   {\displaystyle \ n_{\mathsf {s}}\ } are known.

There are several formulas for a binomial confidence interval, but all of them rely on the assumption of a binomial distribution. In general, a binomial distribution applies when an experiment is repeated a fixed number of times, each trial of the experiment has two possible outcomes (success and failure), the probability of success is the same for each trial, and the trials are statistically independent. Because the binomial distribution is a discrete probability distribution (i.e., not continuous) and difficult to calculate for large numbers of trials, a variety of approximations are used to calculate this confidence interval, all with their own tradeoffs in accuracy and computational intensity.

A simple example of a binomial distribution is the set of various possible outcomes, and their probabilities, for the number of heads observed when a coin is flipped ten times. The observed binomial proportion is the fraction of the flips that turn out to be heads. Given this observed proportion, the confidence interval for the true probability of the coin landing on heads is a range of possible proportions, which may or may not contain the true proportion. A 95% confidence interval for the proportion, for instance, will contain the true proportion 95% of the times that the procedure for constructing the confidence interval is employed.

Problems with using a normal approximation or "Wald interval"

Plotting the normal approximation interval on an arbitrary logistic curve reveals problems of overshoot and zero-width intervals.

A commonly used formula for a binomial confidence interval relies on approximating the distribution of error about a binomially-distributed observation, p ^ {\displaystyle {\hat {p}}} , with a normal distribution. The normal approximation depends on the de Moivre–Laplace theorem (the original, binomial-only version of the central limit theorem) and becomes unreliable when it violates the theorems' premises, as the sample size becomes small or the success probability grows close to either 0 or 1 .

Using the normal approximation, the success probability   p   {\displaystyle \ p\ } is estimated by

  p         p ^ ± z α     n     p ^   ( 1 p ^ )     , {\displaystyle \ p~~\approx ~~{\hat {p}}\pm {\frac {\;z_{\alpha }\ }{\ {\sqrt {n\;}}\ }}\ {\sqrt {{\hat {p}}\ \left(1-{\hat {p}}\right)\ }}\ ,}

where   p ^   n s   n   {\displaystyle \ {\hat {p}}\equiv {\frac {\!\ n_{\mathsf {s}}\!\ }{n}}\ } is the proportion of successes in a Bernoulli trial process and an estimator for   p   {\displaystyle \ p\ } in the underlying Bernoulli distribution. The equivalent formula in terms of observation counts is

  p           n s   n ± z α     n     n s   n     n f   n     , {\displaystyle \ p~~\approx ~~{\frac {\!\ n_{\mathsf {s}}\!\ }{n}}\pm {\frac {\;z_{\alpha }\ }{\ {\sqrt {n\;}}\ }}{\sqrt {{\frac {\!\ n_{\mathsf {s}}\!\ }{n}}\ {\frac {\!\ n_{\mathsf {f}}\!\ }{n}}\ }}\ ,}

where the data are the results of   n   {\displaystyle \ n\ } trials that yielded   n s   {\displaystyle \ n_{\mathsf {s}}\ } successes and   n f = n n s   {\displaystyle \ n_{\mathsf {f}}=n-n_{\mathsf {s}}\ } failures. The distribution function argument   z α   {\displaystyle \ z_{\alpha }\ } is the   1   α   2   {\displaystyle \ 1-{\tfrac {\!\ \alpha \!\ }{2}}\ } quantile of a standard normal distribution (i.e., the probit) corresponding to the target error rate   α   . {\displaystyle \ \alpha ~.} For a 95% confidence level, the error   α = 1 0.95 = 0.05   , {\displaystyle \ \alpha =1-0.95=0.05\ ,} so   1   α   2 = 0.975   {\displaystyle \ 1-{\tfrac {\!\ \alpha \!\ }{2}}=0.975\ } and   z .05 = 1.96   . {\displaystyle \ z_{.05}=1.96~.}

When using the Wald formula to estimate   p   {\displaystyle \ p\ } , or just considering the possible outcomes of this calculation, two problems immediately become apparent:

  • First, for   p ^   {\displaystyle \ {\hat {p}}\ } approaching either 1 or 0, the interval narrows to zero width (falsely implying certainty).
  • Second, for values of   p ^   <   1   1 + n / z α 2     {\displaystyle ~{\hat {p}}~<~{\frac {1}{\ 1+n/z_{\alpha }^{2}\ }}~} (probability too low / too close to 0), the interval boundaries exceed   [ 0 ,   1 ]   {\displaystyle \ \ } (overshoot).

(Another version of the second, overshoot problem, arises when instead   1 p ^   {\displaystyle \ 1-{\hat {p}}\ } falls below the same upper bound: probability too high / too close to 1 .)

An important theoretical derivation of this confidence interval involves the inversion of a hypothesis test. Under this formulation, the confidence interval represents those values of the population parameter that would have large P-values if they were tested as a hypothesized population proportion. The collection of values,   θ   , {\displaystyle \ \theta \ ,} for which the normal approximation is valid can be represented as

{     θ | y α / 2           p ^ θ     1   n   p ^   ( 1 p ^ )             z α / 2     }   , {\displaystyle \left\{~~\theta \quad {\Bigg |}\quad y_{\alpha /2}~~\leq ~~{\frac {\ {\hat {p}}-\theta \ }{{\sqrt {{\frac {\!\ 1\!\ }{n}}\ {\hat {p}}\ \left(1-{\hat {p}}\right)\ }}\ }}~~\leq ~~z_{\alpha /2}~~\right\}\ ,}

where   y α / 2   {\displaystyle \ y_{\alpha /2}\ } is the lower   α   2     {\displaystyle \ {\tfrac {\alpha }{\!\ 2\!\ }}\ } quantile of a standard normal distribution, vs.   z α / 2   , {\displaystyle \ z_{\alpha /2}\ ,} which is the upper quantile.

Since the test in the middle of the inequality is a Wald test, the normal approximation interval is sometimes called the Wald interval or Wald method, after Abraham Wald, but it was first described by Laplace (1812).

Bracketing the confidence interval

Extending the normal approximation and Wald-Laplace interval concepts, Michael Short has shown that inequalities on the approximation error between the binomial distribution and the normal distribution can be used to accurately bracket the estimate of the confidence interval around   p   : {\displaystyle \ p\ :}

    k + C L 1 z α   W ^     n + z α 2           p           k + C U 1 + z α   W ^   n + z α 2   {\displaystyle \ {\frac {\ k+C_{\mathsf {L1}}-z_{\alpha }\ {\widehat {W}}\ }{\ n+z_{\alpha }^{2}\ }}~~\leq ~~p~~\leq ~~{\frac {\ k+C_{\mathsf {U1}}+z_{\alpha }\ {\widehat {W}}\ }{n+z_{\alpha }^{2}}}\ }

with

  W ^   n   k k 2 + C L 2 n   C L 3 k + C L 4   n     , {\displaystyle \ {\widehat {W}}\equiv {\sqrt {{\frac {\ n\ k-k^{2}+C_{\mathsf {L2}}n\ -C_{\mathsf {L3}}k+C_{\mathsf {L4}}\ }{n}}~}}\ ,}

and where   p   {\displaystyle \ p\ } is again the (unknown) proportion of successes in a Bernoulli trial process (as opposed to   p ^   n s   n   {\displaystyle \ {\hat {p}}\equiv {\frac {\ n_{\mathsf {s}}\ }{n}}\ } that estimates it) measured with   n   {\displaystyle \ n\ } trials yielding   k   {\displaystyle \ k\ } successes,   z α   {\displaystyle \ z_{\alpha }\ } is the   1 α 2   {\displaystyle \ 1-{\tfrac {\alpha }{2}}\ } quantile of a standard normal distribution (i.e., the probit) corresponding to the target error rate   α   , {\displaystyle \ \alpha \ ,} and the constants   C L 1 , C L 2 , C L 3 , C L 4 , C U 1 , C U 2 , C U 3   {\displaystyle \ C_{\mathsf {L1}},C_{\mathsf {L2}},C_{\mathsf {L3}},C_{\mathsf {L4}},C_{\mathsf {U1}},C_{\mathsf {U2}},C_{\mathsf {U3}}\ } and   C U 4   {\displaystyle \ C_{\mathsf {U4}}\ } are simple algebraic functions of   z α   . {\displaystyle \ z_{\alpha }~.} For a fixed   α   {\displaystyle \ \alpha \ } (and hence   z α   {\displaystyle \ z_{\alpha }\ } ), the above inequalities give easily computed one- or two-sided intervals which bracket the exact binomial upper and lower confidence limits corresponding to the error rate   α   . {\displaystyle \ \alpha ~.}

Standard error of a proportion estimation when using weighted data

Let there be a simple random sample   X 1 ,   ,   X n   {\displaystyle \ X_{1},\ \ldots ,\ X_{n}\ } where each   X i   {\displaystyle \ X_{i}\ } is i.i.d from a Bernoulli(p) distribution and weight w i {\displaystyle w_{i}} is the weight for each observation, with the(positive) weights w i {\displaystyle w_{i}} normalized so they sum to 1 . The weighted sample proportion is:   p ^ = i = 1 n   w i   X i   . {\textstyle \ {\hat {p}}=\sum _{i=1}^{n}\ w_{i}\ X_{i}~.} Since each of the   X i   {\displaystyle \ X_{i}\ } is independent from all the others, and each one has variance   var {   X i   }   =   p   ( 1 p )     {\displaystyle \ \operatorname {var} \{\ X_{i}\ \}\ =\ p\ (1-p)~~} for every     i   =   1 ,     , n   , {\displaystyle ~~i\ =\ 1,\ \ldots \ ,n\ ,} the sampling variance of the proportion therefore is:

  var {   p ^   } = i = 1 n var {   w i   X i   } = p   ( 1 p )   i = 1 n w i 2   . {\displaystyle \ \operatorname {var} \{\ {\hat {p}}\ \}=\sum _{i=1}^{n}\operatorname {var} \{\ w_{i}\ X_{i}\ \}=p\ (1-p)\ \sum _{i=1}^{n}w_{i}^{2}~.}

The standard error of   p ^   {\displaystyle \ {\hat {p}}\ } is the square root of this quantity. Because we do not know   p   ( 1 p )   , {\displaystyle \ p\ (1-p)\ ,} we have to estimate it. Although there are many possible estimators, a conventional one is to use   p ^   , {\displaystyle \ {\hat {p}}\ ,} the sample mean, and plug this into the formula. That gives:

  SE {   p ^   }   p ^   ( 1 p ^ )   i = 1 n w i 2       {\displaystyle \ \operatorname {SE} \{\ {\hat {p}}\ \}\approx {\sqrt {~{\hat {p}}\ (1-{\hat {p}})\ \sum _{i=1}^{n}w_{i}^{2}~~}}\ }

For otherwise unweighted data, the effective weights are uniform   w i =   1   n   , {\textstyle \ w_{i}={\tfrac {\!\ 1\!\ }{n}}\ ,} giving   i = 1 n w i 2 =   1   n   . {\textstyle \ \sum _{i=1}^{n}w_{i}^{2}={\tfrac {\!\ 1\!\ }{n}}~.} The   SE   {\displaystyle \ \operatorname {SE} \ } becomes   1   n   p ^   ( 1 p ^ )     , {\textstyle {\sqrt {{\tfrac {\!\ 1\!\ }{n}}\ {\hat {p}}\ (1-{\hat {p}})~}}\ ,} leading to the familiar formulas, showing that the calculation for weighted data is a direct generalization of them.

Wilson score interval

Wilson score intervals plotted on a logistic curve, revealing asymmetry and good performance for small n and where p is at or near 0 or 1.

The Wilson score interval was developed by E.B. Wilson (1927). It is an improvement over the normal approximation interval in multiple respects: Unlike the symmetric normal approximation interval (above), the Wilson score interval is asymmetric, and it doesn't suffer from problems of overshoot and zero-width intervals that afflict the normal interval. It can be safely employed with small samples and skewed observations. The observed coverage probability is consistently closer to the nominal value,   1 α   . {\displaystyle \ 1-\alpha ~.}

Like the normal interval, the interval can be computed directly from a formula.

Wilson started with the normal approximation to the binomial:

  z α   (   p p ^   )   σ n   {\displaystyle \ z_{\alpha }\approx {\frac {~\left(\ p-{\hat {p}}\ \right)~}{\sigma _{n}}}\ }

where   z α   {\displaystyle \ z_{\alpha }\ } is the standard normal interval half-width corresponding to the desired confidence   1 α   . {\displaystyle \ 1-\alpha ~.} The analytic formula for a binomial sample standard deviation is   σ n =   p   ( 1 p )   n     . {\displaystyle \ \sigma _{n}={\sqrt {{\frac {\ p\ \left(1-p\right)\ }{n}}~}}~.} Combining the two, and squaring out the radical, gives an equation that is quadratic in   p   : {\displaystyle \ p\ :}

(   p p ^   ) 2 = z α 2   n   p   (   1 p   )   {\displaystyle \left(\ p-{\hat {p}}\ \right)^{2}={\frac {\;z_{\alpha }^{2}\ }{n}}\ p\ \left(\ 1-p\ \right)\ \qquad } or p 2 2   p   p ^ + p ^ 2 = p   z α 2   n p 2   z α 2   n   . {\displaystyle \qquad p^{2}-2\ p\ {\hat {p}}+{\hat {p}}^{2}=p\ {\frac {\;z_{\alpha }^{2}\ }{n}}-p^{2}\ {\frac {\;z_{\alpha }^{2}\ }{n}}~.}

Transforming the relation into a standard-form quadratic equation for   p   , {\displaystyle \ p\ ,} treating   p ^   {\displaystyle \ {\hat {p}}\ } and   n   {\displaystyle \ n\ } as known values from the sample (see prior section), and using the value of   z α   {\displaystyle \ z_{\alpha }\ } that corresponds to the desired confidence   1 α   {\displaystyle \ 1-\alpha \ } for the estimate of   p   {\displaystyle \ p\ } gives this: (   1 + z α 2   n   )   p 2 (   2   p ^ + z α 2   n   )   p + (   p ^ 2   ) = 0   , {\displaystyle \left(\ 1+{\frac {\;z_{\alpha }^{2}\ }{n}}\ \right)\ p^{2}-\left(\ 2\ {\hat {p}}+{\frac {\;z_{\alpha }^{2}\ }{n}}\ \right)\ p+{\biggl (}\ {\hat {p}}^{2}\ {\biggr )}=0~,} where all of the values bracketed by parentheses are known quantities. The solution for   p   {\displaystyle \ p\ } estimates the upper and lower limits of the confidence interval for   p   . {\displaystyle \ p~.} Hence the probability of success   p   {\displaystyle \ p\ } is estimated by   p ^   {\displaystyle \ {\hat {p}}\ } and with   1 α   {\displaystyle \ 1-\alpha \ } confidence bracketed in the interval

p α (   w ,   w +   )     =     1   1 + z α 2   / n   (   p ^ + z α 2   2   n     ±       z α     2   n       4   n   p ^   ( 1 p ^ ) +   z α 2     )   {\displaystyle p\quad {\underset {\approx }{\in }}_{\alpha }\quad {\bigl (}\ w^{-},\ w^{+}\ {\bigr )}~~=~~{\frac {1}{~1+z_{\alpha }^{2}\ /n~}}{\Bigg (}\ {\hat {p}}+{\frac {\;z_{\alpha }^{2}\ }{2\ n}}~~\pm ~~{\frac {\!\ z_{\alpha }\!\ }{\!\ 2\ n\!\ }}\ {\sqrt {\ 4\ n\ {\hat {p}}\ (1-{\hat {p}})+\ z_{\alpha }^{2}~}}~{\Biggr )}\ }

where   α   {\displaystyle \ {\underset {\approx }{\in }}_{\alpha }\ } is an abbreviation for

  P {     p (   w ,   w +   )     } = 1 α   . {\displaystyle \ \operatorname {\mathbb {P} } {\Bigr \{}~~p\in \left(\ w^{-},\ w^{+}\ \right)~~{\Bigl \}}=1-\alpha ~.}

An equivalent expression using the observation counts   n s   {\displaystyle \ n_{\mathsf {s}}\ } and   n f   {\displaystyle \ n_{\mathsf {f}}\ } is

p α   n s +   1   2   z α 2   n + z α 2   ±   z α   n + z α 2     n s   n f   n + z α 2   4     , {\displaystyle p\quad {\underset {\approx }{\in }}_{\alpha }\quad {\frac {\ n_{\mathsf {s}}+{\tfrac {\!\ 1\!\ }{2}}\ z_{\alpha }^{2}\ }{n+z_{\alpha }^{2}}}~\pm ~{\frac {z_{\alpha }}{\ n+z_{\alpha }^{2}\ }}{\sqrt {{\frac {\ n_{\mathsf {s}}\ n_{\mathsf {f}}\ }{n}}+{\frac {\;z_{\alpha }^{2}\ }{4}}~}}\ ,}

with the counts as above: n s {\displaystyle n_{\mathsf {s}}\equiv } the count of observed "successes",   n f {\displaystyle \ n_{\mathsf {f}}\equiv } the count of observed "failures", and their sum is the total number of observations   n = n s + n f   . {\displaystyle \ n=n_{\mathsf {s}}+n_{\mathsf {f}}~.}

In practical tests of the formula's results, users find that this interval has good properties even for a small number of trials and / or the extremes of the probability estimate,   p ^   n s   n   . {\displaystyle \ {\hat {p}}\equiv {\frac {\!\ n_{\mathsf {s}}\ }{n}}~.}

Intuitively, the center value of this interval is the weighted average of   p ^   {\displaystyle \ {\hat {p}}\ } and     1   2   , {\displaystyle \ {\tfrac {\!\ 1\!\ }{2}}\ ,} with   p ^   {\displaystyle \ {\hat {p}}\ } receiving greater weight as the sample size increases. Formally, the center value corresponds to using a pseudocount of     1   2 z α 2   , {\displaystyle \ {\tfrac {\!\ 1\!\ }{2}}z_{\alpha }^{2}\ ,} the number of standard deviations of the confidence interval: Add this number to both the count of successes and of failures to yield the estimate of the ratio. For the common two standard deviations in each direction interval (approximately 95% coverage, which itself is approximately 1.96 standard deviations), this yields the estimate     n s + 2   n + 4   , {\displaystyle \ {\frac {\ n_{\mathsf {s}}+2\ }{n+4}}\ ,} which is known as the "plus four rule".

Although the quadratic can be solved explicitly, in most cases Wilson's equations can also be solved numerically using the fixed-point iteration

p   k + 1 = p ^ ± z α     1   n   p k   (   1 p k   )   {\displaystyle p_{\!\ k+1}={\hat {p}}\pm z_{\alpha }\ {\sqrt {{\tfrac {\!\ 1\!\ }{n}}\ p_{k}\ \left(\ 1-p_{k}\ \right)~}}}

with   p 0 = p ^   . {\displaystyle \ p_{0}={\hat {p}}~.}

The Wilson interval can also be derived from the single sample z-test or Pearson's chi-squared test with two categories. The resulting interval,

{     θ |   y α           p ^ θ       1   n   θ   ( 1 θ )             z α     }   , {\displaystyle \left\{~~\theta \quad {\Bigg |}\quad \ y_{\alpha }~~\leq ~~{\frac {\ {\hat {p}}-\theta \ }{\ {\sqrt {{\tfrac {\!\ 1\!\ }{n}}\ \theta \ \left(1-\theta \right)~}}\ }}~~\leq ~~z_{\alpha }~~\right\}\ ,}

(with   y α   {\displaystyle \ y_{\alpha }\ } the lower   α   {\displaystyle \ \alpha \ } quantile) can then be solved for   θ   {\displaystyle \ \theta \ } to produce the Wilson score interval. The test in the middle of the inequality is a score test.

The interval equality principle

The probability density function (PDF) for the Wilson score interval, plus PDFs at interval bounds. Tail areas are equal.

Since the interval is derived by solving from the normal approximation to the binomial, the Wilson score interval   (   w   ,   w +   )   {\displaystyle ~{\bigl (}\ w^{-}\ ,\ w^{+}\ {\bigr )}~} has the property of being guaranteed to obtain the same result as the equivalent z-test or chi-squared test.

This property can be visualised by plotting the probability density function for the Wilson score interval (see Wallis). After that, then also plotting a normal PDF across each bound. The tail areas of the resulting Wilson and normal distributions represent the chance of a significant result, in that direction, must be equal.

The continuity-corrected Wilson score interval and the Clopper-Pearson interval are also compliant with this property. The practical import is that these intervals may be employed as significance tests, with identical results to the source test, and new tests may be derived by geometry.

Wilson score interval with continuity correction

The Wilson interval may be modified by employing a continuity correction, in order to align the minimum coverage probability, rather than the average coverage probability, with the nominal value,   1 α   . {\displaystyle \ 1-\alpha ~.}

Just as the Wilson interval mirrors Pearson's chi-squared test, the Wilson interval with continuity correction mirrors the equivalent Yates' chi-squared test.

The following formulae for the lower and upper bounds of the Wilson score interval with continuity correction   ( w c c , w c c + )   {\displaystyle \ \left(w_{\mathsf {cc}}^{-},w_{\mathsf {cc}}^{+}\right)\ } are derived from Newcombe:

w c c = max {     0   ,       2   n   p ^ + z α 2 [   z α   z α 2   1   n + 4   n   p ^   ( 1 p ^ ) + ( 4   p ^ 2 )     +   1   ]     2 ( n + z α 2 )     }   , w c c + = min {     1   ,       2   n   p ^ + z α 2 + [   z α   z α 2   1   n + 4   n   p ^   ( 1 p ^ ) ( 4   p ^ 2 )     +   1   ]     2 ( n + z α 2 )     } , {\displaystyle {\begin{aligned}w_{\mathsf {cc}}^{-}&=\max \left\{~~0\ ,~~{\frac {\ 2\ n\ {\hat {p}}+z_{\alpha }^{2}-\left\ }{\ 2\left(n+z_{\alpha }^{2}\right)~~}}\right\}\ ,\\w_{\mathsf {cc}}^{+}&=\min \left\{~~1\ ,~~{\frac {\ 2\ n\ {\hat {p}}+z_{\alpha }^{2}+\left\ }{\ 2\left(n+z_{\alpha }^{2}\right)~~}}\right\},\end{aligned}}}

for   p ^ 0   {\displaystyle \ {\hat {p}}\neq 0\ } and   p ^ 1   . {\displaystyle \ {\hat {p}}\neq 1~.}

If   p ^ = 0   , {\displaystyle \ {\hat {p}}=0\ ,} then   w c c   {\displaystyle \ w_{\mathsf {cc}}^{-}\ } must instead be set to   0   ; {\displaystyle \ 0\ ;} if   p ^ = 1   , {\displaystyle \ {\hat {p}}=1\ ,} then   w c c +   {\displaystyle \ w_{\mathsf {cc}}^{+}\ } must be instead set to   1   . {\displaystyle \ 1~.}

Wallis (2021) identifies a simpler method for computing continuity-corrected Wilson intervals that employs a special function based on Wilson's lower-bound formula: In Wallis' notation, for the lower bound, let

  W i l s o n l o w e r (   p ^ ,   n ,     α   2   )     w   =   1   1 + z α 2   / n   (   p ^ + z α 2     2   n             z α     2   n       4   n   p ^   ( 1 p ^ ) +   z α 2     )   , {\displaystyle ~{\mathsf {Wilson_{lower}}}\left(\ {\hat {p}},\ n,\ {\tfrac {\!\ \alpha \!\ }{2}}\ \right)\ \equiv \ w^{-}\ =\ {\frac {1}{~1+z_{\alpha }^{2}\ /n~}}{\Bigg (}\ {\hat {p}}+{\frac {\;z_{\alpha }^{2}\ }{\!\ 2\ n\!\ }}~~-~~{\frac {\!\ z_{\alpha }\!\ }{\!\ 2\ n\!\ }}\ {\sqrt {\ 4\ n\ {\hat {p}}\ (1-{\hat {p}})+\ z_{\alpha }^{2}~}}~{\Biggr )}\ ,}

where   α   {\displaystyle \ \alpha \ } is the selected tolerable error level for   z α   . {\displaystyle \ z_{\alpha }~.} Then

  w c c = W i l s o n l o w e r (   max {   p ^ 1   2   n   ,   0   } ,   n ,     α   2   )   . {\displaystyle \ w_{\mathsf {cc}}^{-}={\mathsf {Wilson_{lower}}}\left(\ \max \left\{\ {\hat {p}}-{\tfrac {1}{\!\ 2\ n\!\ }},\ 0\ \right\},\ n,\ {\tfrac {\!\ \alpha \!\ }{2}}\ \right)~.}

This method has the advantage of being further decomposable.

Jeffreys interval

The Jeffreys interval has a Bayesian derivation, but good frequentist properties (outperforming most frequentist constructions). In particular, it has coverage properties that are similar to those of the Wilson interval, but it is one of the few intervals with the advantage of being equal-tailed (e.g., for a 95% confidence interval, the probabilities of the interval lying above or below the true value are both close to 2.5%). In contrast, the Wilson interval has a systematic bias such that it is centred too close to   p = 0.5   . {\displaystyle \ p=0.5~.}

The Jeffreys interval is the Bayesian credible interval obtained when using the non-informative Jeffreys prior for the binomial proportion   p   . {\displaystyle \ p~.} The Jeffreys prior for this problem is a Beta distribution with parameters   (   1   2 ,   1   2 )   , {\displaystyle \ \left({\tfrac {\!\ 1\!\ }{2}},{\tfrac {\!\ 1\!\ }{2}}\right)\ ,} a conjugate prior. After observing   x   {\displaystyle \ x\ } successes in   n   {\displaystyle \ n\ } trials, the posterior distribution for   p   {\displaystyle \ p\ } is a Beta distribution with parameters   ( x +   1   2 , n x +   1   2 )   . {\displaystyle \ \left(x+{\tfrac {\!\ 1\!\ }{2}},n-x+{\tfrac {\!\ 1\!\ }{2}}\right)~.}

When   x 0   {\displaystyle \ x\neq 0\ } and   x n   , {\displaystyle \ x\neq n\ ,} the Jeffreys interval is taken to be the   100   ( 1 α )   %   {\displaystyle \ 100\ \left(1-\alpha \right)\ \mathrm {\%} \ } equal-tailed posterior probability interval, i.e., the     1   2   α   {\displaystyle \ {\tfrac {\!\ 1\!\ }{2}}\ \alpha \ } and   1   1   2   α   {\displaystyle \ 1-{\tfrac {\!\ 1\!\ }{2}}\ \alpha \ } quantiles of a Beta distribution with parameters   (   x +   1   2 ,   n x +   1   2   )   . {\displaystyle \ \left(\ x+{\tfrac {\!\ 1\!\ }{2}},\ n-x+{\tfrac {\!\ 1\!\ }{2}}\ \right)~.}

In order to avoid the coverage probability tending to zero when   p 0   {\displaystyle \ p\to 0\ } or 1 , when   x = 0   {\displaystyle \ x=0\ } the upper limit is calculated as before but the lower limit is set to 0 , and when   x = n   {\displaystyle \ x=n\ } the lower limit is calculated as before but the upper limit is set to 1 .

Jeffreys' interval can also be thought of as a frequentist interval based on inverting the p-value from the G-test after applying the Yates correction to avoid a potentially-infinite value for the test statistic.

Clopper–Pearson interval

The Clopper–Pearson interval is an early and very common method for calculating binomial confidence intervals. This is often called an 'exact' method, as it attains the nominal coverage level in an exact sense, meaning that the coverage level is never less than the nominal   1 α   . {\displaystyle \ 1-\alpha ~.}

The Clopper–Pearson interval can be written as

  S S   {\displaystyle \ S_{\leq }\cap S_{\geq }\ }

or equivalently,

  ( inf S   ,   sup S )   {\displaystyle \ \left(\inf S_{\geq }\ ,\ \sup S_{\leq }\right)\ }

with

S     {   p     |     P {   Bin ( n ; p ) x   } >   α   2     }   {\displaystyle S_{\leq }~\equiv ~\left\{~p~~{\Big |}~~\operatorname {\mathbb {P} } \left\{~\operatorname {Bin} \left(n;p\right)\leq x~\right\}>{\tfrac {\!\ \alpha \!\ }{2}}~~\right\}~}

and

  S     {   p     |     P {   Bin ( n ; p ) x } >   α   2     }   , {\displaystyle ~S_{\geq }~\equiv ~\left\{~p~~{\Big |}~~\operatorname {\mathbb {P} } \left\{~\operatorname {Bin} \left(n;p\right)\geq x\right\}>{\tfrac {\!\ \alpha \!\ }{2}}~~\right\}\ ,}

where   0 x n   {\displaystyle \ 0\leq x\leq n\ } is the number of successes observed in the sample and   B i n ( n ; p )   {\displaystyle \ {\mathsf {Bin}}\left(n;p\right)\ } is a binomial random variable with   n   {\displaystyle \ n\ } trials and probability of success   p   . {\displaystyle \ p~.}

Equivalently we can say that the Clopper–Pearson interval is   (     x   n ε 1 ,     x   n + ε 2   )   {\textstyle \ \left(\ {\frac {\!\ x\!\ }{n}}-\varepsilon _{1},\ {\frac {\!\ x\!\ }{n}}+\varepsilon _{2}\ \right)\ } with confidence level   1 α   {\displaystyle \ 1-\alpha \ } if   ε i   {\displaystyle \ \varepsilon _{i}\ } is the infimum of those such that the following tests of hypothesis succeed with significance     α   2   : {\textstyle \ {\frac {\!\ \alpha \!\ }{2}}\ :}

  1. H0:   p =   x   n ε 1   {\displaystyle \ p={\frac {\!\ x\!\ }{n}}-\varepsilon _{1}\ } with HA:   p >   x   n ε 1 {\displaystyle \ p>{\frac {\!\ x\!\ }{n}}-\varepsilon _{1}}
  2. H0:   p =   x   n + ε 2   {\displaystyle \ p={\frac {\!\ x\!\ }{n}}+\varepsilon _{2}\ } with HA:   p <   x   n + ε 2   . {\displaystyle \ p<{\frac {\!\ x\!\ }{n}}+\varepsilon _{2}~.}

Because of a relationship between the binomial distribution and the beta distribution, the Clopper–Pearson interval is sometimes presented in an alternate format that uses quantiles from the beta distribution.

  B (   α   2   ;   x   ,   n x + 1 )   <   p   <   B (   1   α   2   ;   x + 1   ,   n x   )   {\displaystyle \ B\!\left({\tfrac {\!\ \alpha \!\ }{2}}\ ;\ x\ ,\ n-x+1\right)~<~p~<~B\!\left(\ 1-{\tfrac {\!\ \alpha \!\ }{2}}\ ;\ x+1\ ,\ n-x\ \right)\ }

where   x   {\displaystyle \ x\ } is the number of successes,   n   {\displaystyle \ n\ } is the number of trials, and   B (   p   ;   v   ,   w   )   {\displaystyle \ B\!\left(\ p\ ;\ v\ ,\ w\ \right)\ } is the pth quantile from a beta distribution with shape parameters   v   {\displaystyle \ v\ } and   w   . {\displaystyle \ w~.}

Thus,   p min   <   p <   p max   , {\displaystyle \ p_{\min }~<~p<~p_{\max }\ ,} where:

  Γ ( n + 1 )     Γ ( x )   Γ ( n x + 1 )     0 p min   t x 1   ( 1 t ) n x   d   t     =       α   2   , {\displaystyle {\tfrac {\ \Gamma (n+1)\ }{\ \Gamma \!(x)\ \Gamma \!(n-x+1)\ }}\ \int _{0}^{p_{\min }}\ t^{x-1}\ (1-t)^{n-x}\ \mathrm {d} \!\ t~~=~~{\tfrac {\!\ \alpha \!\ }{2}}\ ,}
Γ ( n + 1 ) Γ ( x + 1 ) Γ ( n x )   0 p max   t x   ( 1 t ) n x 1   d   t   =   1   α   2   . {\displaystyle {\tfrac {\Gamma (n+1)}{\Gamma (x+1)\Gamma (n-x)}}\ \int _{0}^{p_{\max }}\ t^{x}\ (1-t)^{n-x-1}\ \mathrm {d} \!\ t~=~1-{\tfrac {\!\ \alpha \!\ }{2}}~.}

The binomial proportion confidence interval is then   (   p min   ,   p max )   , {\displaystyle \ \left(\ p_{\min }\ ,\ p_{\max }\right)\ ,} as follows from the relation between the Binomial distribution cumulative distribution function and the regularized incomplete beta function.

When   x   {\displaystyle \ x\ } is either 0 or   n   , {\displaystyle \ n\ ,} closed-form expressions for the interval bounds are available: when   x = 0   {\displaystyle \ x=0\ } the interval is

  ( 0   ,   1 (     α   2   ) 1 / n )   {\textstyle \ \left(0\ ,\ 1-\left(\ {\tfrac {\!\ \alpha \!\ }{2}}\ \right)^{1/n}\right)\ }

and when   x = n   {\displaystyle \ x=n\ } it is

  (   (   α   2   ) 1 / n   ,   1   )   . {\textstyle \ \left(\ \left({\tfrac {\!\ \alpha \!\ }{2}}\ \right)^{1/n}\ ,\ 1\ \right)~.}

The beta distribution is, in turn, related to the F-distribution so a third formulation of the Clopper–Pearson interval can be written using F quantiles:

(   1 +   n x + 1     x   F [     α   2   ;   2   x   ,   2   (   n x + 1   )   ]     ) 1     <     p     <     (   1 +   n x   ( x + 1 )     F [   1   α   2   ;   2   ( x + 1 )   ,   2   ( n x   )   ]     ) 1 {\displaystyle \left(\ 1+{\frac {\ n-x+1\ }{\ x\ F\!\left\ }}\ \right)^{-1}~~<~~p~~<~~\left(\ 1+{\frac {\ n-x\ }{(x+1)\ \ F\!\left\ }}\ \right)^{-1}}

where   x   {\displaystyle \ x\ } is the number of successes,   n   {\displaystyle \ n\ } is the number of trials, and   F (   c   ;   d 1   , d 2   )   {\displaystyle \ F\!\left(\ c\ ;\ d_{1}\ ,d_{2}\ \right)\ } is the   c   {\displaystyle \ c\ } quantile from an F-distribution with   d 1   {\displaystyle \ d_{1}\ } and   d 2   {\displaystyle \ d_{2}\ } degrees of freedom.

The Clopper–Pearson interval is an 'exact' interval, since it is based directly on the binomial distribution rather than any approximation to the binomial distribution. This interval never has less than the nominal coverage for any population proportion, but that means that it is usually conservative. For example, the true coverage rate of a 95% Clopper–Pearson interval may be well above 95%, depending on   n   {\displaystyle \ n\ } and   p   . {\displaystyle \ p~.} Thus the interval may be wider than it needs to be to achieve 95% confidence, and wider than other intervals. In contrast, it is worth noting that other confidence interval may have coverage levels that are lower than the nominal   1 α   , {\displaystyle \ 1-\alpha \ ,} i.e., the normal approximation (or "standard") interval, Wilson interval, Agresti–Coull interval, etc., with a nominal coverage of 95% may in fact cover less than 95%, even for large sample sizes.

The definition of the Clopper–Pearson interval can also be modified to obtain exact confidence intervals for different distributions. For instance, it can also be applied to the case where the samples are drawn without replacement from a population of a known size, instead of repeated draws of a binomial distribution. In this case, the underlying distribution would be the hypergeometric distribution.

The interval boundaries can be computed with numerical functions qbeta in R and scipy.stats.beta.ppf in Python.

from scipy.stats import beta
k = 20
n = 400
alpha = 0.05
p_u, p_o = beta.ppf(, , )

Agresti–Coull interval

The Agresti–Coull interval is also another approximate binomial confidence interval.

Given   n s   {\displaystyle \ n_{\mathsf {s}}\ } successes in   n   {\displaystyle \ n\ } trials, define

  n ~ n + z α 2   {\displaystyle \ {\tilde {n}}\equiv n+z_{\alpha }^{2}\ }

and

  p ~ = 1   n ~   (   n s +   z α 2 2   )   {\displaystyle \ {\tilde {p}}={\frac {1}{\!\ {\tilde {n}}\!\ }}\left(\!\ n_{\mathsf {s}}+{\tfrac {\ z_{\alpha }^{2}}{2}}\!\ \right)\ }

Then, a confidence interval for   p   {\displaystyle \ p\ } is given by

  p         p ~   ±   z α     p ~   n ~   (   1 p ~   )   {\displaystyle \ p~~\approx ~~{\tilde {p}}~\pm ~z_{\alpha }\ {\sqrt {{\frac {\!\ {\tilde {p}}\!\ }{\tilde {n}}}\ \left(\!\ 1-{\tilde {p}}\!\ \right)~}}}

where   z α = Φ - 1 (   1   α   2   )   {\displaystyle \ z_{\alpha }=\operatorname {\Phi ^{-1}} \!\!\left(\ 1-{\tfrac {\!\ \alpha \!\ }{2}}\ \right)\ } is the quantile of a standard normal distribution, as before (for example, a 95% confidence interval requires   α = 0.05   , {\displaystyle \ \alpha =0.05\ ,} thereby producing   z .05 = 1.96   {\displaystyle \ z_{.05}=1.96\ } ). According to Brown, Cai, & DasGupta (2001), taking   z = 2   {\displaystyle \ z=2\ } instead of 1.96 produces the "add 2 successes and 2 failures" interval previously described by Agresti & Coull.

This interval can be summarised as employing the centre-point adjustment,   p ~   , {\displaystyle \ {\tilde {p}}\ ,} of the Wilson score interval, and then applying the Normal approximation to this point.

  p ~ = p ^ +   z α 2     2   n   1 +   z α 2 n   {\displaystyle \ {\tilde {p}}={\frac {\quad {\hat {p}}+{\frac {\ z_{\alpha }^{2}\!\ }{\ 2\ n\ }}\quad }{\quad 1+{\frac {\ z_{\alpha }^{2}}{n}}\quad }}\ }

Arcsine transformation

Main article: Arcsine transformation Further information: Cohen's h

The arcsine transformation has the effect of pulling out the ends of the distribution. While it can stabilize the variance (and thus confidence intervals) of proportion data, its use has been criticized in several contexts.

Let   X   {\displaystyle \ X\ } be the number of successes in   n   {\displaystyle \ n\ } trials and let   p = 1   n     X   . {\displaystyle \ p={\tfrac {1}{\!\ n\!\ }}\!\ X~.} The variance of   p   {\displaystyle \ p\ } is

var {     p     } = 1   n     p   ( 1 p )   . {\displaystyle \operatorname {var} \{~~p~~\}={\tfrac {1}{\!\ n\!\ }}\ p\ (1-p)~.}

Using the arc sine transform, the variance of the arcsine of     p     {\displaystyle \ {\sqrt {\ p~}}\ } is

  var {     arcsin p       }       var {     p     }     4   p   ( 1 p )   =   p   ( 1 p )     4   n   p   ( 1 p )   =   1     4   n     . {\displaystyle \ \operatorname {var} \left\{~~\arcsin {\sqrt {p~}}~~\right\}~\approx ~{\frac {\ \operatorname {var} \{~~p~~\}\ }{\ 4\ p\ (1-p)\ }}={\frac {\ p\ (1-p)\ }{\ 4\ n\ p\ (1-p)\ }}={\frac {\ 1\ }{\ 4\ n\ }}~.}

So, the confidence interval itself has the form

  sin 2 (     z α   2   n     + arcsin p     )   <   θ   <   sin 2 (   +     z α     2   n       + arcsin p     )   , {\displaystyle \ \sin ^{2}\left(\ -\ {\frac {z_{\alpha }}{\ 2\ {\sqrt {n\ }}\ }}+\arcsin {\sqrt {p\ }}~\right)~<~\theta ~<~\sin ^{2}\left(\ +\ {\frac {\ z_{\alpha }\ }{\ 2\ {\sqrt {n\ }}\ }}\ +\arcsin {\sqrt {p\ }}~\right)\ ,}

where   z α   {\displaystyle \ z_{\alpha }\ } is the   1       α   2   {\displaystyle \ 1\ -\ {\tfrac {\!\ \alpha \!\ }{2}}\ } quantile of a standard normal distribution.

This method may be used to estimate the variance of   p   {\displaystyle \ p\ } but its use is problematic when   p   {\displaystyle \ p\ } is close to 0 or 1 .

ta transform

This section does not cite any sources. Please help improve this section by adding citations to reliable sources. Unsourced material may be challenged and removed. (July 2017) (Learn how and when to remove this message)

Let   p   {\displaystyle \ p\ } be the proportion of successes. For   0 a 2   , {\displaystyle \ 0\leq a\leq 2\ ,}

  t a   =   log (     p a     ( 1 p ) 2 a     )   =   a   log p ( 2 a )   log (   1 p   )   {\displaystyle \ t_{a}\ =\ \log \left(\ {\frac {\ p^{a}\ }{\ (1-p)^{2-a}\ }}\ \right)\ =\ a\ \log p-(2-a)\ \log(\ 1-p\ )\ }

This family is a generalisation of the logit transform which is a special case with a = 1 and can be used to transform a proportional data distribution to an approximately normal distribution. The parameter a has to be estimated for the data set.

Rule of three — for when no successes are observed

The rule of three is used to provide a simple way of stating an approximate 95% confidence interval for   p   , {\displaystyle \ p\ ,} in the special case that no successes (   p ^ = 0   {\displaystyle \ {\hat {p}}=0\ } ) have been observed. The interval is   (   0 ,     3   n )   . {\displaystyle \ \left(\ 0,\ {\tfrac {\!\ 3\!\ }{n}}\right)~.}

By symmetry, in the case of only successes (   p ^ = 1   {\displaystyle \ {\hat {p}}=1\ } ), the interval is   (   1   3   n ,   1   )   . {\displaystyle \ \left(\ 1-{\tfrac {\!\ 3\!\ }{n}},\ 1\ \right)~.}

Comparison and discussion

There are several research papers that compare these and other confidence intervals for the binomial proportion.

Both Ross (2003) and Agresti & Coull (1998) point out that exact methods such as the Clopper–Pearson interval may not work as well as some approximations. The normal approximation interval and its presentation in textbooks has been heavily criticised, with many statisticians advocating that it not be used. The principal problems are overshoot (bounds exceed   [   0 ,   1   ]   {\displaystyle \ \left\ } ), zero-width intervals at   p ^   = 0   {\displaystyle \ {\hat {p}}\ =0\ } or 1 (falsely implying certainty), and overall inconsistency with significance testing.

Of the approximations listed above, Wilson score interval methods (with or without continuity correction) have been shown to be the most accurate and the most robust, though some prefer Agresti & Coulls' approach for larger sample sizes. Wilson and Clopper–Pearson methods obtain consistent results with source significance tests, and this property is decisive for many researchers.

Many of these intervals can be calculated in R using packages like binom.

See also

References

  1. Sullivan, Lisa (2017-10-27). "Confidence Intervals". sphweb.bumc.bu.edu (course notes). Boston, MA: Boston University School of Public Health. BS704.
  2. ^ Newcombe, R.G. (1998). "Two-sided confidence intervals for the single proportion: Comparison of seven methods". Statistics in Medicine. 17 (8): 857–872. doi:10.1002/(SICI)1097-0258(19980430)17:8<857::AID-SIM777>3.0.CO;2-E. PMID 9595616.
  3. ^ Wallis, Sean A. (2013). "Binomial confidence intervals and contingency tests: Mathematical fundamentals and the evaluation of alternative methods" (PDF). Journal of Quantitative Linguistics. 20 (3): 178–208. doi:10.1080/09296174.2013.799918. S2CID 16741749.
  4. ^ Brown, Lawrence D.; Cai, T. Tony; DasGupta, Anirban (2001). "Interval estimation for a binomial proportion". Statistical Science. 16 (2): 101–133. CiteSeerX 10.1.1.50.3025. doi:10.1214/ss/1009213286. MR 1861069. Zbl 1059.62533.
  5. Laplace, P.S. (1812). Théorie analytique des probabilités [Analyitic Probability Theory] (in French). Ve. Courcier. p. 283.
  6. ^ Short, Michael (2021-11-08). "On binomial quantile and proportion bounds: With applications in engineering and informatics". Communications in Statistics - Theory and Methods. 52 (12): 4183–4199. doi:10.1080/03610926.2021.1986540. ISSN 0361-0926. S2CID 243974180.
  7. "How to calculate the standard error of a proportion using weighted data?". stats.stackexchange.com. 159220 / 253.
  8. ^ Wilson, E.B. (1927). "Probable inference, the law of succession, and statistical inference". Journal of the American Statistical Association. 22 (158): 209–212. doi:10.1080/01621459.1927.10502953. JSTOR 2276774.
  9. ^ Wallis, Sean A. (2021). Statistics in Corpus Linguistics: A new approach. New York, NY: Routledge. ISBN 9781138589384.
  10. Cai, T.T. (2005). "One-sided confidence intervals in discrete distributions". Journal of Statistical Planning and Inference. 131 (1): 63–88. doi:10.1016/j.jspi.2004.01.005.
  11. Clopper, C.; Pearson, E.S. (1934). "The use of confidence or fiducial limits illustrated in the case of the binomial". Biometrika. 26 (4): 404–413. doi:10.1093/biomet/26.4.404.
  12. ^ Thulin, Måns (2014-01-01). "The cost of using exact confidence intervals for a binomial proportion". Electronic Journal of Statistics. 8 (1): 817–840. arXiv:1303.1288. doi:10.1214/14-EJS909. ISSN 1935-7524. S2CID 88519382.
  13. ^ Agresti, Alan; Coull, Brent A. (1998). "Approximate is better than 'exact' for interval estimation of binomial proportions". The American Statistician. 52 (2): 119–126. doi:10.2307/2685469. JSTOR 2685469. MR 1628435.
  14. "The Beta distribution". stat.ethz.ch (software doc). R Manual. Retrieved 2023-12-02.
  15. "scipy.stats.beta". SciPy Manual. docs.scipy.org (software doc) (1.11.4 ed.). Retrieved 2023-12-02.
  16. Holland, Steven. "Transformations of proportions and percentages". strata.uga.edu. Retrieved 2020-09-08.
  17. Warton, David I.; Hui, Francis K.C. (January 2011). "The arcsine is asinine: The analysis of proportions in ecology". Ecology. 92 (1): 3–10. Bibcode:2011Ecol...92....3W. doi:10.1890/10-0340.1. hdl:1885/152287. ISSN 0012-9658. PMID 21560670.
  18. Shao, J. (1998). Mathematical Statistics. New York, NY: Springer.
  19. Simon, Steve (2010). "Confidence interval with zero events". Ask Professor Mean. Kansas City, MO: The Children's Mercy Hospital. Archived from the original on 15 October 2011. Stats topics on Medical Research
  20. Sauro, J.; Lewis, J.R. (2005). Comparison of Wald, Adj-Wald, exact, and Wilson intervals calculator (PDF). Human Factors and Ergonomics Society, 49th Annual Meeting (HFES 2005). Orlando, FL. pp. 2100–2104. Archived from the original (PDF) on 18 June 2012.
  21. Reiczigel, J. (2003). "Confidence intervals for the binomial parameter: Some new considerations" (PDF). Statistics in Medicine. 22 (4): 611–621. doi:10.1002/sim.1320. PMID 12590417. S2CID 7715293.
  22. Ross, T.D. (2003). "Accurate confidence intervals for binomial proportion and Poisson rate estimation". Computers in Biology and Medicine. 33 (6): 509–531. doi:10.1016/S0010-4825(03)00019-2. PMID 12878234.
  23. Dorai-Raj, Sundar (2 May 2022). binom: Binomial confidence intervals for several parameterizations (software doc.). Retrieved 2 December 2023.
Categories: