MichaelChirico / r-bugs

A ⚠️read-only⚠️mirror of https://bugs.r-project.org/
20 stars 0 forks source link

[BUGZILLA #15331] Wishlist: Improved 2x3 Fisher's exact test algorithm #4919

Closed MichaelChirico closed 4 years ago

MichaelChirico commented 4 years ago

I'd like to suggest an alternative to the FEXACT function for the 2x3 Fisher's exact test.

See fisher23() in https://github.com/chrchang/stats , fisher.c . No workspace is required any more, and contingency tables with entries in the millions can be evaluated in seconds. This can be quickly patched in by importing fisher.c into src/library/stats/src/, adding in a thin wrapper in fisher.c which takes a 2x3/3x2 R matrix and converts it to fisher23()'s format, and adding a branch in src/library/stats/R/fisher.test.R as the first line under

if(nr != 2  ||  nc != 2) {

to calculate 2x3/3x2 p-values via the fisher23() wrapper instead of simulation or FEXACT.

My source code also contains a fisher22() function, but it does not provide fisher.test's 2x2 odds ratio functionality so it can be ignored for now.


METADATA

MichaelChirico commented 4 years ago

You were asked for a patch against the current R-devel sources (including documentation).

In any case, we cannot accept contributions under GPL (>= 3), as you were told.


METADATA