*27*

Fisher’s Exact Test is used to determine whether or not there is a significant association between two categorical variables.

It is typically used as an alternative to the Chi-Square Test of Independence when one or more of the cell counts in a 2×2 table is less than 5.

Fisher’s Exact Test uses the following null and alternative hypotheses:

**H**The two variables are independent._{0}: (null hypothesis)**H**The two variables are_{A}: (alternative hypothesis)*not*independent.

The following example shows how to conduct Fisher’s Exact Test in R.

**Example: Fisher’s Exact Test in R**

In order to conduct Fisher’s Exact Test in R, you simply need a 2×2 dataset.

For example, let’s generate a 2×2 dataset to use as an example:

#create 2x2 dataset data = matrix(c(2,5,9,4), nrow = 2) #view dataset data # 2 9 # 5 4

To conduct Fisher’s Exact Test, we simply use the following code:

fisher.test(data)

This produces the following output:

In Fisher’s Exact Test, the null hypothesis is that the two columns are independent (or equivalently, that the odds ratio is equal to 1).

To determine if the two columns are independent, we can look at the p-value of the test.

In this case the p-value is **0.1597**, which tells us we do not have sufficient evidence to reject the null hypothesis.

Thus, we cannot say that there is any statistically significant difference between the two columns.

Note that the odds ratio is 0.1957871. Since the p-value of the test is 0.1597, this tells us that the odds ratio is not significantly different than 1.

The output of the test also gives us a 95% confidence interval for the odds ratio, which is:

95% Confidence Interval for Odds Ratio: **(0.0130943, 1.8397543)**

Since the number 1 is within this ratio, it confirms that the odds ratio is not significantly different than 1 (assuming we use alpha level 0.05).

**Additional Resources**

The following tutorials provide additional information about Fisher’s Exact Test:

An Introduction to Fisher’s Exact Test

Fisher’s Exact Test Online Calculator

How to Report Fisher’s Exact Test Results