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 |
Details
The confidence intervals are:
Jeffreys:
\left[ F(\alpha/2; x+0.5, n-x+0.5), F(1-\alpha/2; x+0.5, n-x+0.5) \right],
where F(\alpha, a, b)
denotes the \alpha
quantile of the Beta distribution with parameters a
and b
, Be(a, b)
.
Wald:
\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],
where \hat{p}=\frac{x}{n}
and Z_{1-\alpha/2}
denotes the 1-\alpha/2
quantile of the standard normal distribution. If \hat{p}=0
the interval becomes (0 , 1 - e^{\frac{1}{n}\log({\alpha}{2})})
and if \hat{p}=1
the interval becomes (e^{\frac{1}{n}\log({\alpha}{2})}, 1)
.
Wald corrected:
\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],
and if \hat{p}=0
or \hat{p}=1
the previous (Wald) adjustment applies.
Wald BS:
\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],
and if \hat{p}=0
or \hat{p}=1
the previous (Wald) adjustment applies.
Agresti and Coull:
\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],
where \hat{\theta}=\frac{x+2}{n+4}
.
Wilson:
\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],
where x_b=x+Z_{1-\alpha/2}^2/2
and n_b=n+Z_{1-\alpha/2}^2
.
Score:
\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],
where c=Z_{1-\alpha/2}\sqrt{x-x^2/n+Z_{1-\alpha/2}^2/4}
.
Score corrected:
\left[ \frac{\ell_1}{n+Z_{1-\alpha/2}} , \frac{\ell_2}{n+Z_{1-\alpha/2}} \right],
where \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}
, \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}
and b_1=x-0.5
, b_2=x+0.5
.
Wald-logit:
\left[ 1-(1+e^{b-c})^{-1}, 1-(1+e^{b+c})^{-1} \right],
where b=\log(\frac{x}{n-x})
and c=\frac{Z_{1-\alpha/2}}{\sqrt{n\hat{p}(1-\hat{p})}}
. If \hat{p}=0
or \hat{p}=1
the previous (Wald) adjustment applies.
Wald-logit corrected:
\left[ 1-(1+e^{b-c})^{-1}, 1-(1+e^{b+c})^{-1} \right],
where b=\log(\frac{\hat{p}_b}{\hat{q}_b})
, \hat{p}_b=x+0.5
, \hat{q}_b=n-x+0.5
and c=\frac{Z_{1-\alpha/2}}{\sqrt{(n+1)\frac{\hat{p}_b}{n+1}(1-\frac{\hat{p}_b}{n+1})}}
.
Arcsine:
\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.
If \hat{p}=0
or \hat{p}=1
the previous (Wald) adjustment applies.
Exact binomial:
\left[ (1+\frac{a_1}{d_1})^{-1}, (1+\frac{a_2}{d_2})^{-1} \right],
where a_1=n-x+1
, a_2=a_1-1
, d_1=x-F(\alpha/2,2x,2a_1)
, d_2=(x+1)F(1-\alpha/2,2(x+1),2a_2)
and F(\alpha,a,b)
denotes the \alpha
quantile of the F distribution with degrees of freedom a
and b
, F(a, b)
.
Value
A list including:
prop |
The proportion. |
ci |
A matrix with 12 rows containing the 12 different |
Author(s)
Michail Tsagris.
R implementation and documentation: Michail Tsagris mtsagris@uoc.gr.
See Also
Examples
binomCI(45, 100)