Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Calculate odds ratio and fisher's exact text

  1. Aug 6, 2010 #1
    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. jcsd
  3. Aug 6, 2010 #2
    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).

    [tex] P=\frac{(a+b)!(c+d)!(a+d)!(b+d)!}{a!b!c!d!n!}[/tex]

    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).

    Last edited: Aug 6, 2010
  4. Aug 7, 2010 #3
    Last edited: Aug 8, 2010
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook