Reputation: 2857
SciPy allows you to conduct both chi square tests and Fisher exact tests. While the output of the chi square test includes the expected array, the Fisher exact does not.
e.g.:
from scipy import stats
import numpy as np
obs = np.array(
[[1100,6848],
[11860,75292]])
stats.chi2_contingency(obs)
returns:
(0.31240019935827701,
0.57621104841277448,
1L,
array([[ 1083.13438486, 6864.86561514],
[ 11876.86561514, 75275.13438486]]))
while:
from scipy import stats
oddsratio, pvalue = stats.fisher_exact([[1100,6848],
[11860,75292]])
print pvalue, oddsratio
returns:
0.561533439157 1.01974850672
The documentation says nothing, and I couldn't find anything online either. Any chance it's possible? Thanks!
Upvotes: 1
Views: 3146
Reputation: 114781
Fisher's exact test (http://en.wikipedia.org/wiki/Fisher%27s_exact_test) doesn't involve computing an expected array. That's why fisher_exact()
doesn't return one.
If you need the expected array, it is the same as that returned by chi2_contingency
. If you want to compute it without calling chi2_contingency
, you can use scipy.stats.contingency.expected_freq
. For example:
In [40]: obs
Out[40]:
array([[ 1100, 6848],
[11860, 75292]])
In [41]: from scipy.stats.contingency import expected_freq
In [42]: expected_freq(obs)
Out[42]:
array([[ 1083.13438486, 6864.86561514],
[ 11876.86561514, 75275.13438486]])
Upvotes: 2