The R functions Sterne2dtest(), Sterne2dCS(), SterneRDtest(), SterneRRtest(), SterneCI.RD(), and SterneCI.RR() are related to the paper
Reiczigel J, Abonyi-Tóth Zs, Singer J, An exact confidence set for two binomial proportions and exact unconditional confidence intervals for the difference and ratio of proportions, Computational Statistics and Data Analysis, 52, 5046–5053 (2008).
An exact joint confidence set is proposed for two binomial parameters estimated from independent samples. Its construction relies on inverting the minimum volume test, a two-dimensional analogue of Sterne’s test for a single probability. The algorithm involves computer-intensive exact computation based on binomial probabilities. The proposed confidence set has good coverage properties and it performs much better than the likelihood-based confidence set for the same problem. Applying the principle of intersection-union tests, the method can be used to derive exact tests and confidence intervals for functions of the two binomial parameters. Based on this, new exact unconditional two-sided confidence intervals are proposed for the risk difference and risk ratio. The performance of the new intervals is comparable to that of certain well-known confidence intervals in small samples. Extension of the methods described to two hypergeometric or two Poisson variables is straightforward.
Keywords: Exact confidence set; Binomial; Intersection-union test; Exact unconditional test; Exact confidence interval; Risk difference; Risk ratio; Relative risk
The functions are written in the simplest way without any optimization, thus calculation of confidence intervals for risk difference and risk ratio with sample sizes of several hundreds may take more than one hour.
Using these functions, calculation of a CI with samples of 300 takes about 5 minutes on a PC with a 2.4 GHz Intel i3 processor. Testing takes just a few seconds even with samples as big as that.
For those unfamiliar with R I’ve prepared standalone programs (.exe files) that carry out exact unconditional tests for risk difference and risk ratio, corresponding to the above R functions SterneRDtest() and SterneRRtest(). The programs are able to work with sample sizes up to 1000. I’ve tested them in XP. I’m planning to write similar programs for the confidence intervals.
The algorithm has been accelerated, and a bug related to rounding errors is fixed.
(Calculation of a CI for samples of 300 takes about 10 minutes with a 2.4 GHz Intel i3 processor. Tests take just a few seconds.)
Last updated 20.02.2015.