binom.midp(x, n, conf.level=0.95)
binom.confint
function of the binom
packageuniroot
to determine the upper and lower
bounds of the mid-p confidence interval.The lower bound $p_l$ is found as the solution to the equation $$\frac{1}{2} f(x;n,p_l) + (1-F(x;m,p_l)) = \frac{\alpha}{2}$$ where $f(x;n,p)$ denotes the probability mass function (pmf) and $F(x;n,p)$ the (cumulative) distribution function of the binomial distribution with size $n$ and proportion $p$ evaluated at $x$. In case x=0 then the lower bound is zero.
The upper bound $p_u$ is found as the solution to the equation $$\frac{1}{2} f(x;n,p_u) + F(x-1;m,p_u) = \frac{\alpha}{2}$$ In case x=n then the upper bound is 1.
Fosage, G.T. (2005) Modified exact sample size for a binomial proportion with special emphasis on diagnostic test parameter estimation, Statistics in Medicine 24(18):2857-66.
A. Agresti and A. Gottard (2005), Comment: Randomized Confidence Intervals and the Mid-P Approach, Statistical Science, 20(4):367--371
binom.midp(x=0:10,n=10)
binom.midp(x=0:5,n=5,conf.level=0.9)
Run the code above in your browser using DataLab