Learn R Programming

binomSamSize (version 0.1-3)

ciss.midp: Sample size calculations using the Fosgate (2005) approach

Description

Calculate sample size for a binomial proportion based on a mid-p confidence interval width specification.

Usage

ciss.midp(p0, d, alpha, nMax=1e6)

Arguments

p0
hypothesized upper bound (if below 0.5, if above 0.5 then lower bound) on the parameter p in the binomial distribution
alpha
an $(1-\alpha/2)\cdot 100%$ confidence interval is computed
d
half width of the confidence interval
nMax
Largest n to check. Interrupt iterations when this value is reached

Value

  • the necessary sample size $n$

Details

Fosgate (2005) discusses the need for improved sample size calculations in cases where the binomial proportion is close to 0 and 1. To improve on this, calculation on confidence intervals based on the mid-p method are suggested where computation of the upper and lower limit are combined into one formula. Given lower and upper bounds $p_l$ and $p_u$ of the (1-alpha)*100% confidence interval, one finds the sample size $n$ as the solution to

$$\frac{1}{2} f(x;n,p_l) + \frac{1}{2} f(x;n,p_u) + (1 - F(x;n,p_l)) + F(x-1;m,p_u) = \alpha$$ 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$. The function then returns $\lceil n \rceil$. Note that in this approach $(p_l,p_u) = p_0 \pm d$, which has to be a subset of $(0,1)$. Another option would be to choose the lower and upper independent specifically. In the above, $x$ is found as the integer value, such that $x/n$ is as close as possible to the hypothesized value p0 as possible.

An alternative approach to determine sample sizes based on the mid-p approach is to manually find the sample size $n$ such that the interval obtained by binom.midp has a length less than $2\cdot d$.

References

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.

See Also

binom.midp, ciss.binom

Examples

Run this code
#Fosgate approach
ciss.midp(p0=0.2,alpha=0.05,d=0.05)
#Iterative increase of n using the general purpose function
ciss.binom( p0=0.2, alpha=0.05, ci.fun=binom.midp, d=0.05)

Run the code above in your browser using DataLab