BinomCIn {DescTools}  R Documentation 
Returns the necessary sample size to achieve a given width of a binomial confidence interval, as calculated by BinomCI()
. The function uses uniroot()
to find a numeric solution.
BinomCIn(p = 0.5, width, interval = c(1, 100000),
conf.level = 0.95, sides = "two.sided", method = "wilson")
p 
probability for success, defaults to 
width 
the width of the confidence interval 
interval 
a vector containing the endpoints of the interval to be searched for the root. The defaults are set to 
conf.level 
confidence level, defaults to 
sides 
a character string specifying the side of the confidence interval, must be one of 
method 
character string specifing which method to use; this can be one out of:

The required sample sizes for a specific width of confidence interval depends on the proportion in the population. This value might be unknown right from the start when a study is planned. In such cases the sample size needed for a given level of accuracy can be estimated using the worst case percentage which is p=50%. When a better estimate is available you can you can use it to get a smaller interval.
a numeric value
Andri Signorell <andri@signorell.net>
BinomCI()
BinomCIn(p=0.1, width=0.05, method="pratt")