An implementation of the binconf
function in Frank
Harrell's Hmisc package. Produces 1-alpha confidence intervals for binomial
probabilities.
binom_ci(
x,
n,
alpha = 0.05,
method = c("wilson", "exact", "asymptotic"),
return.df = FALSE
)
vector containing the number of "successes" for binomial variates.
vector containing the numbers of corresponding observations.
probability of a type I error, so confidence coefficient = 1-alpha.
character string specifying which method to use. The "exact" method uses the F distribution to compute exact (based on the binomial cdf) intervals; the "wilson" interval is score-test-based; and the "asymptotic" is the text-book, asymptotic normal interval. Following Agresti and Coull, the Wilson interval is to be preferred and so is the default.
logical flag to indicate that a data frame rather than a matrix be returned.
A. Agresti and B.A. Coull, Approximate is better than "exact" for interval estimation of binomial proportions, American Statistician, 52:119--126, 1998.
R.G. Newcombe, Logit confidence intervals and the inverse sinh transformation, American Statistician, 55:200--202, 2001.
L.D. Brown, T.T. Cai and A. DasGupta, Interval estimation for a binomial proportion (with discussion), Statistical Science, 16:101--133, 2001.
binom_ci(46,50,method="wilson")
#> PointEst Lower Upper
#> 0.92 0.8116175 0.9684505