# ExactCIdiff: An R Package for Computing Exact Confidence Intervals for the Difference of Two Proportions

Comparing two proportions through the difference is a basic problem in statistics and has applications in many fields. More than twenty confidence intervals (Newcombe, 1998a,b) have been proposed. Most of them are approximate intervals with an asymptotic infimum coverage probability much less than the nominal level. In addition, large sample may be costly in practice. So exact optimal confidence intervals become critical for drawing valid statistical inference with accuracy and precision. Recently, Wang (2010, 2012) derived the exact smallest (optimal) one-sided 1 − α confidence intervals for the difference of two paired or independent proportions. His intervals, however, are computer-intensive by nature. In this article, we provide an R package ExactCIdiff to implement the intervals when the sample size is not large. This would be the first available package in R to calculate the exact confidence intervals for the difference of proportions. Exact two-sided 1 − α interval can be easily obtained by taking the intersection of the lower and upper one-sided 1 − α/2 intervals. Readers may jump to Examples 1 and 2 to obtain these intervals.

## CRAN packages used

ExactCIdiff, Epi, PropCIs, exactci

## CRAN Task Views implied by cited packages

Survival

### Reuse

Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".

### Citation

For attribution, please cite this work as

Shan & Wang, "The R Journal: ExactCIdiff: An R Package for Computing Exact Confidence Intervals for the Difference of Two Proportions", The R Journal, 2013

BibTeX citation

@article{RJ-2013-026,
author = {Shan, Guogen and Wang, Weizhen},
title = {The R Journal: ExactCIdiff: An R Package for Computing Exact Confidence Intervals for the Difference of Two Proportions},
journal = {The R Journal},
year = {2013},
note = {https://doi.org/10.32614/RJ-2013-026},
doi = {10.32614/RJ-2013-026},
volume = {5},
issue = {2},
issn = {2073-4859},
pages = {62-70}
}