Calculate confidence interval for the mean of binomial probabilities using pooled variance
Source:R/binomial-ci.R
BinomCIMeanPoolCustom.Rd
This method accounts for unique confidence intervals from each experiment by calculating the pooled variance adjusted for the confidence interval around each binomial probability. It does not use bootstrapping or rely on a large number of trials per experiment (though, the number of trials should not be very small; i.e n
should be at least 5, ideally larger) It does not necessarily rely on many repetitions of each experiment because the final mean binomial probability is calculated using the t-distribution and number of degrees of freedom corresponding to the effective sample size. The effective sample size is used to calculate a standard error from the pooled variance across experiments and construct the final confidence interval.
Arguments
- x
matrix or numeric. First column of the matrix, or the numeric vector, should represent the estimated binomial proportion for each experiment.
- n
integer. Number of trials per experiment. If
length(n)
does not match the number of estimated binomial proportions it is repeated.- alpha
numeric. Probability level for Z-value in normal distribution confidence interval calculation.
Examples
library(DescTools)
# example: 3 binomial experiments, 10 trials, confidence level 0.8
x <- DescTools::BinomCI(c(5,6,7), 10, 0.8)
# Inspect input
x
#> est lwr.ci upr.ci
#> x.1 0.5 0.3122044 0.6877956
#> x.2 0.6 0.4013518 0.7704344
#> x.3 0.7 0.4973717 0.8462008
# Calculate confidence interval for mean binomial probability
# NOTE: accounting for custom CI in pooled variance
BinomCIMeanPoolCustom(x, 10)
#> est lwr.ci upr.ci
#> [1,] 0.6 0.3811151 0.8188849
# Compare to t-distribution
BinomCIMeanPoolNorm(x, 10)
#> est lwr.ci upr.ci
#> [1,] 0.6 0.3788071 0.8211929
# Compare to arithmetic average
colMeans(x)
#> est lwr.ci upr.ci
#> 0.6000000 0.4036427 0.7681436