Package: diff-binom-confint
Confidence Intervals for Difference of Binomial ProportionsComputation of confidence intervals for binomial proportions and for difference of binomial proportions.[GitHub Pages]  [Read the Docs]InstallationRunpython-mpipinstalldiff-binom-confintor install the latest version inGitHubusingpython-mpipinstallgit+https://github.com/DeepPSP/DBCI.gitor git clone this repository and install locally viacdDBCI
python-mpipinstall.Numbaaccelerated versionInstall usingpython-mpipinstalldiff-binom-confint[acc]Usage examplesfromdiff_binom_confintimportcompute_difference_confidence_intervaln_positive,n_total=84,101ref_positive,ref_total=89,105confint=compute_difference_confidence_interval(n_positive,n_total,ref_positive,ref_total,conf_level=0.95,method="wilson",)Implemented methodsConfidence intervals for binomial proportionsClick to view!Method (type)Implementedwilson:heavy_check_mark:wilson-cc:heavy_check_mark:wald:heavy_check_mark:wald-cc:heavy_check_mark:agresti-coull:heavy_check_mark:jeffreys:heavy_check_mark:clopper-pearson:heavy_check_mark:arcsine:heavy_check_mark:logit:heavy_check_mark:pratt:heavy_check_mark:witting:heavy_check_mark:mid-p:heavy_check_mark:lik:heavy_check_mark:blaker:heavy_check_mark:modified-wilson:heavy_check_mark:modified-jeffreys:heavy_check_mark:Confidence intervals for difference of binomial proportionsClick to view!Method (type)Implementedwilson:heavy_check_mark:wilson-cc:heavy_check_mark:wald:heavy_check_mark:wald-cc:heavy_check_mark:haldane:heavy_check_mark:jeffreys-perks:heavy_check_mark:mee:heavy_check_mark:miettinen-nurminen:heavy_check_mark:true-profile:heavy_check_mark:hauck-anderson:heavy_check_mark:agresti-caffo:heavy_check_mark:carlin-louis:heavy_check_mark:brown-li:heavy_check_mark:brown-li-jeffrey:heavy_check_mark:miettinen-nurminen-brown-li:heavy_check_mark:exact:x:mid-p:x:santner-snell:x:chan-zhang:x:agresti-min:x:wang:x:pradhan-banerjee:x:ReferencesSASPASSstatsmodels.stats.proportionscipy.stats._binomtestcorplingstatsDescTools.StatsAndCIsNewcombeeNOTEReference 1has errors in the description of the methodsWilson CC,Mee,Miettinen-Nurminen.
The correct computation ofWilson CCis given inReference 5.
The correct computation ofMee,Miettinen-Nurminenare given in thecode blocksinReference 1Test dataTest dataaretaken (with slight modification, e.g. theupper_boundofmiettinen-nurminen-brown-limethod in theedge case file) fromReference 1for automatic test of the correctness of the implementation of the algorithms.generated usingDescTools.StatsAndCIsvialibrary("DescTools")library("data.table")results=data.table()for(minc("wilson","wald","waldcc","agresti-coull","jeffreys","modified wilson","wilsoncc","modified jeffreys","clopper-pearson","arcsine","logit","witting","pratt","midp","lik","blaker")){ci=BinomCI(84,101,method=m)new_row=data.table("method"=m,"ratio"=ci[1],"lower_bound"=ci[2],"upper_bound"=ci[3])results=rbindlist(list(results,new_row))}fwrite(results,"./test/test-data/example-84-101.csv")# with manual slight adjustment of method namestaken fromReference 7(Table II).The filenames has the following pattern:# for computing confidence interval for difference of binomial proportions"example-(?P<n_positive>[\\d]+)-(?P<n_total>[\\d]+)-vs-(?P<ref_positive>[\\d]+)-(?P<ref_total>[\\d]+)\\.csv"# for computing confidence interval for binomial proportions"example-(?P<n_positive>[\\d]+)-(?P<n_total>[\\d]+)\\.csv"Note that the out-of-range values (e.g.> 1) are left as empty values in the.csvfiles.Known IssuesEdge cases incorrect for the methodtrue-profile.