The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
This vignette serves an introduction to the R package ‘ExactCIone’, which is aimed at constructing the admissible exact confidence intervals (CI) for the binomial proportion, the poisson mean and the total number of subjects with a certain attribute or the total number of the subjects for the hypergeometric distribution. Both one-sided and two-sided CI are of interest. This package can be used to calculate the intervals constructed methods developed by Wang (2014) and Wang (2015).
Suppose \(X\sim bino(n,p)\), the sample space of \(X\) is \(\{0,1,...,n\}\). Wang (2014) proposed an admissible interval for \(p\) which is obtained by uniformly shrinking the initial \(1-\alpha\) Clopper-Pearson interval from the middle to both sides of the sample space iteratively. This interval is admissible so that any proper sub-interval of it cannot assure the confidence coefficient. So the interval cannot be shortened anymore.
# Compute the 95% confidence interval when x=2, n=5.
WbinoCI(x=2,n=5,conf.level=0.95)
#> $CI
#> x lower upper
#> [1,] 2 0.0764403 0.8107447
Use “details=TRUE” to show the CIs of the whole sample space.
WbinoCI(x=2,n=5,conf.level=0.95,details=TRUE)
#> $CI
#> x lower upper
#> [1,] 2 0.0764403 0.8107447
#>
#> $CIM
#> x lower upper
#> [1,] 0 0.00000000 0.5000000
#> [2,] 1 0.01020614 0.6574084
#> [3,] 2 0.07644030 0.8107447
#> [4,] 3 0.18925530 0.9235597
#> [5,] 4 0.34259163 0.9897939
#> [6,] 5 0.49999997 1.0000000
#>
#> $icp
#> [1] 0.95
The one-sided intervals are the one-sided \(1-\alpha\) Clopper-Pearson intervals (Clopper and Pearson, 1934). Also show all the CIs when “details=TRUE”.
WbinoCI_lower(x=2,n=5,conf.level=0.95)
#> $CI
#> sample lower upper
#> [1,] 2 0.07644039 1
WbinoCI_lower(x=2,n=5,conf.level=0.95,details=TRUE)
#> $CI
#> sample lower upper
#> [1,] 0 0.00000000 1
#> [2,] 1 0.01020622 1
#> [3,] 2 0.07644039 1
#> [4,] 3 0.18925538 1
#> [5,] 4 0.34259168 1
#> [6,] 5 0.54928027 1
WbinoCI_upper(x=2,n=5,conf.level=0.95)
#> $CI
#> sample lower upper
#> [1,] 2 0 0.8107446
WbinoCI_upper(x=2,n=5,conf.level=0.95,details=TRUE)
#> $CI
#> sample lower upper
#> [1,] 0 0 0.4507197
#> [2,] 1 0 0.6574083
#> [3,] 2 0 0.8107446
#> [4,] 3 0 0.9235596
#> [5,] 4 0 0.9897938
#> [6,] 5 0 1.0000000
Suppose \(X\sim poi(\lambda)\), the sample space of \(X\) is \(\{0,1,...\}\). Wang (2014) proposed an admissible interval for \(\lambda\) which is obtained by uniformly shrinking the initial \(1-\alpha\) Clopper-Pearson interval one by one from 0 to the sample point of interest. This interval is admissible so that any proper sub-interval of it cannot assure the confidence coefficient, which means the interval cannot be shortened anymore.
# The admissible CI for poisson mean when the observed sample is x=3.
WpoisCI(x=3,conf.level = 0.95)
#> $CI
#> x lower upper
#> [1,] 3 0.8176914 8.395386
#We show the intervals from 0 to the sample of interest when "details=TRUE".
WpoisCI(x=3,conf.level = 0.95,details = TRUE)
#> $CI
#> x lower upper
#> [1,] 3 0.8176914 8.395386
#>
#> $CIM
#> x lower upper
#> [1,] 0 0.00000000 3.453832
#> [2,] 1 0.05129329 5.491160
#> [3,] 2 0.35536150 6.921952
#> [4,] 3 0.81769144 8.395386
#>
#> $icp
#> [1] 0.95
The one-sided intervals are the one-sided \(1-\alpha\) Clopper-Pearson intervals which is givend by Garwood (1936). Also shows all the CIs when “details=TRUE”.
WpoisCI_lower(x=3,conf.level = 0.95)
#> $CI
#> sample
#> [1,] 3 0.8176914 Inf
WpoisCI_lower(x=3,conf.level = 0.95,details = TRUE)
#> $CI
#> x lower upper
#> [1,] 3 0.8176914 Inf
#>
#> $CIM
#> sample lower upper
#> [1,] 0 0.00000000 Inf
#> [2,] 1 0.05129329 Inf
#> [3,] 2 0.35536151 Inf
#> [4,] 3 0.81769145 Inf
WpoisCI_upper(x=3,conf.level = 0.95)
#> $CI
#> sample
#> [1,] 3 0 7.753657
WpoisCI_upper(x=3,conf.level = 0.95,details = TRUE)
#> $CI
#> x lower upper
#> [1,] 3 0 7.753657
#>
#> $CIM
#> sample lower upper
#> [1,] 0 0 2.995732
#> [2,] 1 0 4.743865
#> [3,] 2 0 6.295794
#> [4,] 3 0 7.753657
Suppose \(X\sim Hyper(M,N,n)\). The sample space is \(\{0,\ldots,\min(M,n)\}\). When \(M\) and \(n\) are known, Wang (2015) construct an admissible confidence interval for \(N\) by uniformly shrinking the initial \(1-\alpha\) Clopper-Pearson type interval from 0 to \(\min(M,n)\). Also this interval cannot be shortened more.
# For hyper(M,N,n), construct 95% CI for N on the observed sample x when n,M are known.
WhyperCI_N(x=5,n=10,M=800,conf.level = 0.95)
#> $CI
#> x lower upper
#> [1,] 5 1031 3591
# It shows CIs for all the sample point When "details=TRUE".
WhyperCI_N(x=5,n=10,M=800,conf.level = 0.95,details=TRUE)
#> $CI
#> x lower upper
#> [1,] 5 1031 3591
#>
#> $CIM
#> x lower upper
#> [1,] 0 3003 Inf
#> [2,] 1 1837 156370
#> [3,] 2 1459 21746
#> [4,] 3 1295 9160
#> [5,] 4 1151 5326
#> [6,] 5 1031 3591
#> [7,] 6 943 3002
#> [8,] 7 878 2096
#> [9,] 8 831 1779
#> [10,] 9 805 1411
#> [11,] 10 800 1150
#>
#> $icp
#> [1] 0.9500001
The one-sided \(1-\alpha\) CI for \(N\) is the one-sided Clopper-Pearson type interval (Konijn, 1973).
WhyperCI_N_lower(x=0,n=10,M=800,conf.level = 0.95)
#> $CI
#> x
#> [1,] 0 3095 Inf
WhyperCI_N_lower(x=0,n=10,M=800,conf.level = 0.95,details=TRUE)
#> $CI
#> sample lower upper
#> [1,] 0 3095 Inf
#>
#> $CIM
#> sample lower upper
#> [1,] 0 3095 Inf
#> [2,] 1 2033 Inf
#> [3,] 2 1581 Inf
#> [4,] 3 1321 Inf
#> [5,] 4 1151 Inf
#> [6,] 5 1031 Inf
#> [7,] 6 943 Inf
#> [8,] 7 878 Inf
#> [9,] 8 831 Inf
#> [10,] 9 805 Inf
#> [11,] 10 800 Inf
WhyperCI_N_upper(x=0,n=10,M=800,conf.level = 0.95)
#> $CI
#> x
#> [1,] 0 0 Inf
WhyperCI_N_upper(x=0,n=10,M=800,conf.level = 0.95,details=TRUE)
#> $CI
#> sample lower upper
#> [1,] 0 0 Inf
#>
#> $CIM
#> sample lower upper
#> [1,] 0 0 Inf
#> [2,] 1 0 156370
#> [3,] 2 0 21746
#> [4,] 3 0 9160
#> [5,] 4 0 5326
#> [6,] 5 0 3591
#> [7,] 6 0 2631
#> [8,] 7 0 2030
#> [9,] 8 0 1619
#> [10,] 9 0 1318
#> [11,] 10 0 1077
Suppose \(X\sim Hyper(M,N,n)\). When N and n are known, Wang (2015) construct an admissible confidence interval for N by uniformly shrinking the initial \(1-\alpha\) Clopper-Pearson type interval from the mid-point of the sample space to 0. This interval is admissible so that any proper sub-interval of it cannot assure the confidence coefficient. This means the interval cannot be shortened anymore.
# For Hyper(M,N,n), construct the CI for M on the observed sample x when n, N are known.
# Also output CI for p=M/N.
WhyperCI_M(x=0,n=10,N=2000,conf.level = 0.95)
#> $CI
#> x lower upper
#> [1,] 0 0 608
#>
#> $CI_p
#> p lower upper
#> [1,] 0 0 0.304
WhyperCI_M(x=0,n=10,N=2000,conf.level = 0.95,details = TRUE)
#> $CI
#> X lower upper
#> [1,] 0 0 608
#>
#> $CIM
#> x lower upper
#> [1,] 0 0 608
#> [2,] 1 11 873
#> [3,] 2 74 1102
#> [4,] 3 176 1236
#> [5,] 4 301 1391
#> [6,] 5 446 1554
#> [7,] 6 609 1699
#> [8,] 7 764 1824
#> [9,] 8 898 1926
#> [10,] 9 1127 1989
#> [11,] 10 1392 2000
#>
#> $CIM_p
#> p lower_p upper_p
#> [1,] 0.0 0.0000 0.3040
#> [2,] 0.1 0.0055 0.4365
#> [3,] 0.2 0.0370 0.5510
#> [4,] 0.3 0.0880 0.6180
#> [5,] 0.4 0.1505 0.6955
#> [6,] 0.5 0.2230 0.7770
#> [7,] 0.6 0.3045 0.8495
#> [8,] 0.7 0.3820 0.9120
#> [9,] 0.8 0.4490 0.9630
#> [10,] 0.9 0.5635 0.9945
#> [11,] 1.0 0.6960 1.0000
#>
#> $icp
#> [1] 0.9500005
The one-sided \(1-\alpha\) CI for \(M\) is the one-sided Clopper-Pearson type interval (Konijn, 1973).
WhyperCI_M_lower(X=0,n=10,N=2000,conf.level = 0.95)
#> $CI
#> X N
#> [1,] 0 0 2000
WhyperCI_M_lower(X=0,n=10,N=2000,conf.level = 0.95,details = TRUE)
#> $CI
#> X N
#> [1,] 0 0 2000
#>
#> $CIM
#> sample lower upper
#> [1,] 0 0 2000
#> [2,] 1 11 2000
#> [3,] 2 74 2000
#> [4,] 3 176 2000
#> [5,] 4 301 2000
#> [6,] 5 446 2000
#> [7,] 6 609 2000
#> [8,] 7 788 2000
#> [9,] 8 988 2000
#> [10,] 9 1213 2000
#> [11,] 10 1484 2000
WhyperCI_M_upper(X=0,n=10,N=2000,conf.level = 0.95)
#> $CI
#> X
#> [1,] 0 0 516
WhyperCI_M_upper(X=0,n=10,N=2000,conf.level = 0.95,details = TRUE)
#> $CI
#> X
#> [1,] 0 0 516
#>
#> $CIM
#> sample lower upper
#> [1,] 0 0 516
#> [2,] 1 0 787
#> [3,] 2 0 1012
#> [4,] 3 0 1212
#> [5,] 4 0 1391
#> [6,] 5 0 1554
#> [7,] 6 0 1699
#> [8,] 7 0 1824
#> [9,] 8 0 1926
#> [10,] 9 0 1989
#> [11,] 10 0 2000
Clopper, C. J. and Pearson, E. S. (1934). The use of confidence or fiducial limits in the case of the binomial. “Biometrika” 26: 404-413.
Garwood, F. (1936). Fiducial Limits for the Poisson Distribution. “Biometrika” 28: 437-442.
Konijn, H. S. (1973). Statistical Theory of Sample Survey Design and Analysis, Amsterdam: North-Holland.
Wang, W. (2014). An iterative construction of confidence intervals for a proportion. “Statistica Sinica” 24: 1389-1410.
Wang, W. (2015). Exact Optimal Confidence Intervals for Hypergeometric Parameters. “Journal of the American Statistical Association” 110 (512): 1491-1499.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.