binomCI {binomCI} R Documentation
Confidence Intervals for a Binomial Proportion.
Description
Confidence Intervals for a Binomial Proportion.
Usage
binomCI(x, n, a = 0.05)
Arguments
x
The number of successes.
n
The number of trials.
a
The significance level to compute the ( 1 − α ) % (1-\alpha)\% ( 1 − α ) %
confidence intervals.
Details
The confidence intervals are:
Jeffreys :
[ F ( α / 2 ; x + 0.5 , n − x + 0.5 ) , F ( 1 − α / 2 ; x + 0.5 , n − x + 0.5 ) ] ,
\left[ F(\alpha/2; x+0.5, n-x+0.5), F(1-\alpha/2; x+0.5, n-x+0.5) \right],
[ F ( α /2 ; x + 0.5 , n − x + 0.5 ) , F ( 1 − α /2 ; x + 0.5 , n − x + 0.5 ) ] ,
where F ( α , a , b ) F(\alpha, a, b) F ( α , a , b )
denotes the α \alpha α
quantile of the Beta distribution with parameters a a a
and b b b
, B e ( a , b ) Be(a, b) B e ( a , b )
.
Wald :
[ p ^ − Z 1 − α / 2 × p ^ ( 1 − p ^ ) n , p ^ − Z 1 − α / 2 × p ^ ( 1 − p ^ ) n ] ,
\left[ \hat{p} - Z_{1-\alpha/2} \times \sqrt{\frac{\hat{p}(1-\hat{p})}{n}}, \hat{p} - Z_{1-\alpha/2} \times \sqrt{\frac{\hat{p}(1-\hat{p})}{n}} \right],
[ p ^ − Z 1 − α /2 × n p ^ ( 1 − p ^ ) , p ^ − Z 1 − α /2 × n p ^ ( 1 − p ^ ) ] ,
where p ^ = x n \hat{p}=\frac{x}{n} p ^ = n x
and Z 1 − α / 2 Z_{1-\alpha/2} Z 1 − α /2
denotes the 1 − α / 2 1-\alpha/2 1 − α /2
quantile of the standard normal distribution. If p ^ = 0 \hat{p}=0 p ^ = 0
the interval becomes ( 0 , 1 − e 1 n log ( α 2 ) ) (0 , 1 - e^{\frac{1}{n}\log({\alpha}{2})}) ( 0 , 1 − e n 1 l o g ( α 2 ) )
and if p ^ = 1 \hat{p}=1 p ^ = 1
the interval becomes ( e 1 n log ( α 2 ) , 1 ) (e^{\frac{1}{n}\log({\alpha}{2})}, 1) ( e n 1 l o g ( α 2 ) , 1 )
.
Wald corrected :
[ p ^ − Z 1 − α / 2 × p ^ ( 1 − p ^ ) n − 0.5 n , p ^ − Z 1 − α / 2 × p ^ ( 1 − p ^ ) n + 0.5 n ] ,
\left[ \hat{p} - Z_{1-\alpha/2} \times \sqrt{\frac{\hat{p}(1-\hat{p})}{n}} - \frac{0.5}{n}, \hat{p} - Z_{1-\alpha/2} \times \sqrt{\frac{\hat{p}(1-\hat{p})}{n}} + \frac{0.5}{n} \right],
[ p ^ − Z 1 − α /2 × n p ^ ( 1 − p ^ ) − n 0.5 , p ^ − Z 1 − α /2 × n p ^ ( 1 − p ^ ) + n 0.5 ] ,
and if p ^ = 0 \hat{p}=0 p ^ = 0
or p ^ = 1 \hat{p}=1 p ^ = 1
the previous (Wald) adjustment applies.
Wald BS :
[ p ^ − Z 1 − α / 2 × p ^ ( 1 − p ^ ) n − Z 1 − α / 2 − 2 Z 1 − α / 2 / n − 1 / n − 0.5 n , p ^ − Z 1 − α / 2 × p ^ ( 1 − p ^ ) n − Z 1 − α / 2 − 2 Z 1 − α / 2 / n − 1 / n + 0.5 n ] ,
\left[ \hat{p} - Z_{1-\alpha/2} \times \sqrt{\frac{\hat{p}(1-\hat{p})}{n-Z_{1-\alpha/2}-2Z_{1-\alpha/2}/n-1/n}} - \frac{0.5}{n}, \hat{p} - Z_{1-\alpha/2} \times \sqrt{\frac{\hat{p}(1-\hat{p})}{n-Z_{1-\alpha/2}-2Z_{1-\alpha/2}/n-1/n}} + \frac{0.5}{n} \right],
[ p ^ − Z 1 − α /2 × n − Z 1 − α /2 − 2 Z 1 − α /2 / n − 1/ n p ^ ( 1 − p ^ ) − n 0.5 , p ^ − Z 1 − α /2 × n − Z 1 − α /2 − 2 Z 1 − α /2 / n − 1/ n p ^ ( 1 − p ^ ) + n 0.5 ] ,
and if p ^ = 0 \hat{p}=0 p ^ = 0
or p ^ = 1 \hat{p}=1 p ^ = 1
the previous (Wald) adjustment applies.
Agresti and Coull :
[ θ ^ − Z 1 − α / 2 × θ ^ ( 1 − θ ^ ) n + 4 , p ^ − Z 1 − α / 2 × θ ^ ( 1 − θ ^ ) n + 4 ] ,
\left[ \hat{\theta} - Z_{1-\alpha/2} \times \sqrt{\frac{\hat{\theta}(1-\hat{\theta})}{n+4}}, \hat{p} - Z_{1-\alpha/2} \times \sqrt{\frac{\hat{\theta}(1-\hat{\theta})}{n+4}} \right],
[ θ ^ − Z 1 − α /2 × n + 4 θ ^ ( 1 − θ ^ ) , p ^ − Z 1 − α /2 × n + 4 θ ^ ( 1 − θ ^ ) ] ,
where θ ^ = x + 2 n + 4 \hat{\theta}=\frac{x+2}{n+4} θ ^ = n + 4 x + 2
.
Wilson :
[ x b n b − Z 1 − α / 2 n n b × p ^ ( 1 − p ^ ) + Z 1 − α / 2 / 4 , x b n b + Z 1 − α / 2 n n b × p ^ ( 1 − p ^ ) + Z 1 − α / 2 / 4 ] ,
\left[ \frac{x_b}{n_b} - \frac{Z_{1-\alpha/2}\sqrt{n}}{n_b} \times \sqrt{\hat{p}(1-\hat{p})+Z_{1-\alpha/2}/4}, \frac{x_b}{n_b} + \frac{Z_{1-\alpha/2}\sqrt{n}}{n_b} \times \sqrt{\hat{p}(1-\hat{p})+Z_{1-\alpha/2}/4} \right],
[ n b x b − n b Z 1 − α /2 n × p ^ ( 1 − p ^ ) + Z 1 − α /2 /4 , n b x b + n b Z 1 − α /2 n × p ^ ( 1 − p ^ ) + Z 1 − α /2 /4 ] ,
where x b = x + Z 1 − α / 2 2 / 2 x_b=x+Z_{1-\alpha/2}^2/2 x b = x + Z 1 − α /2 2 /2
and n b = n + Z 1 − α / 2 2 n_b=n+Z_{1-\alpha/2}^2 n b = n + Z 1 − α /2 2
.
Score :
[ x + Z 1 − α / 2 2 − c n + Z 1 − α / 2 2 , x + Z 1 − α / 2 2 + c n + Z 1 − α / 2 2 ] ,
\left[ \frac{x+Z_{1-\alpha/2}^2-c}{n+Z_{1-\alpha/2}^2} , \frac{x+Z_{1-\alpha/2}^2+c}{n+Z_{1-\alpha/2}^2} \right],
[ n + Z 1 − α /2 2 x + Z 1 − α /2 2 − c , n + Z 1 − α /2 2 x + Z 1 − α /2 2 + c ] ,
where c = Z 1 − α / 2 x − x 2 / n + Z 1 − α / 2 2 / 4 c=Z_{1-\alpha/2}\sqrt{x-x^2/n+Z_{1-\alpha/2}^2/4} c = Z 1 − α /2 x − x 2 / n + Z 1 − α /2 2 /4
.
Score corrected :
[ ℓ 1 n + Z 1 − α / 2 , ℓ 2 n + Z 1 − α / 2 ] ,
\left[ \frac{\ell_1}{n+Z_{1-\alpha/2}} , \frac{\ell_2}{n+Z_{1-\alpha/2}} \right],
[ n + Z 1 − α /2 ℓ 1 , n + Z 1 − α /2 ℓ 2 ] ,
where ℓ 1 = b 1 + 0.5 Z 1 − α / 2 2 − Z 1 − α / 2 b 1 − b 1 2 / n + 0.25 Z 1 − α / 2 2 \ell_1=b_1+0.5Z_{1-\alpha/2}^2-Z_{1-\alpha/2}\sqrt{b_1-b_1^2/n+0.25Z_{1-\alpha/2}^2} ℓ 1 = b 1 + 0.5 Z 1 − α /2 2 − Z 1 − α /2 b 1 − b 1 2 / n + 0.25 Z 1 − α /2 2
, ℓ 2 = b 2 + 0.5 Z 1 − α / 2 2 + Z 1 − α / 2 b 2 − b 2 2 / n + 0.25 Z 1 − α / 2 2 \ell_2=b_2+0.5Z_{1-\alpha/2}^2+Z_{1-\alpha/2}\sqrt{b_2-b_2^2/n+0.25Z_{1-\alpha/2}^2} ℓ 2 = b 2 + 0.5 Z 1 − α /2 2 + Z 1 − α /2 b 2 − b 2 2 / n + 0.25 Z 1 − α /2 2
and b 1 = x − 0.5 b_1=x-0.5 b 1 = x − 0.5
, b 2 = x + 0.5 b_2=x+0.5 b 2 = x + 0.5
.
Wald-logit :
[ 1 − ( 1 + e b − c ) − 1 , 1 − ( 1 + e b + c ) − 1 ] ,
\left[ 1-(1+e^{b-c})^{-1}, 1-(1+e^{b+c})^{-1} \right],
[ 1 − ( 1 + e b − c ) − 1 , 1 − ( 1 + e b + c ) − 1 ] ,
where b = log ( x n − x ) b=\log(\frac{x}{n-x}) b = log ( n − x x )
and c = Z 1 − α / 2 n p ^ ( 1 − p ^ ) c=\frac{Z_{1-\alpha/2}}{\sqrt{n\hat{p}(1-\hat{p})}} c = n p ^ ( 1 − p ^ ) Z 1 − α /2
. If p ^ = 0 \hat{p}=0 p ^ = 0
or p ^ = 1 \hat{p}=1 p ^ = 1
the previous (Wald) adjustment applies.
Wald-logit corrected :
[ 1 − ( 1 + e b − c ) − 1 , 1 − ( 1 + e b + c ) − 1 ] ,
\left[ 1-(1+e^{b-c})^{-1}, 1-(1+e^{b+c})^{-1} \right],
[ 1 − ( 1 + e b − c ) − 1 , 1 − ( 1 + e b + c ) − 1 ] ,
where b = log ( p ^ b q ^ b ) b=\log(\frac{\hat{p}_b}{\hat{q}_b}) b = log ( q ^ b p ^ b )
, p ^ b = x + 0.5 \hat{p}_b=x+0.5 p ^ b = x + 0.5
, q ^ b = n − x + 0.5 \hat{q}_b=n-x+0.5 q ^ b = n − x + 0.5
and c = Z 1 − α / 2 ( n + 1 ) p ^ b n + 1 ( 1 − p ^ b n + 1 ) c=\frac{Z_{1-\alpha/2}}{\sqrt{(n+1)\frac{\hat{p}_b}{n+1}(1-\frac{\hat{p}_b}{n+1})}} c = ( n + 1 ) n + 1 p ^ b ( 1 − n + 1 p ^ b ) Z 1 − α /2
.
Arcsine :
{ sin 2 [ s i n − 1 ( p ^ ) − 0.5 Z 1 − α / 2 n ] , sin 2 [ s i n − 1 ( p ^ ) + 0.5 Z 1 − α / 2 n ] } .
\left\lbrace \sin^2\left[sin^{-1}(\sqrt{\hat{p}})-0.5\frac{Z_{1-\alpha/2}}{\sqrt{n}}\right], \sin^2\left[sin^{-1}(\sqrt{\hat{p}})+0.5\frac{Z_{1-\alpha/2}}{\sqrt{n}}\right] \right\rbrace.
{ sin 2 [ s i n − 1 ( p ^ ) − 0.5 n Z 1 − α /2 ] , sin 2 [ s i n − 1 ( p ^ ) + 0.5 n Z 1 − α /2 ] } .
If p ^ = 0 \hat{p}=0 p ^ = 0
or p ^ = 1 \hat{p}=1 p ^ = 1
the previous (Wald) adjustment applies.
Exact binomial :
[ ( 1 + a 1 d 1 ) − 1 , ( 1 + a 2 d 2 ) − 1 ] ,
\left[ (1+\frac{a_1}{d_1})^{-1}, (1+\frac{a_2}{d_2})^{-1} \right],
[ ( 1 + d 1 a 1 ) − 1 , ( 1 + d 2 a 2 ) − 1 ] ,
where a 1 = n − x + 1 a_1=n-x+1 a 1 = n − x + 1
, a 2 = a 1 − 1 a_2=a_1-1 a 2 = a 1 − 1
, d 1 = x − F ( α / 2 , 2 x , 2 a 1 ) d_1=x-F(\alpha/2,2x,2a_1) d 1 = x − F ( α /2 , 2 x , 2 a 1 )
, d 2 = ( x + 1 ) F ( 1 − α / 2 , 2 ( x + 1 ) , 2 a 2 ) d_2=(x+1)F(1-\alpha/2,2(x+1),2a_2) d 2 = ( x + 1 ) F ( 1 − α /2 , 2 ( x + 1 ) , 2 a 2 )
and F ( α , a , b ) F(\alpha,a,b) F ( α , a , b )
denotes the α \alpha α
quantile of the F distribution with degrees of freedom a a a
and b b b
, F ( a , b ) F(a, b) F ( a , b )
.
Value
A list including:
prop
The proportion.
ci
A matrix with 12 rows containing the 12 different ( 1 − α ) % (1-\alpha)\% ( 1 − α ) %
confidence intervals.
Author(s)
Michail Tsagris.
R implementation and documentation: Michail Tsagris mtsagris@uoc.gr .
See Also
binomCIs
Examples
binomCI(45, 100)
[Package
binomCI version 1.1
Index ]