Fisher's exact test of 2x4 contingency tables permits calculation of precise probabilities in situation where, as a consequence of small cell frequencies, the much more rapid normal approximation and chi-square calculations are liable to be inaccurate. The Fisher's exact test involves the computations of several factorials to obtain the probability of the observed and each of the more extreme tables. Factorials growth quickly, so it's necessary use logarithms of factorials. This computations is very easy in Matlab because x!=gamma(x+1) and log(x!)=gammaln(x+1). This function is now fully vectorized to speed up the computation. Actually, the function also computes the mid-P correction to make the test less conservative.
Giuseppe thank you for your quick response.
Your routine takes all my data now.
Jon was right. I have fixed the bug and uploaded the new version
I get error messages for some data.
27 13 9 15
12 10 3 16
??? Attempted to access idxBstart(15); index out of bounds because
Error in ==> myfisher24 at 116
I hope this can be fixed?
inputparser; table implementation; github link
Changes in description
Actually, the function also computes the mid-P correction to make the test less conservative.
Bug fixed after Jon comment
little improvements in tables enumeration
Changes in help section
Speeding up using gammaln function and vectorization