I can't seem to find a way to achieve a test in R with all of these points:
- Fisher's exact
- One-sided (greater than, at 90% confidence level)
- With mid-p correction
What I have found are combinations of two of those characteristics, but not all three. Here are a few examples that have fallen short:
#Example data
dat<- rbind("exposed"=c(5,3),"unexposed"=c(20,30))
colnames(dat)<- c("case", "control")
#Fisher's exact, one-sided. No option for mid-p correction, & gives different ORs:
results.F <- fisher.test (dat, alternative="two.sided", conf.level=.9)
results.F$p.value
#Mid-p exact, two-sided. No option for one-sided:
library(epitools)
results.EpiM <- epitab (dat, method="oddsratio", conf.level=.8, oddsratio="midp")
results.EpiM$p.value[,1]
#Mid-p exact, two-sided. No option for one-sided. Same results as above:
library(epitools)
results.OrM <- oddsratio.midp (dat, conf.level=.8)
results.OrM$p.value[,1]
I know that OpenEpi online (not an R package) can calculate what I want. But, since I'm running this through many loops (same test on different geographic areas), I need to be able to output the p-value, odds ratio (OR), and lower confidence limit (LCL) for each loop in R.
Through experimentation, I've confirmed that the p value is impacted by both the sidedness and the mid-p/lack thereof specifications. I've also confirmed that the ORs and LCLs are not impacted by sidedness (UCLs are), but are impacted by mid-p/lack thereof. This makes sense and I can explain if that would be helpful. I therefore need all three characteristics to be in place in the same test to get the correct p value (for a while I thought there may be a way to get the OR & LCL from one test, but the p value from another, but it cannot be).
Does anyone know code that would implement this in R?
Thanks!
Best Answer
Without a reproducible example, it is difficult to be certain but I believe you are looking for
ormidp.test
from theepitools
package. As per the help page description it states that it is a 'Test for independence using the mid-p method'.Finding a quick example to verify at this link, I use the following table and code.
Which is consistent with the results shown at the above link.