Calculate odds ratio and fisher's exact text

  • Context: Undergrad 
  • Thread starter Thread starter hoffmann
  • Start date Start date
  • Tags Tags
    Ratio Text
Click For Summary
SUMMARY

This discussion focuses on calculating the odds ratio (OR) and Fisher's exact test using two variables, M1 and M2, which contain overlapping elements. The correct formula for the odds ratio is confirmed as OR = (a*d) / (b*c), where 'a' and 'd' are the upper left and bottom right elements of a 2x2 contingency table, respectively. Additionally, the probability under the null hypothesis for Fisher's exact test is expressed using a hypergeometric distribution formula. The variance of the odds ratio can be calculated using the delta method, specifically Woolf's formula, Var ln(OR) = (1/a + 1/b + 1/c + 1/d).

PREREQUISITES
  • Understanding of odds ratios in statistics
  • Familiarity with 2x2 contingency tables
  • Knowledge of Fisher's exact test
  • Basic statistical concepts such as hypergeometric distribution
NEXT STEPS
  • Research the hypergeometric distribution and its applications in statistics
  • Learn about the delta method for calculating variance in odds ratios
  • Explore online calculators for Fisher's exact test
  • Study the implications of sparse data in statistical tests
USEFUL FOR

Statisticians, data analysts, researchers conducting hypothesis testing, and anyone involved in calculating odds ratios and Fisher's exact tests in their work.

hoffmann
Messages
65
Reaction score
0
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?
 
Physics news on Phys.org
hoffmann said:
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?

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:
SW VandeCarr said:
P=\frac{(a+b)!(c+d)!(a+c)!(b+d)!}{a!b!c!d!n!}

I guess no one is paying attention. There was a mistake in the previous post. This is the corrected version of Fisher's exact test. Can anyone point out the mistake based on first principles and not just comparing the two? (In other words, what does the numerator represent?)
 
Last edited:

Similar threads

  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 14 ·
Replies
14
Views
2K
Replies
2
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 18 ·
Replies
18
Views
3K
Replies
1
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K