Learn R Programming

DescTools (version 0.99.56)

BinomCIn: Sample Size for a Given Width of a Binomial Confidence Interval

Description

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.

Usage

BinomCIn(p = 0.5, width, interval = c(1, 100000), 
         conf.level = 0.95, sides = "two.sided", method = "wilson")

Value

a numeric value

Arguments

p

probability for success, defaults to 0.5.

width

the width of the confidence interval

interval

a vector containing the end-points of the interval to be searched for the root. The defaults are set to c(1, 100000).

conf.level

confidence level, defaults to 0.95.

sides

a character string specifying the side of the confidence interval, must be one of "two.sided" (default), "left" or "right". You can specify just the initial letter. "left" would be analogue to a hypothesis of "greater" in a t.test.

method

character string specifing which method to use; this can be one out of: "wald", "wilson", "wilsoncc", "agresti-coull", "jeffreys", "modified wilson", "modified jeffreys", "clopper-pearson", "arcsine", "logit", "witting" or "pratt". Defaults to "wilson". Abbreviation of method are accepted. See details in BinomCI().

Author

Andri Signorell <andri@signorell.net>

Details

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.

See Also

BinomCI()

Examples

Run this code
BinomCIn(p=0.1, width=0.05, method="pratt")

Run the code above in your browser using DataLab