
Confidence intervals for proportions, vectorized over all arguments
Source:R/confIntProp.R
confIntProp.Rd
This function simply computes confidence intervals for proportions.
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()
. It
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'.
Author
Unknown (see binom.test()
; adapted by Gjalt-Jorn Peters)
Maintainer: Gjalt-Jorn Peters rock@opens.science
Examples
### Simple case
rock::confIntProp(84, 200);
#> ci.lo ci.hi
#> 0.42, 95% 0.3507439 0.4916638
### Using vectors
rock::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