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
)

Arguments

x

vector containing the number of "successes" for binomial variates.

n

vector containing the numbers of corresponding observations.

alpha

probability of a type I error, so confidence coefficient = 1-alpha.

method

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.

return.df

logical flag to indicate that a data frame rather than a matrix be returned.

References

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.

Author

Frank Harrell, modified by Michael Schramm

Examples

binom_ci(46,50,method="wilson")
#>  PointEst     Lower     Upper
#>      0.92 0.8116175 0.9684505