Martin Maechler
2026-May-18 14:51 UTC
[Rd] Feature request: Fisher's 2x2, binomial (, others?) exact test efficiency improvements
>>>>> Stephanie Evert >>>>> on Sun, 17 May 2026 09:03:52 +0200 writes:>> I will revise my feature request to "have an >> easily-discoverable fast p-value-only calculation" for >> those who aren't using the odds ratio or confidence >> interval. > fisher.pval() in the "corpora" package. > Best, Steph Thank you Steph; However, I still agree with Chris that it would be nice to have an easy way to basically just get the p-value, in a case where neither the ESTIMATE nor the confidence interval is needed. Indeed, I've not unfrequently seen R code snippets <some>.test(.........)$p.value also in CRAN package R code and I think base R should provide a simple documented way to get only the pvalue in cases where the full test costs a factor of 1000 more, even if is still only microseconds in case of small data sets. My svn commit to the R sources, > 22 years ago (!) r29551 | maechler | 2004-05-24 21:34 | did introduce the optional argument 'conf.int = TRUE' for the 2x2 case _and_ the NEWS entry (of svn rev 29551) has been> o fisher.test(*, conf.int=FALSE) allows to skip the confidence interval computationHowever, Chris is (indirectly) correct -- he did not mention the 'conf.int' option -- but in this very large case, conf.int=FALSE does not help much, as indeed, the unconditionalized logdc <- dhyper(support, m, n, k, log = TRUE) is already expensive, and also the computation of the sample OR (odds ratio) ESTIMATE <- mle(x) is costly. Indeed, I will add a new argument to fisher.test() to allow skipping the expensive parts and get the p.value and *still* a valid result of class "htest". For now, this will only be fast when as by default the null hypothesis is `or = 1` Martin Maechler
Kurt Hornik
2026-May-19 13:25 UTC
[Rd] Feature request: Fisher's 2x2, binomial (, others?) exact test efficiency improvements
>>>>> Martin Maechler writes:>>>>> Stephanie Evert >>>>> on Sun, 17 May 2026 09:03:52 +0200 writes:>>> I will revise my feature request to "have an >>> easily-discoverable fast p-value-only calculation" for >>> those who aren't using the odds ratio or confidence >>> interval.>> fisher.pval() in the "corpora" package.>> Best, Steph> Thank you Steph;> However, I still agree with Chris that it would be nice to have > an easy way to basically just get the p-value, in a case where > neither the ESTIMATE nor the confidence interval is needed.> Indeed, I've not unfrequently seen R code snippets> <some>.test(.........)$p.value> also in CRAN package R code and I think base R should provide > a simple documented way to get only the pvalue in cases where > the full test costs a factor of 1000 more, even if is still > only microseconds in case of small data sets.> My svn commit to the R sources, > 22 years ago (!)> r29551 | maechler | 2004-05-24 21:34 |> did introduce the optional argument 'conf.int = TRUE' for the > 2x2 case _and_ the NEWS entry (of svn rev 29551) has been>> o fisher.test(*, conf.int=FALSE) allows to skip the confidence interval computation> However, Chris is (indirectly) correct -- he did not mention the > 'conf.int' option -- but in this very large case, conf.int=FALSE > does not help much, as indeed, the unconditionalized> logdc <- dhyper(support, m, n, k, log = TRUE)> is already expensive, and also the computation of the sample OR (odds ratio)> ESTIMATE <- mle(x)> is costly. Indeed, I will add a new argument to fisher.test() to allow skipping > the expensive parts and get the p.value and *still* a valid result > of class "htest". > For now, this will only be fast when as by default the null > hypothesis is `or = 1`Perhaps we could simply take `or = NULL` or `or = NA` to say "do not even estimate the OR"? -k> Martin Maechler> ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel