Type: | Package |
Title: | Various Confidence Interval Methods for Proportions |
Version: | 0.3-0 |
Date: | 2018-02-22 |
Author: | Ralph Scherer |
Maintainer: | Ralph Scherer <shearer.ra76@gmail.com> |
Description: | Computes two-sample confidence intervals for single, paired and independent proportions. |
License: | GPL-2 | GPL-3 [expanded from: GPL] |
URL: | https://github.com/shearer/PropCIs |
BugReports: | https://github.com/shearer/PropCIs/issues |
LazyLoad: | yes |
Packaged: | 2018-02-23 10:27:26 UTC; ralph |
NeedsCompilation: | no |
Repository: | CRAN |
Date/Publication: | 2018-02-23 16:49:49 UTC |
Confidence intervals for single, paired and independent proportions
Description
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.
Details
Package: | PropCIs |
Type: | Package |
Version: | 0.3-0 |
Date: | 2018-02-22 |
License: | GPL=2 |
LazyLoad: | yes |
Author(s)
Ralph Scherer
Maintainer: Ralph Scherer <shearer.ra76@gmail.com>
References
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.
internal function
Description
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
Description
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
Usage
add4ci(x, n, conf.level)
Arguments
x |
number of successes |
n |
number of trials |
conf.level |
confidence coefficient |
Value
A list with class '"htest"' containing the following components:
conf.int |
The confidence intervall for the proportion |
estimate |
The estimator for the proportion |
References
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.
Examples
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
Description
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.
Usage
addz2ci(x, n, conf.level)
Arguments
x |
number of successes |
n |
number of trials |
conf.level |
confidence coefficient |
Value
A list with class '"htest"' containing the following components:
conf.int |
The confidence intervall for the proportion |
estimate |
The estimator for the proportion |
References
Agresti, A., Coull, B. (1998): Approximate is better than exact for interval estimation of binomial proportions. The American Statistician 52, 119–126.
Examples
addz2ci(x = 15, n = 112, conf.level = 0.95)
Blaker's exact CI for a binomial proportion
Description
Blaker's exact CI for a binomial proportion
Usage
blakerci(x, n, conf.level, tolerance=1e-05)
Arguments
x |
Number of successes |
n |
Total sample size |
conf.level |
Confidence level |
tolerance |
default tolerance |
Value
A list with class '"htest"' containing the following components:
conf.int |
The confidence intervall for the proportion |
References
Blaker, H. (2000). Confidence curves and improved exact confidence intervals for discrete distributions, Canadian Journal of Statistics 28 (4), 783–798
Bayesian confidence interval for different of independent proportions
Description
Approximate Bayesian confidence interval for different of proportions using simulation method
Usage
diffci.bayes(x1,n1,x2,n2,a,b,c,d,conf.level, nsim)
Arguments
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 |
Value
Confidence interval with given confidence level.
References
Agresti, A. (2002) Categorical Data Analysis. Wiley, 2nd Edition.
Bayesian HPD confidence interval for different of independent proportions
Description
Approximate Bayesian HPD confidence interval for different of proportions using independent priors
Usage
diffci.bayes.hpd(x1,n1,x2,n2,a,b,c,d,conf.level)
Arguments
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 |
Value
Confidence interval with given confidence level.
References
Agresti, A. (2002) Categorical Data Analysis. Wiley, 2nd Edition.
Wald interval for a difference of proportions with matched pairs
Description
Wald interval for a difference of proportions with matched pairs.
Usage
diffpropci.Wald.mp(b, c, n, conf.level)
Arguments
b |
off-diag count |
c |
off-diag count |
n |
sample size |
conf.level |
confidence coefficient |
Details
The interval is truncated, when it overshoots the boundary
Value
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 |
References
D. G. Altman (1999) Practical statistics for medical research. London, Chapman & Hall
Examples
diffpropci.Wald.mp(b = 3, c = 9, n = 32, conf.level = 0.95)
Adjusted Wald interval for a difference of proportions with matched pairs
Description
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
Usage
diffpropci.mp(b, c, n, conf.level)
Arguments
b |
off-diag count |
c |
off-diag count |
n |
sample size |
conf.level |
confidence coefficient |
Details
The interval is truncated, when it overshoots the boundary
Value
A list with class '"htest"' containing the following components:
conf.int |
a confidence interval for the difference in proportions. |
estimate |
estimated difference in proportions |
References
Agresti, A. and Min, Y. (2005) Simple improved confidence intervals for comparing matched proportions. Statistics in Medicine 24 (5), 729–740.
Examples
diffpropci.mp(b = 40, c = 20, n = 160, conf.level = 0.95)
Score interval for difference of proportions
Description
Score interval for difference of proportions and independent samples (p1 - p2)
Usage
diffscoreci(x1, n1, x2, n2, conf.level)
Arguments
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 |
Value
A list with class '"htest"' containing the following components:
conf.int |
a confidence interval for the difference in proportions. |
References
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
Description
Clopper-Pearson exact CI
Usage
exactci(x, n, conf.level)
Arguments
x |
Number of successes |
n |
Total sample size |
conf.level |
Confidence level |
Value
A list with class '"htest"' containing the following components:
conf.int |
a confidence interval for the proportion |
References
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.
internal function
Description
internal function of orscoreci
mid-P confidence interval adaptation of the Clopper-Pearson interval
Description
mid-P confidence interval adaptation of the Clopper-Pearson interval
Usage
midPci(x, n, conf.level)
Arguments
x |
number of successes |
n |
number of trials |
conf.level |
confidence coefficient |
Value
A list with class '"htest"' containing the following components:
conf.int |
a confidence interval for the difference in proportions. |
References
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.
Examples
midPci(x = 15, n = 112, conf.level = 0.95)
Adapted binomial score confidence interval for the subject-specific odds ratio with matched pairs
Description
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.
Usage
oddsratioci.mp(b, c, conf.level)
Arguments
b |
off-diagonal count |
c |
off-diagonal count |
conf.level |
confidence coefficient |
Value
A list with class '"htest"' containing the following components:
conf.int |
a confidence interval for the difference in proportions. |
References
A. Agresti and Y. Min, (2005) Simple improved confidence intervals for comparing matched proportions. Statistics in Medicine 24 (5), 729–740.
Examples
oddsratioci.mp(b = 40, c = 20, conf.level = 0.95)
Bayesian tail confidence interval for an odds ratio
Description
Approximate Bayesian tail confidence interval for an odds ratio using simulation method
Usage
orci.bayes(x1,n1,x2,n2,a,b,c,d,conf.level, nsim)
Arguments
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 |
Value
Confidence interval for an odds ratio with given confidence level.
References
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))]
Description
score confidence interval for an odds ratio in a 2x2 table [p1(1-p1)/(p2(1-p2))]
Usage
orscoreci(x1, n1, x2, n2, conf.level)
Arguments
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 |
Value
A list with class '"htest"' containing the following components:
conf.int |
a confidence interval for the difference in proportions. |
References
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
Description
score confidence interval for the relative risk in a 2x2 table
Usage
riskscoreci(x1, n1, x2, n2, conf.level)
Arguments
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 |
Value
A list with class '"htest"' containing the following components:
conf.int |
a confidence interval for the difference in proportions. |
References
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.
Bayesian tail confidence interval for the relative risk
Description
Approximate Bayesian tail confidence interval for the relative risk using simulation method
Usage
rrci.bayes(x1,n1,x2,n2,a,b,c,d,conf.level, nsim)
Arguments
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 |
Value
Confidence interval for the relative risk with given confidence level.
References
Agresti, A. (2002) Categorical Data Analysis. Wiley, 2nd Edition.
Wilson's confidence interval for a single proportion
Description
Wilson's confidence interval for a single proportion. Score CI based on inverting the asymptotic normal test using the null standard error
Usage
scoreci(x, n, conf.level)
Arguments
x |
Number of successes |
n |
Total sample size |
conf.level |
Confidence level |
Value
A list with class '"htest"' containing the following components:
conf.int |
a confidence interval for the difference in proportions. |
References
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
Description
Tango's score confidence interval for a difference of proportions with matched pairs
Usage
scoreci.mp(b, c, n, conf.level)
Arguments
b |
off-diagonal count |
c |
off-diagonal count |
n |
sample size |
conf.level |
confidence coefficient |
Value
A list with class '"htest"' containing the following components:
conf.int |
a confidence interval for the difference in proportions. |
References
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
Examples
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.
Description
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.
Usage
wald2ci(x1, n1, x2, n2, conf.level, adjust)
Arguments
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 |
Details
If adjust=AC
is chosen, the standard Wald interval is modified
to the Agresti-Caffo adjusted CI (American Statistician, 2000)
Value
A list with class '"htest"' containing the following components:
conf.int |
a confidence interval for the difference in proportions. |
estimate |
estimated difference in proportions |
References
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.
internal function
Description
internal function of diffscoreci