[R] [R-pkgs] exactci package gives exact binomial and poisson tests and matching CI

Fay, Michael (NIH/NIAID) [E] mfay at niaid.nih.gov
Thu Jan 28 01:59:09 CET 2010


I am announcing the release of the exactci package.  It calculates exact tests and confidence intervals for binomial and Poisson tests. Here is an example to motivate the package:

Suppose you want to see if the observed rates of 2/17877  for group A  are significantly different from the observed rates of 10/20000 for group B assuming Poisson counts. The poisson.test function in the stats package gives a significant test result but a confidence interval that contains the rate ratio of 1:

> poisson.test(c(2,10),c(17877,20000))

        Comparison of Poisson rates

data:  c(2, 10) time base: c(17877, 20000)
count1 = 2, expected count1 = 5.664, p-value = 0.04213
alternative hypothesis: true rate ratio is not equal to 1
95 percent confidence interval:
 0.02383738 1.04995468
sample estimates:
rate ratio
 0.2237512

In the exactci package, the test and confidence interval are calculated from the same p-value function so these kind of test-CI inconsistencies are avoided as much as is possible. Here are the results from the package (first using the central method to match the CI from poisson.test, then using the minlike method to match the p-value from poisson.test):

> poisson.exact(c(2,10),c(17877,20000))

        Exact two-sided Poisson test (central method)

data:  c(2, 10) time base: c(17877, 20000)
count1 = 2, expected count1 = 5.664, p-value = 0.06056
alternative hypothesis: true rate ratio is not equal to 1
95 percent confidence interval:
 0.02383738 1.04995468
sample estimates:
rate ratio
 0.2237512

> poisson.exact(c(2,10),c(17877,20000),tsmethod="minlike")

        Exact two-sided Poisson test (sum of minimum likelihood method)

data:  c(2, 10) time base: c(17877, 20000)
count1 = 2, expected count1 = 5.664, p-value = 0.04213
alternative hypothesis: true rate ratio is not equal to 1
95 percent confidence interval:
 0.03519552 0.94194758
sample estimates:
rate ratio
 0.2237512


The binom.exact function works similarly with the binomial  hypothesis tests.

Mike
******************************************************************
Michael P. Fay, PhD
Mathematical Statistician
National Institute of Allergy and Infectious Diseases
Tel: 301-451-5124               Fax:301-480-0912
(U.S. postal mail address)
6700B Rockledge Drive MSC 7609
Bethesda, MD 20892-7609
(Overnight mail address)
6700-A Rockledge Drive, Room 5133
Bethesda, MD 20817
http://www3.niaid.nih.gov/about/organization/dcr/BRB/staff/michael.htm


	[[alternative HTML version deleted]]

_______________________________________________
R-packages mailing list
R-packages at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages



More information about the R-help mailing list