| Type: | Package | 
| Title: | Exact Rate Ratio Test | 
| Version: | 1.1 | 
| Date: | 2022-05-09 | 
| Author: | Michael Fay <mfay@niaid.nih.gov> | 
| Maintainer: | Michael Fay <mfay@niaid.nih.gov> | 
| Depends: | R (≥ 2.4.1), stats | 
| Description: | Performs exact rate ratio tests. | 
| License: | GPL-3 | 
| NeedsCompilation: | no | 
| Packaged: | 2022-05-09 14:03:26 UTC; faym | 
| Repository: | CRAN | 
| Date/Publication: | 2022-05-09 14:50:02 UTC | 
An Exact Rate Ratio Test Assuming Poisson Counts
Description
Performs the uniformy most powerful unbiased test on the ratio of rates of two Poisson counts with given time (e.g., perons-years) at risk for each count.
Usage
rateratio.test(x, n, RR = 1, 
    alternative = c("two.sided", "less", "greater"), 
    conf.level = 0.95)
Arguments
| x | a vector of length 2 with counts for the two rates | 
| n | a vector of length 2 with time at risk in each rate | 
| RR | the null rate ratio (two.sided) or the rate ratio on boundary between null and alternative | 
| alternative | a character string specifying the alternative hypothesis, must be one of '"two.sided"' (default), '"greater"' or '"less"'. You can specify just the initial letter. | 
| conf.level | confidence level of the returned confidence interval. Must be a single number between 0 and 1. | 
Details
The rateratio.test tests whether the ratio of the first rate (estimated by x[1]/n[1]) 
over the second rate (estimated by x[2]/n[2]) is either equal to, less, or greater than 
RR.  Exact confidence intervals  
come directly from binom.test. The two-sided p-value is defined as either 1 or twice the minimum of 
the one-sided p-values. See Lehmann (1986, p. 152) or vignette("rateratio.test").
For full discussion of the p-value and confidence interval consistency of inferences, see Fay (2010) and exactci package.
Value
An object of class ‘htest’ containing the following components:
| p.value | the p-value of the test | 
| estimate | a vector with the rate ratio and the two individual rates | 
| null.value | the null rate ratio (two.sided) or the rate ratio on boundary between null and alternative | 
| conf.int | confidence interval | 
| alternative | type of alternative hypothesis | 
| method | description of method | 
| data.name | description of data | 
Note
Much of the error checking code was taken from prop.test.
Author(s)
Michael Fay
References
Fay, M. P. (2010). Two-sided exact tests and matching confidence intervals for discrete data. R Journal, 2(1), 53-58.
Lehmann, E.L. (1986). Testing Statistical Hypotheses (second edition). Wadsworth and Brooks/Cole, Pacific Grove, California.
See Also
 See poisson.exact in the exactci package, which gives the same test. 
Examples
### p values and confidence intervals are defined the same way
### so there is consistency in inferences
rateratio.test(c(2,9),c(17877,16660))
### Small counts and large time values will give results similar to Fisher's exact test 
### since in that case the rate ratio is  approximately equal to the odds ratio 
### However, for the Fisher's exact test, the two-sided p-value is defined differently from 
###  the way the confidence intervals are defined and may imply different inferences
### i.e., p-value may say reject OR=1, but confidence interval says not to reject OR=1
fisher.test(matrix(c(2,9,17877-2,16660-9),2,2))