Calculate odds ratio and fisher's exact text

1. Aug 6, 2010

hoffmann

basic statistics question:

i have two variables, M1 and M2. i want to calculate how similar these two variables are using the odds ratio. M1 and M2 are lists of things, with some elements present in both lists. i also have a background list containing the things in M1 and M2, plus more. is this how i calculate the odds ratio? (in a 2x2 table from left to right and top to bottom):

1) a = # of common elements in M1 and background / # elements in background
2) b = 1 - a
3) c = # of common elements in M2 and background / # elements in background
4) d = 1 - c

odds ratio = a*d / b*c, where a is the upper left element of the 2x2 matrix and d is the bottom right.

does this look correct? how would i go about creating a 2x2 table for the fisher exact test? just use the number of common elements without doing the division by the background in the cells?

2. Aug 6, 2010

SW VandeCarr

That's the correct calculation the odds ratio (OR) for a 2x2 table. The 2x2 table (constrained by the marginal totals) has a hypergeometric distribution. The exact calculation is only necessary if the data are sparse (a zero in any cell for certain).

$$P=\frac{(a+b)!(c+d)!(a+d)!(b+d)!}{a!b!c!d!n!}$$

This is the probability of the data under the null hypothesis. There are calculators for this on line, but you'll have to find them yourself.

EDIT: For the variance of the odds ratio, use the delta method (Woolf) Var ln(OR)=(1/a+1/b+1/c+1/d).

http://www.ncbi.nlm.nih.gov/pmc/articles/PMC1270683/

Last edited: Aug 6, 2010
3. Aug 7, 2010

SW VandeCarr

Last edited: Aug 8, 2010