3.11.18.1.7. statsmodels.stats.proportion.proportion_confint

statsmodels.stats.proportion.proportion_confint(count, nobs, alpha=0.05, method='normal')[source]

confidence interval for a binomial proportion

Parameters:

count : int or array

number of successes

nobs : int

total number of trials

alpha : float in (0, 1)

significance level, default 0.05

method : string in [‘normal’]

method to use for confidence interval, currently available methods :

  • normal : asymptotic normal approximation
  • agresti_coull : Agresti-Coull interval
  • beta : Clopper-Pearson interval based on Beta distribution
  • wilson : Wilson Score interval
  • jeffrey : Jeffrey’s Bayesian Interval
  • binom_test : experimental, inversion of binom_test
Returns:

ci_low, ci_upp : float

lower and upper confidence level with coverage (approximately) 1-alpha. Note: Beta has coverage coverage is only 1-alpha on average for some other methods.)

Notes

Beta, the Clopper-Pearson interval has coverage at least 1-alpha, but is in general conservative. Most of the other methods have average coverage equal to 1-alpha, but will have smaller coverage in some cases.

Method “binom_test” directly inverts the binomial test in scipy.stats. which has discrete steps.

TODO: binom_test intervals raise an exception in small samples if one
interval bound is close to zero or one.

References

http://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval

Brown, Lawrence D.; Cai, T. Tony; DasGupta, Anirban (2001). “Interval
Estimation for a Binomial Proportion”, Statistical Science 16 (2): 101–133. doi:10.1214/ss/1009213286. TODO: Is this the correct one ?