I am a bit confused on which ratios are being compared in a 2x2 contingency table for a Fisher Exact test.

In this question, the ratios are compared between columns. However, in this question, the ratios are compared between rows.

Which is the correct ratio comparison for Fisher Exact? The reason I ask this is to figure out whether to use "less" or "greater" when doing a one-tailed FE test. If I'm doing a comparison between rows, then I might expect the opposite of comparison between columns.


1 Answer 1


The Fisher exact test is just as much a test of equality for the odds ratio for the row factor as for the column factor -- either way the odds ratios are the same. Indeed, rows and columns are entirely interchangeable.

Consider a 2x2 table with counts as follows:

                   Col. factor
                    Yes  No
      Row     Yes    a    b
     factor   No     c    d

Then the sample odds ratios will be equivalent to (a/c)/(b/d) for one and (a/b)/(c/d) for the other. Both simplify to ad/bc. (The same thing happens with the population odds; they simplify to the same quantity.)

Which way around a one tailed test is being done may depend on exactly what it says it's doing (that is, the help is usually explicit), however, it's quite straightforward to just check it -- for a 2x2 as a one-tailed test it's just a hypergeometric, so it will either be looking at this-many-or-more in a particular cell, or this-many-or-fewer -- if the program doesn't say clearly, it's not hard to figure out which it's doing by taking a specific example and seeing what p-value it gives.

Conditioning on the margins, if you're looking at $ad/bc$, lowering $a$ will necessarily increase $b$ and $c$ and lower $d$ (resulting in a smaller odds ratio of the form $ad/bc$), and raising $a$ will (correspondingly) necessarily increase $ad/bc$. A one tailed test on a 2x2 will either look at larger or smaller values for any given cell, so you can just pick a cell and see how it relates to the test.

So for example, here we double check it in R. First I make the most extreme table possible given a set of margins (row totals 8 and 8 and column totals 9 and 7), yielding the following extreme table (the top left cell cannot be made any smaller):

     [,1] [,2]
[1,]    1    7
[2,]    8    0

Now consider the alternative "greater". If it is looking at greater values of the top left cell, this table and all tables with values of $a$ larger than this one will comprise all such tables (and we'll have p-value of exactly $1$) or it will be looking at this table plus tables with smaller values of 'a' -- which can only include this table -- and so we'll have a p-value less than $1$. So let's try it:


        Fisher's Exact Test for Count Data

data:  tab.ex
p-value = 1
alternative hypothesis: true odds ratio is greater than 1
95 percent confidence interval:
   0 Inf
sample estimates:
odds ratio 

The p-value is $1$, so it's looking at the current table plus tables with larger values of the top left cell when you use greater (this is exactly the way I would expect it to behave, but if it had done differently we'd have spotted it here and it would be no harder to use)

If you use less instead it gives the p-value as $0.0006993$, which is the hypergeometric probability of the specific table we gave.

[1] 0.0006993007

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.