This function uses confIntProp() to compute the required sample size for estimating a proportion with a given accuracy.

pwr.confIntProp(prop, conf.level = 0.95, w = 0.1, silent = TRUE)

Arguments

prop

The proportion you expect to find, or a vector of proportions to enable easy sensitivity analyses.

conf.level

The confidence level of the desired confidence interval.

w

The desired 'halfwidth' of the confidence interval.

silent

Whether to provide a lot of information about progress ('FALSE') or not ('TRUE').

Value

A single numeric value (the sample size).

Examples

### Required sample size to estimate a prevalence of .03 in the
### population with a confidence interval of a maximum half-width of .01
pwr.confIntProp(.03, w=.01);
#> 0.03 
#> 1222 

### Vectorized over prop, so you can easily see how the required sample
### size varies as a function of the proportion
pwr.confIntProp(c(.03, .05, .10), w=.01);
#> 0.03 0.05  0.1 
#> 1222 1926 3556