Learn R Programming

binomSamSize (version 0.1-3)

ciss.wilson: Sample sizes for improved binomial confidence intervals

Description

Calculate sample size for a binomial parameter enhancing the traditional Wald-type interval

Usage

ciss.wald(p0, d, alpha) ciss.wilson(p0, d, alpha) ciss.agresticoull(p0, d, alpha)

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

Value

the necessary sample size n

Details

Given a pre set $\alpha$-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.

References

Piegorsch, W. W. (2004), Sample sizes for improved binomial confidence intervals, Computational Statistics and Data Analysis, 46:309--316.

See Also

ciss.midp

Examples

Run this code

#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)

Run the code above in your browser using DataLab