This function simply computes confidence intervals for proportions.

confIntProp(x, n, conf.level = 0.95, plot = FALSE)

## Arguments

x

The number of 'successes', i.e. the number of events, observations, or cases that one is interested in.

n

The total number of cases or observatons.

conf.level

The confidence level.

plot

Whether to plot the confidence interval in the binomial distribution.

## Value

The confidence interval bounds in a twodimensional matrix, with the first column containing the lower bound and the second column containing the upper bound.

## Details

This function is the adapted source code of binom.test(). Ir uses pbeta(), with some lines of code taken from the binom.test() source. Specifically, the count for the low category is specified as first 'shape argument' to pbeta(), and the total count (either the sum of the count for the low category and the count for the high category, or the total number of cases if compareHiToLo is FALSE) minus the count for the low category as the second 'shape argument'.

binom.test() and ggProportionPlot, the function for which this was written.

## Author

Unknown (see binom.test(); adapted by Gjalt-Jorn Peters)

Maintainer: Gjalt-Jorn Peters gjalt-jorn@userfriendlyscience.com

## Examples


### Simple case
confIntProp(84, 200);
#>               ci.lo     ci.hi
#> 0.42, 95% 0.3507439 0.4916638

### Using vectors
confIntProp(c(2,3), c(10, 20), conf.level=c(.90, .95, .99));
#>                 ci.lo     ci.hi
#> 0.2, 90%  0.036771438 0.5069013
#> 0.1, 90%  0.018065203 0.2826185
#> 0.3, 90%  0.087264434 0.6066242
#> 0.15, 90% 0.042169408 0.3436638
#> 0.2, 95%  0.025210726 0.5560955
#> 0.1, 95%  0.012348527 0.3169827
#> 0.3, 95%  0.066739511 0.6524529
#> 0.15, 95% 0.032070937 0.3789268
#> 0.2, 99%  0.010850509 0.6482012
#> 0.1, 99%  0.005295149 0.3871253
#> 0.3, 99%  0.037007221 0.7351140
#> 0.15, 99% 0.017642638 0.4494654