In doing a Fisher's exact test, on wikipedia it states that the p-value is calculated as the sum of the probabilities of tables having probability less than or equal to the probability of the observed table. It then states that we use the Hypergeometric distribution to find the probabilities. HOWEVER, in R, the documentation states that a Non-central Hypergeometric distribution is used. Why is there a difference between the two? Thanks!
This is what the R help says.
For 2 by 2 tables, the null of conditional independence is equivalent to the hypothesis that the odds ratio equals one. ‘Exact’ inference can be based on observing that in general, given all marginal totals fixed, the first element of the contingency table has a non-central hypergeometric distribution with non-centrality parameter given by the odds ratio (Fisher, 1935).
So note the two facts in that quote:
the null of conditional* independence is equivalent to the hypothesis that the odds ratio equals one
the first element of the contingency table has a non-central hypergeometric distribution with non-centrality parameter given by the odds ratio
If you make the odds ratio 1, then that's the central hypergeometric. See, for example the Wikipedia article on Fisher's noncentral hypergeometric distribution which states it explicitly:
The two distributions* are both equal to the (central) hypergeometric distribution when the odds ratio is 1.
* [Fisher's and Wallenius' noncentral hypergeometrics are being discussed; they both give the ordinary hypergeometric when the odds ratio is 1]
So there's no contradiction - under the null, it's the central hypergeometric.
Why the R help didn't add just a few words to make that clear, I don't know.
* it's the margins being conditioned on there
The noncentral hypergeometric distribution is a generalization of the hypergeometric distribution. The latter is used for the Fisher exact test. However, it frequently seems to be referred to as the hypergeometric distribution as if the question of noncentrality did not exist. I suppose that the thinking for this is that the noncentrality is just the introducing of weighting for the hypergeometric distribution and people sometimes use shorthand and refer to weighted functions by the function name itself, e.g., when the weighting is neutral, is would be exactly that function.
@gammer helpfully suggests that the difference amounts to independent random variables for the hypergeometric case, and the weighted (noncentral) hypergeometric distribution for the not independent random variable case. BTW, (+1) good question.
Note however, that this is not the only numerical approach to problems of the Fisher exact test type, see Given the power of computers these days, is there ever a reason to do a chi-squared test rather than Fisher's exact test? for further information.
As @Glen_b says, under the null hypothesis of an odds ratio of one, Fisher's non-central hypergeometric distribution reduces to a hypergeometric distribution. However the
fisher.test function, as well as carrying out Fisher's Exact Test, (1) also calculates the conditional maximum-likelihood estimate of, & confidence intervals for, the odds ratio, & (2) does have an argument to set the odds ratio under the null to values other than 1; explaining the need to bring up non-centrality. It's worth noting, despite the manual's saying "given all marginal totals fixed", that it's Fisher's non-central hypergeometric distribution that's used in these calculations; which can arise from conditioning on marginal totals under several sampling schemes, but which is inapplicable when they are in fact fixed by design. See Fog (2015), "Biased Urn Theory".