When the conditions for Pearson’s chi-square test are not met, especially when one of more of the cells have expi < 5, an alternative approach with 2 × 2 contingency tables is to use Fisher’s exact test. Since this method is computationally intense, it is best used for small samples.
Example 1: Repeat Example 2 from Independence Testing (to determine whether the cure rate is independent of the therapy used) with the data in Figure 1.
As you can see from Figure 1, the expectation for two of the cells is less than 5. Since we are dealing with a 2 × 2 contingency table with relatively small sample size, it is better to use Fisher’s exact test.
The approach is to determine how many different ways the above marginal frequencies can be achieved and then determine the probability that the above cell configuration can be achieved merely by chance.
We can restrict our attention to any one of the cells since once the frequency for one cell is determined the frequencies for the other cells can be determined from the marginal totals. We choose cell B6 since it has the smallest marginal total (namely 9 in cell D6). Now cell B6 can take any value between 0 and 9; once this value is set the values of the other three cells can be adjusted to maintain the marginal totals.
The probability that cell B6 takes on a specific value x is equivalent to the probability of getting x successes in a sample of size 9 (cell D6) taken without replacement from a population of size 21 (cell D8) which contains 11 (cell B8) successful choices. This can be calculated by the hypergeometric distribution. Here cells D6 and B8 are cells with the marginal totals corresponding to cell B6 and cell D8 contains the grand total.
Figure 2 contains a table of the probabilities for each possible value of x.
Figure 2 – Fisher exact test for Example 1
Thus, e.g., cell L11 contains the formula
Our test consists of determining whether the probability that at most 2 of those taking therapy 1 are cured (the observed count in cell B6) is less than .05. From Figure 2, we see that the probability of count 0 is 3.4E-05, the probability of count 1 is .001684 and the probability of count 2 is .022454 for a cumulative probability of .024172 < .05 = α, and so we reject the null hypothesis and conclude there is a significant difference between the cure rates for the two therapies.
There are one-tail and two-tail versions of the test. The probability for the one tail test (cell L17) is given by the formula
and the probability for the two tail test (cell L18) is given by the formula
Real Statistics Excel Function: The following function is provided in the Real Statistics Resource Pack:
FISHERTEST(R1, t) = the probability calculated by the Fisher exact test for the 2 × 2 contingency table contained in range R1 where t = the number of tails = 1 (one-tail) or 2 (two tail).
The range R1 must contain only numeric values.
For Example 1, FISHERTEST(B6:C7,1) = .024172.