I've noticed that the Fisher-exact test in SciPy returns a negative p-value if the p-value is extrememly small:
>>> import scipy as sp
>>> import scipy.stats
>>> x = [[48,60],[3088,17134]]
>>> sp.stats.fisher_exact(x)
(4.4388601036269426, -1.5673906617053035e-11)
In R, using the same 2x2 contingency table:
> a = matrix(c(48,60,3088,17134), nrow=2)
> fisher.test(a)
p-value = 6.409e-13
My question is 1) why does SciPy return a negative p-value? 2) how can I use SciPy to generate the correct p-value?
Thanks for the help.
Fisher's exact test uses the hypergeometric distribution.
The version of scipy you are using uses an implementation of the hypergeometric distribution that is not very precise. This is a known problem and has been fixed in the scipy repository.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With