# BinomCIn: Sample Size for a Given Width of a Binomial Confidence... In AndriSignorell/DescTools: Tools for Descriptive Statistics

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

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

## 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()`.

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

a numeric value

## Author(s)

Andri Signorell <andri@signorell.net>

## See Also

`BinomCI()`

## Examples

 `1` ```BinomCIn(p=0.1, width=0.05, method="pratt") ```

AndriSignorell/DescTools documentation built on April 8, 2021, 5:51 a.m.