ciss.wilson {binomSamSize} | R Documentation |
Calculate sample size for a binomial parameter enhancing the traditional Wald-type interval
ciss.wald(p0, d, alpha) ciss.wilson(p0, d, alpha) ciss.agresticoull(p0, d, alpha)
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-α/2)\cdot 100\% confidence interval is computed |
d |
half width of the confidence interval |
Given a pre set α-level and an anticipated value of p, say p_0, the objective is to find the minimum sample size n such that the confidence interval will lead to an interval of length 2\cdot d.
The work in Piegorsch (2004) gives a number of formulas enhancing the traditional Wald-type interval.
the necessary sample size n
M. Höhle
Piegorsch, W. W. (2004), Sample sizes for improved binomial confidence intervals, Computational Statistics and Data Analysis, 46:309–316.
#Simple calculation at one proportion (worst case) ciss.wald(p0=0.5,alpha=0.1,d=0.05) #Evaluate for a grid of hypothesized proportion p.grid <- seq(0,0.5,length=100) cissfuns <- list(ciss.wald, ciss.wilson, ciss.agresticoull) ns <- sapply(p.grid, function(p) { unlist(lapply(cissfuns, function(f) f(p, d=0.1, alpha=0.05))) }) matplot(p.grid, t(ns),type="l",xlab=expression(p[0]),ylab="n",lwd=2) legend(x="topleft", c("Wald", "Wilson","Agresti-Coull"), col=1:3, lty=1:3,lwd=2)