{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nConsider a $2 \\times 2$ [[contingency table|PANSMHE0SW]] of counts $a, b$ in the first row and $c, d$ in the second row, with total $n = a + b + c + d$.\nFix the row totals $r_1 = a + b$, $r_2 = c + d$ and the column totals $k_1 = a + c$, $k_2 = b + d$.\nAssume the null hypothesis that the row factor and the column factor are independent.\nThen, conditionally on these totals, $a$ has the [[hypergeometric distribution|0SPBPW3K61]]\n$$P(a) = \\binom{r_1}{a} \\binom{r_2}{k_1 - a} \\Big/ \\binom{n}{k_1}.$$\n*Fisher's exact test* computes the [[p-value|0EHYZFZ4PK]] as a sum of $P(a')$ over tables with the same totals.\nThe sum runs over the tables at least as extreme as the observed one.\nThe one-sided version sums over $a' \\ge a$; the usual two-sided version sums over all $a'$ with $P(a') \\le P(a)$.\n\n## Remarks\n\nExample: in the lady tasting tea experiment, $r_1 = r_2 = k_1 = k_2 = 4$, $n = 8$, and she classifies all cups correctly, so $a = 4$.\nThen $P(4) = \\binom{4}{4}\\binom{4}{0}/\\binom{8}{4} = 1/70$, and the one-sided p-value is $1/70 \\approx 0.014$.\nNon-example: replacing the hypergeometric law by its chi-squared approximation gives Pearson's [[chi-squared test|0EN0V3NY20]], whose p-value is only approximate.\nThe test is conservative: since the conditional law is discrete, the probability of a type I error is at most $\\alpha$ and often smaller.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "defines": "J6JP5CJNPX",
    "kind": "definition",
    "msc": [
      "62H17",
      "62F03"
    ],
    "name": "Fisher's exact test",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Fisher%27s_exact_test"
      }
    ],
    "tag": "YB9390ZE4W",
    "uses": [
      "PANSMHE0SW",
      "0SPBPW3K61",
      "0EHYZFZ4PK",
      "087P03NEND"
    ]
  },
  "kind": "definition",
  "link": "https://tamnd.github.io/math2/node/YB9390ZE4W/",
  "links": [
    {
      "field": "defines",
      "target": "J6JP5CJNPX"
    },
    {
      "field": "uses",
      "target": "PANSMHE0SW"
    },
    {
      "field": "uses",
      "target": "0SPBPW3K61"
    },
    {
      "field": "uses",
      "target": "0EHYZFZ4PK"
    },
    {
      "field": "uses",
      "target": "087P03NEND"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/YB9390ZE4W.md",
  "msc": [
    "62H17",
    "62F03"
  ],
  "name": "Fisher's exact test",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/YB9/YB9390ZE4W.md",
  "status": null,
  "tag": "YB9390ZE4W",
  "uri": "m2://YB9390ZE4W",
  "url": "https://tamnd.github.io/math2/wiki/fishers-exact-test-definition/",
  "writing": {
    "tag": "YB9390ZE4W",
    "kind": "definition",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      },
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
