How can Fisher’s Exact Test be performed in Stata?

Fisher’s Exact Test is a statistical method used to determine the significance of the relationship between two categorical variables. It is often used when the sample size is small or when the data violates the assumptions of other statistical tests. In Stata, Fisher’s Exact Test can be performed by using the “tabulate” command, followed by the “exact” option and specifying the two categorical variables of interest. This will generate a two-tailed p-value, which can be used to determine if there is a significant relationship between the two variables. Additionally, Stata allows for the use of different options such as “one-sided” or “two-sided” tests, as well as the ability to specify a specific alternative hypothesis. Overall, performing Fisher’s Exact Test in Stata is a simple and efficient way to analyze the relationship between categorical variables in small sample sizes or non-parametric data.

Perform Fisher’s Exact Test in Stata


 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 when one or more of the cell counts in a 2×2 table is less than 5. 

This tutorial explains how to perform Fisher’s Exact Test in Stata.

Example: Fisher’s Exact Test in Stata

Suppose we want to know whether or not gender is associated with political party preference at a particular college. To explore this, we randomly poll 25 students on campus. The number of students who are Democrats or Republicans, based on gender, is shown in the table below:

Democrat Republican
Male 4 9
Female 8 4

To determine if there is a statistically significant association between gender and political party preference, we can perform Fisher’s Exact Test.

In Stata, we can use the tabi command to perform Fisher’s Exact test. We enter the counts in the 2×2 table from left to right with a  to separate the top and bottom rows.

tabi 4 9 8 4

Fisher's Exact Test output in Stata

Here is how to interpret the output:

Output table: This table shows the counts for each cell, just as we entered them in.

Fisher’s exact: This is the p-value associated with a two-sided Fisher’s Exact Test. In this case, it is 0.115.

1-sided Fisher’s exact: This is the p-value associated with a one-sided Fisher’s Exact Test. In this case, it is 0.081. 

The null hypothesis for Fisher’s Exact Test is that the two variables are independent. In this case, our null hypothesis is that gender and political party preference are independent, which is a two-sided test so we would use the first p-value of 0.115.

Since this p-value is not less than 0.05, we do not reject the null hypothesis. Thus, we don’t have sufficient evidence to say that there is a significant association between gender and political party preference.

x