Free Code for Clopper Pearson CI and requisite sample size
We provide two programs relevent to Clopper-Pearson confidence limits.
The first (BP1CI) calculates these intervals; the second (CONFINT)
calculates the sample size necessary to have a specified probability
that the length of the interval is not larger than a particular
amount.
The programs are written in standard Fortran95 and come with source
and Windows32 and Mac executables. The executables were compiled with
the free g95 compiler. The programs are free (open source, no charge)
and we encourage redistribution. They can be downloaded from:
http://biostatistics.mdanderson.org/SoftwareDownload
Here is a sample run of each of the two programs.
Barry W Brown
Professor, Biostatistics &
Applied Mathematics
U Texas MD Anderson Cancer
Center
bwb...@mdanderson.org
&&&&&&&&&&&&&&&&&&&& BEGIN EXAMPLE &&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&& BP1CI &&&&&&&&&&&&&&&&&&&&
bp1ci.exe
BP1CI
Version 2.0: May 2008
Confidence Intervals for One-Sample
Binomial and Poisson Trials
Barry W. Brown
Floyd M. Spears
Dan M. Serachitopol
Copyright 2008 for:
The University of Texas M.D. Anderson Cancer Center
Department of Biomathematics, Box 237
1515 Holcombe Boulevard
Houston, TX 77030 (USA)
Contact: BWB at above address or
b...@mdanderson.org
This program can be freely copied and (noncommercially)
distributed.
Press the Return or Enter key to continue ...
Enter '0' to exit this program
'1' to change the setup (confidence level, binomial or
Poisson
distribution, method of entry of binomial data)
Current settings:
Distribution - Binomial
Confidence level - 95.0%
Binomial entry method -
Number of Successes, Number of Failures
'2' to calculate a confidence interval
> 2
Enter number of successes then the number of failures. Separate
the two entries with a space.
> 10 15
======================================================================
Data
N Successes: 10.0 N Failures: 15.0 N Total:
25.0
95.0% Confidence Interval and Estimate of the Probability of
Success
Low Bound: 0.2113 Estimate: 0.4000 High Bound: 0.6133
======================================================================
Enter '0' to exit this program
'1' to change the setup (confidence level, binomial or
Poisson
distribution, method of entry of binomial data)
Current settings:
Distribution - Binomial
Confidence level - 95.0%
Binomial entry method -
Number of Successes, Number of Failures
'2' to calculate a confidence interval
> 0
STOP User chosen termination of program
&&&&&&&&&&&&&&&&&&&& END EXAMPLE &&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&& BP1CI &&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&& BEGIN EXAMPLE &&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&& CONFINT &&&&&&&&&&&&&&&&&&&&
confint.exe
CONFINT
Version 2.0: April 2008
Sample Sizes Required to Achieve a
Specified Small Confidence Interval
Barry W. Brown
Copyright 2008 for:
The University of Texas M. D. Anderson Cancer Center
Department of Biostatistics and Applied Mathematics
1515 Holcombe Boulevard
Houston, TX 77030 (USA)
Contact: BWB at above address of
b...@mdanderson.org
This program may be freely copied and (noncommercially)
redistributed.
Do you want a report file (y/n)? The report file will
contain all
answers to the calculations performed. You can print it
instead of
copying numbers from the screen.
Please enter one of [yn]: > n
ENTER 0 to exit this program
Calculations for a one-sample confidence interval
ENTER number of calculation desired:
(1) Normal (Gaussian) mean
(2) Normal (Gaussian) standard deviation
(3) binomial
(4) Poisson
(5) Exponential Survival -- Clinical Trial
(Confidence Interval on the Hazard)
(6) Exponential Survival -- Clinical Trial
(Confidence Interval on the Mean Survival Time)
> 3
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++
+ +
+ One-Sample Binomial Confidence
Interval +
+ +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++
Enter (0) to return to the main menu
(1) to compute the confidence interval properties of a
study
with fixed sample size.
(2) to compute the sample size required to achieve a
confidence
interval with a maximum fixed size.
> 2
ENTER:
(1) The (presumed true) probability of an event at which
this calculations is made
(2) The maximum desired length of the confidence interval
(3) The confidence LEVEL of the interval
(0.8, 0.95 are popular values)
(4) The probability that the extent of the confidence
interval does not exceed the maximum desired length.
> 0.8 0.1 0.95 0.8
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++
+ +
+ Input
Values +
+ +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++
The probability of an event is:
0.8000
The maximum length of the confidence interval is:
0.1000
The confidence level of the interval is
0.9500
The probability that the confidence interval is small is:
0.800000
!....................................................................!
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++
+ +
+ Calculating Sample Size of the
Study +
+ +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++
The sample size is:
278.0000
Let phat = (number of events)/(number of trials).
The confidence interval will have length at most 0.10000 if
phat is <= 0.21942 or else phat >= 0.78058
Hit the "Enter" or "Return" key to continue
PROBABILITY LENGTH LOW HIGH MEDIAN
OF CONFIDENCE INT PROBABILITY PROBABILITY LENGTH
<= 0.1000 OF EVENT OF EVENT OF CI
0.050 0.2642 0.7358 0.1062
0.100 0.2545 0.7455 0.1052
0.150 0.2480 0.7520 0.1043
0.200 0.2430 0.7570 0.1032
0.250 0.2386 0.7614 0.1027
0.300 0.2348 0.7652 0.1022
0.350 0.2312 0.7688 0.1017
0.400 0.2279 0.7721 0.1011
0.450 0.2247 0.7753 0.1005
0.500 0.2216 0.7784 0.1005
0.550 0.2184 0.7816 0.1000
0.600 0.2153 0.7847 0.0994
0.650 0.2121 0.7879 0.0988
0.700 0.2087 0.7913 0.0982
0.750 0.2051 0.7949 0.0976
0.800 0.2011 0.7989 0.0969
0.850 0.1965 0.8035 0.0963
0.900 0.1908 0.8092 0.0950
0.950 0.1825 0.8175 0.0936
NOTE: Due to the symmetry of the problem, the probability
that the
length of the confidence interval is less than the specified
value is
the same for any value of the true probability of an event
and one
minus this value.
Enter (0) to return to the main menu
(1) to compute the confidence interval properties of a
study
with fixed sample size.
(2) to compute the sample size required to achieve a
confidence
interval with a maximum fixed size.
> 0
ENTER 0 to exit this program
Calculations for a one-sample confidence interval
ENTER number of calculation desired:
(1) Normal (Gaussian) mean
(2) Normal (Gaussian) standard deviation
(3) binomial
(4) Poisson
(5) Exponential Survival -- Clinical Trial
(Confidence Interval on the Hazard)
(6) Exponential Survival -- Clinical Trial
(Confidence Interval on the Mean Survival Time)
> 0
User requested termination to program
STOP User requested termination to program
&&&&&&&&&&&&&&&&&&&& END EXAMPLE &&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&& CONFINT &&&&&&&&&&&&&&&&&&&&