Fisher Algorithm

Performed on a set of non-negative numbers and labels of size N. There must be two specific labels. Label 1 must be 1 and label 2 must be 2. There can also be any other labels that will be ignored.

Consider all numbers greater than 0 as 1. Construct the following table:

Column1 Column2 Total
Row1 a b r1
Row2 c d r2
Total s1 s2 N

Where:
  • a is the number of 1 values in group 1.
  • b is the number of 1 values in group 2.
  • c is the number of 0 values in group 1.
  • d is the number of 0 values in group 2.
  • r1 = a + b
  • r2 = c + d
  • s1 = a + c
  • s2 = b + d
  • N = r1 + r2 = s1 + s2

Rearrage the table so a is the smallest value. There are two possible rearranging moves:
  • Swap Row1 and Row2.
  • Swap Column1 and Column2.

Fisher's Exact value

  1. Chi1: $\frac{(a - E)^2}{E}$
    • E: $\frac{r1 s1}{N}$
  2. Chi2: $\frac{(b - E)^2}{E}$
    • E: $\frac{r1 s2}{N}$
  3. Chi3: $\frac{(c - E)^2}{E}$
    • E: $\frac{r2 s1}{N}$
  4. Chi4: $\frac{(d - E)^2}{E}$
    • E: $\frac{r2 s2}{N}$
  5. Chi-Square: Chi1 + Chi2 + Chi3 + Chi4

Fisher's Exact probability

The probability for a table is calculated by $ \frac{r1!r2!s1!s2!}{N!a!b!c!d!}$.

The following table is called "Set 0":
Column1 Column2 Total
Row1 0 B r1
Row2 C D r2
Total s1 s2 N

  1. Determine the number of table probabilities to calculate by finding the smallest marginal total (least value among r1, r2, s1, s2) and adding 1.
  2. Generate the table for "Set 0"
    • A = 0
    • B = b + a
    • C = c + a
    • D = d - a
    • Totals remain unchanged.
  3. Calculate the probability of "Set 0"
    • $P_0$: $\frac{s2!r2!}{N!D!}$
    • This is because in "Set 0" A! = 1, $\frac{r1!}{B!}$ = 1, and $\frac{s1!}{C!}$ = 1.
  4. Calculate probabilities for other tables where A = {1, 2, ..., smallest marginal total}
    • $P_i$: $P_{i-1}\frac{(B - (i - 1))(C - (i - 1))}{(D + i)(i)}$
  5. P-value: $\sum{P_i}$ where $P_i$ <= $P_a$ + $\delta$
    • $\delta=1.0*10^{-15}$

Remarks

  • When the P-value gets very close to 1 and should in fact be 1, it is necessary to make a correction.
Topic revision: r5 - 09 Dec 2004, WillGray
 

This site is powered by FoswikiCopyright © 2013-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Vanderbilt Biostatistics Wiki? Send feedback