Title: | Various Confidence Interval Methods for Proportions |
---|---|
Description: | Computes two-sample confidence intervals for single, paired and independent proportions. |
Authors: | Ralph Scherer |
Maintainer: | Ralph Scherer <[email protected]> |
License: | GPL |
Version: | 0.3-0 |
Built: | 2024-11-05 05:27:19 UTC |
Source: | https://github.com/shearer/propcis |
Computes confidence intervals for single proportions as well as for differences in dependent and independent proportions, the odds-ratio and the relative risk in a 2x2 table. Intervals are available for independent samples and matched pairs. The functions are partly written by assistants of Alan Agresti, see website http://www.stat.ufl.edu/~aa/cda/cda.html.
Package: | PropCIs |
Type: | Package |
Version: | 0.3-0 |
Date: | 2018-02-22 |
License: | GPL=2 |
LazyLoad: | yes |
Ralph Scherer
Maintainer: Ralph Scherer <[email protected]>
Agresti, A., Coull, B. (1998) Approximate is better than exact for interval estimation of binomial proportions. The American Statistician 52, 119–126.
Agresti, A., Caffo, B.(2000) Simple and effective confidence intervals for proportions and difference of proportions result from adding two successes and two failures. The American Statistician 54 (4), 280–288.
Agresti, A. (2002) Categorical Data Analysis. Wiley, 2nd Edition.
Agresti, A. and Min, Y. (2005) Simple improved confidence intervals for comparing matched proportions Statistics in Medicine 24 (5), 729–740.
Agresti, A., Gottard, A. (2005) Randomized confidence intervals and the mid-P approach, discussion of article by C. Geyer and G. Meeden, Statistical Science 20, 367–371.
Altman, D. G. (1999) Practical statistics for medical research. London, Chapman & Hall.
Blaker, H. (2000). Confidence curves and improved exact confidence intervals for discrete distributions, Canadian Journal of Statistics 28 (4), 783–798.
Clopper, C. and Pearson, E.S. (1934) The use of cenfidence or fiducial limits illustrated in the case of the binomial. Biometrika 26, 404–413.
Koopman PAR. (1985) Confidence limits for the ratio of two binomial proportions. Biometrics 40, 513–517.
Mee, RW. (1984) Confidence bounds for the difference between two probabilities. Biometrics 40, 1175–1176.
Miettinen OS, Nurminen M. (1985) Comparative analysis of two rates. Statistics in Medicine 4, 213–226.
Nam, J. M. (1995) Confidence limits for the ratio of two binomial proportions based on likelihood scores: Non-iterative method. Biom. J. 37 (3), 375–379.
Nurminen, M. (1986) Analysis of trends in proportions with an ordinally scaled determinant. Biometrical J. 28, 965–974.
Olivier, J. and May, W. L. (2006) Weighted confidence interval construction for binomial parameters Statistical Methods in Medical Research 15 (1), 37–46.
Tango T. (1998) Equivalence test and confidence interval for the difference in proportions for the paired-sample design Statistics in Medicine 17, 891–908.
Wilson, E. B. (1927) Probable inference, the law of succession, and statistical inference. J. Amer. Stat. Assoc. 22, 209–212.
computes the Blaker acceptability of p when x is observed and X is bin(n, p)
Agresti-Coull add-4 CI for a binomial proportion, based on adding 2 successes and 2 failures before computing the Wald CI. The CI is truncated, when it overshoots the boundary
add4ci(x, n, conf.level)
add4ci(x, n, conf.level)
x |
number of successes |
n |
number of trials |
conf.level |
confidence coefficient |
A list with class '"htest"' containing the following components:
conf.int |
The confidence intervall for the proportion |
estimate |
The estimator for the proportion |
Agresti, A., Coull, B. (1998) Approximate is better than exact for interval estimation of binomial proportions. The American Statistician 52, 119–126.
Agresti, A., Caffo, B.(2000) Simple and effective confidence intervals for proportions and difference of proportions result from adding two successes and two failures. The American Statistician 54 (4), 280–288.
add4ci(x = 15, n = 112, conf.level = 0.95)
add4ci(x = 15, n = 112, conf.level = 0.95)
Agresti-Coull CI for a binomial proportion based on adding z^2/2 successes and z^2/2 failures before computing the Wald CI. The CI is truncated, when it overshoots the boundary.
addz2ci(x, n, conf.level)
addz2ci(x, n, conf.level)
x |
number of successes |
n |
number of trials |
conf.level |
confidence coefficient |
A list with class '"htest"' containing the following components:
conf.int |
The confidence intervall for the proportion |
estimate |
The estimator for the proportion |
Agresti, A., Coull, B. (1998): Approximate is better than exact for interval estimation of binomial proportions. The American Statistician 52, 119–126.
addz2ci(x = 15, n = 112, conf.level = 0.95)
addz2ci(x = 15, n = 112, conf.level = 0.95)
Blaker's exact CI for a binomial proportion
blakerci(x, n, conf.level, tolerance=1e-05)
blakerci(x, n, conf.level, tolerance=1e-05)
x |
Number of successes |
n |
Total sample size |
conf.level |
Confidence level |
tolerance |
default tolerance |
A list with class '"htest"' containing the following components:
conf.int |
The confidence intervall for the proportion |
Blaker, H. (2000). Confidence curves and improved exact confidence intervals for discrete distributions, Canadian Journal of Statistics 28 (4), 783–798
Approximate Bayesian confidence interval for different of proportions using simulation method
diffci.bayes(x1,n1,x2,n2,a,b,c,d,conf.level, nsim)
diffci.bayes(x1,n1,x2,n2,a,b,c,d,conf.level, nsim)
x1 |
Binomial variate group 1 |
n1 |
Sample size group 1 |
x2 |
Binomial variate group 2 |
n2 |
Sample size group 2 |
a |
beta prior for x1 |
b |
beta prior for x2 |
c |
beta prior for n1 |
d |
beta prior for n2 |
conf.level |
confidence level |
nsim |
number of simulations with default 10M |
Confidence interval with given confidence level.
Agresti, A. (2002) Categorical Data Analysis. Wiley, 2nd Edition.
Approximate Bayesian HPD confidence interval for different of proportions using independent priors
diffci.bayes.hpd(x1,n1,x2,n2,a,b,c,d,conf.level)
diffci.bayes.hpd(x1,n1,x2,n2,a,b,c,d,conf.level)
x1 |
Binomial variate group 1 |
n1 |
Sample size group 1 |
x2 |
Binomial variate group 2 |
n2 |
Sample size group 2 |
a |
beta prior for x1 |
b |
beta prior for x2 |
c |
beta prior for n1 |
d |
beta prior for n2 |
conf.level |
confidence level |
Confidence interval with given confidence level.
Agresti, A. (2002) Categorical Data Analysis. Wiley, 2nd Edition.
Adjusted Wald interval for a difference of proportions with matched pairs. This is the interval called Wald+2 in Agresti and Min (2005). Adds 0.5 to each cell before constructing the Wald CI
diffpropci.mp(b, c, n, conf.level)
diffpropci.mp(b, c, n, conf.level)
b |
off-diag count |
c |
off-diag count |
n |
sample size |
conf.level |
confidence coefficient |
The interval is truncated, when it overshoots the boundary
A list with class '"htest"' containing the following components:
conf.int |
a confidence interval for the difference in proportions. |
estimate |
estimated difference in proportions |
Agresti, A. and Min, Y. (2005) Simple improved confidence intervals for comparing matched proportions. Statistics in Medicine 24 (5), 729–740.
diffpropci.mp(b = 40, c = 20, n = 160, conf.level = 0.95)
diffpropci.mp(b = 40, c = 20, n = 160, conf.level = 0.95)
Wald interval for a difference of proportions with matched pairs.
diffpropci.Wald.mp(b, c, n, conf.level)
diffpropci.Wald.mp(b, c, n, conf.level)
b |
off-diag count |
c |
off-diag count |
n |
sample size |
conf.level |
confidence coefficient |
The interval is truncated, when it overshoots the boundary
A list with class '"htest"' containing the following components:
conf.int |
a confidence interval for the difference in proportions. |
estimate |
estimated difference in proportions c-b/n |
D. G. Altman (1999) Practical statistics for medical research. London, Chapman & Hall
diffpropci.Wald.mp(b = 3, c = 9, n = 32, conf.level = 0.95)
diffpropci.Wald.mp(b = 3, c = 9, n = 32, conf.level = 0.95)
Score interval for difference of proportions and independent samples (p1 - p2)
diffscoreci(x1, n1, x2, n2, conf.level)
diffscoreci(x1, n1, x2, n2, conf.level)
x1 |
success counts in sample 1 |
n1 |
sample size in sample 1 |
x2 |
success counts in sample 2 |
n2 |
sample size in sample 2 |
conf.level |
confidence coefficient |
A list with class '"htest"' containing the following components:
conf.int |
a confidence interval for the difference in proportions. |
Agresti, A. (2002) Categorical Data Analysis. Wiley, 2nd Edition.
Mee, RW. (1984) Confidence bounds for the difference between two probabilities. Biometrics 40, 1175–1176.
Miettinen OS, Nurminen M. (1985) Comparative analysis of two rates. Statistics in Medicine 4, 213–226.
Nurminen, M. (1986) Analysis of trends in proportions with an ordinally scaled determinant. Biometrical J. 28, 965–974
Clopper-Pearson exact CI
exactci(x, n, conf.level)
exactci(x, n, conf.level)
x |
Number of successes |
n |
Total sample size |
conf.level |
Confidence level |
A list with class '"htest"' containing the following components:
conf.int |
a confidence interval for the proportion |
Clopper, C. and Pearson, E.S. (1934) The use of confidence or fiducial limits illustrated in the case of the binomial. Biometrika 26, 404–413.
mid-P confidence interval adaptation of the Clopper-Pearson interval
midPci(x, n, conf.level)
midPci(x, n, conf.level)
x |
number of successes |
n |
number of trials |
conf.level |
confidence coefficient |
A list with class '"htest"' containing the following components:
conf.int |
a confidence interval for the difference in proportions. |
Agresti, A., Gottard, A. (2005) Randomized confidence intervals and the mid-P approach, discussion of article by C. Geyer and G. Meeden, Statistical Science 20, 367–371.
midPci(x = 15, n = 112, conf.level = 0.95)
midPci(x = 15, n = 112, conf.level = 0.95)
Adapted binomial score confidence interval for the subject-specific odds ratio with matched pairs. This uses the Wilson score CI for a binomial parameter with the off-diagonal counts.
oddsratioci.mp(b, c, conf.level)
oddsratioci.mp(b, c, conf.level)
b |
off-diagonal count |
c |
off-diagonal count |
conf.level |
confidence coefficient |
A list with class '"htest"' containing the following components:
conf.int |
a confidence interval for the difference in proportions. |
A. Agresti and Y. Min, (2005) Simple improved confidence intervals for comparing matched proportions. Statistics in Medicine 24 (5), 729–740.
oddsratioci.mp(b = 40, c = 20, conf.level = 0.95)
oddsratioci.mp(b = 40, c = 20, conf.level = 0.95)
Approximate Bayesian tail confidence interval for an odds ratio using simulation method
orci.bayes(x1,n1,x2,n2,a,b,c,d,conf.level, nsim)
orci.bayes(x1,n1,x2,n2,a,b,c,d,conf.level, nsim)
x1 |
Binomial variate group 1 |
n1 |
Sample size group 1 |
x2 |
Binomial variate group 2 |
n2 |
Sample size group 2 |
a |
beta prior for x1 |
b |
beta prior for x2 |
c |
beta prior for n1 |
d |
beta prior for n2 |
conf.level |
confidence level |
nsim |
number of simulations with default 10M |
Confidence interval for an odds ratio with given confidence level.
Agresti, A. (2002) Categorical Data Analysis. Wiley, 2nd Edition.
score confidence interval for an odds ratio in a 2x2 table [p1(1-p1)/(p2(1-p2))]
orscoreci(x1, n1, x2, n2, conf.level)
orscoreci(x1, n1, x2, n2, conf.level)
x1 |
number of successes in sample 1 |
n1 |
sample size in sample 1 |
x2 |
number of successes in sample 2 |
n2 |
sample size in sample 2 |
conf.level |
confidence coefficient |
A list with class '"htest"' containing the following components:
conf.int |
a confidence interval for the difference in proportions. |
Cornfield, J. (1956) A statistical problem arising from retrospective studies. In Neyman J. (ed.), Proceedings of the third Berkeley Symposium on Mathematical Statistics and Probability 4, pp. 135–148.
Miettinen O. S., Nurminen M. (1985) Comparative analysis of two rates. Statistics in Medicine 4, 213–226.
Agresti, A. 2002. Categorical Data Analysis. Wiley, 2nd Edition.
score confidence interval for the relative risk in a 2x2 table
riskscoreci(x1, n1, x2, n2, conf.level)
riskscoreci(x1, n1, x2, n2, conf.level)
x1 |
number of successes in sample 1 |
n1 |
sample size in sample 1 |
x2 |
number of successes in sample 2 |
n2 |
sample size in sample 2 |
conf.level |
confidence coefficient |
A list with class '"htest"' containing the following components:
conf.int |
a confidence interval for the difference in proportions. |
Nam, J. M. (1995) Confidence limits for the ratio of two binomial proportions based on likelihood scores: Non-iterative method. Biom. J. 37 (3), 375–379.
Koopman PAR. (1985) Confidence limits for the ratio of two binomial proportions. Biometrics 40, 513–517.
Miettinen OS, Nurminen M. (1985) Comparative analysis of two rates. Statistics in Medicine 4, 213–226.
Nurminen, M. (1986) Analysis of trends in proportions with an ordinally scaled determinant. Biometrical J 28, 965–974
Agresti, A. (2002) Categorical Data Analysis. Wiley, 2nd Edition.
Approximate Bayesian tail confidence interval for the relative risk using simulation method
rrci.bayes(x1,n1,x2,n2,a,b,c,d,conf.level, nsim)
rrci.bayes(x1,n1,x2,n2,a,b,c,d,conf.level, nsim)
x1 |
Binomial variate group 1 |
n1 |
Sample size group 1 |
x2 |
Binomial variate group 2 |
n2 |
Sample size group 2 |
a |
beta prior for x1 |
b |
beta prior for x2 |
c |
beta prior for n1 |
d |
beta prior for n2 |
conf.level |
confidence level |
nsim |
number of simulations with default 10M |
Confidence interval for the relative risk with given confidence level.
Agresti, A. (2002) Categorical Data Analysis. Wiley, 2nd Edition.
Wilson's confidence interval for a single proportion. Score CI based on inverting the asymptotic normal test using the null standard error
scoreci(x, n, conf.level)
scoreci(x, n, conf.level)
x |
Number of successes |
n |
Total sample size |
conf.level |
Confidence level |
A list with class '"htest"' containing the following components:
conf.int |
a confidence interval for the difference in proportions. |
Wilson, E.B. (1927) Probable inference, the law of succession, and statistical inference J. Amer. Stat. Assoc 22, 209–212
Tango's score confidence interval for a difference of proportions with matched pairs
scoreci.mp(b, c, n, conf.level)
scoreci.mp(b, c, n, conf.level)
b |
off-diagonal count |
c |
off-diagonal count |
n |
sample size |
conf.level |
confidence coefficient |
A list with class '"htest"' containing the following components:
conf.int |
a confidence interval for the difference in proportions. |
Agresti, A. and Min, Y. (2005) Simple improved confidence intervals for comparing matched proportions Statistics in Medicine 24 (5), 729–740.
Tango T. (1998) Equivalence test and confidence interval for the difference in proportions for the paired-sample design Statistics in Medicine 17, 891–908
scoreci.mp(b = 40, c = 20, n = 160, conf.level = 0.95)
scoreci.mp(b = 40, c = 20, n = 160, conf.level = 0.95)
Wald interval with the possibility to adjust according to Agresti, Caffo (2000) for difference in proportions and independent samples. The Agresti-Caffo interval adds 1 to x1 and x2 and adds 2 to n1 and n2.
wald2ci(x1, n1, x2, n2, conf.level, adjust)
wald2ci(x1, n1, x2, n2, conf.level, adjust)
x1 |
success counts in sample 1 |
n1 |
sample size in sample 1 |
x2 |
success counts in sample 2 |
n2 |
sample size in sample 2 |
conf.level |
confidence coefficient |
adjust |
option to adjust the Wald interval to the Agresti-Caffo interval for better performance |
If adjust=AC
is chosen, the standard Wald interval is modified
to the Agresti-Caffo adjusted CI (American Statistician, 2000)
A list with class '"htest"' containing the following components:
conf.int |
a confidence interval for the difference in proportions. |
estimate |
estimated difference in proportions |
Agresti, A. (2002) Categorical Data Analysis. Wiley, 2nd Edition. Agresti, A., Caffo, B.(2000) Simple and effective confidence intervals for proportions and difference of proportions result from adding two successes and two failures. The American Statistician 54 (4), 280–288.