statsmodels.stats.proportion.confint_proportions_2indep(count1, nobs1, count2, nobs2, method=None, compare='diff', alpha=0.05, correction=True)[source]

Confidence intervals for comparing two independent proportions.

This assumes that we have two independent binomial samples.

count1, nobs1float

Count and sample size for first sample.

count2, nobs2float

Count and sample size for the second sample.


Method for computing confidence interval. If method is None, then a default method is used. The default might change as more methods are added.

  • ‘wald’,

  • ‘agresti-caffo’

  • ‘newcomb’ (default)

  • ‘score’

  • ‘log’

  • ‘log-adjusted’ (default)

  • ‘score’

  • ‘logit’

  • ‘logit-adjusted’ (default)

  • ‘score’

comparestr in [‘diff’, ‘ratio’ ‘odds-ratio’]

If compare is diff, then the confidence interval is for diff = p1 - p2. If compare is ratio, then the confidence interval is for the risk ratio defined by ratio = p1 / p2. If compare is odds-ratio, then the confidence interval is for the odds-ratio defined by or = p1 / (1 - p1) / (p2 / (1 - p2).


Significance level for the confidence interval, default is 0.05. The nominal coverage probability is 1 - alpha.

low, upp


Status: experimental, API and defaults might still change.

more methods will be added.



Fagerland, Morten W., Stian Lydersen, and Petter Laake. 2015. “Recommended Confidence Intervals for Two Independent Binomial Proportions.” Statistical Methods in Medical Research 24 (2): 224–54.


Koopman, P. A. R. 1984. “Confidence Intervals for the Ratio of Two Binomial Proportions.” Biometrics 40 (2): 513–17.


Miettinen, Olli, and Markku Nurminen. “Comparative analysis of two rates.” Statistics in medicine 4, no. 2 (1985): 213-226.


Newcombe, Robert G. 1998. “Interval Estimation for the Difference between Independent Proportions: Comparison of Eleven Methods.” Statistics in Medicine 17 (8): 873–90.<873::AID- SIM779>3.0.CO;2-I.


Newcombe, Robert G., and Markku M. Nurminen. 2011. “In Defence of Score Intervals for Proportions and Their Differences.” Communications in Statistics - Theory and Methods 40 (7): 1271–82.

Last update: Dec 14, 2023