Skip to contents

This method accounts for unique confidence intervals from each experiment by sampling from the confidence intervals during bootstrapping. Upper and lower confidence interval boundaries are determined using quantiles (corresponding to the specified level of alpha) of the bootstrapped estimates.

Usage

BinomCIMeanBootCustom(x, n, alpha = 0.05, B = 1000)

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.

B

integer. Number of bootstrap replicates to use. Default: 1000

Value

matrix containing columns "est", "lwr.ci", "upr.ci"

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 mean binomial probability and CI using bootstrapping
# NOTE: the estimated CI from BinomCI() are considered in this method
BinomCIMeanBootCustom(x, 10, B = 100)
#>            est  lwr.ci upr.ci
#> [1,] 0.5986667 0.43475 0.7606

# Compare to normal approximation
BinomCIMeanNorm(x, 10)
#>      est    lwr.ci    upr.ci
#> [1,] 0.6 0.4399696 0.7600304

# Compare to straight arithmetic average of experiments
colMeans(x)
#>       est    lwr.ci    upr.ci 
#> 0.6000000 0.4036427 0.7681436