{
  "aliases": [
    "chi-square-test",
    "pearsons-chi-squared-test"
  ],
  "backlinks": null,
  "body": "\n## Summary\n\nA chi-squared test is a [[hypothesis test|087P03NEND]] whose test statistic has approximately a [[chi-squared distribution|0RFMMBHFTV]] under the null hypothesis. The main example is Pearson's chi-squared test for counts in categories.\nFor observed counts $O_1, \\dots, O_k$ and expected counts $E_1, \\dots, E_k$ under $H_0$, Pearson's statistic is\n$$\\chi^2 = \\sum_{i=1}^{k} \\frac{(O_i - E_i)^2}{E_i}.$$\nOne rejects $H_0$ when $\\chi^2$ is large.\n\n## Remarks\n\nIn the goodness-of-fit test, $H_0$ fixes the probabilities of the $k$ categories. For a large sample, $\\chi^2$ has approximately the law $\\chi^2_{k - 1}$ under $H_0$.\nIn the test of independence for an $r \\times c$ contingency table, $H_0$ states that the two categorical variables are [[independent|0XCE070V8B]]. Then $E_{ij}$ is (row total $\\times$ column total) / $n$, and the law is approximately $\\chi^2_{(r-1)(c-1)}$.\nThe approximation is poor when expected counts are small. A common rule asks for $E_i \\ge 5$ in each cell. For small tables, Fisher's exact test is an alternative.\nKarl Pearson introduced the test in 1900.\n\n## Explanations\n\n### L1 human\n\nThe chi-squared test compares the counts that you observe with the counts that a hypothesis predicts.\nIf the squared differences, scaled by the predictions, add up to a large number, the hypothesis does not fit the data.\n",
  "commit": "f591989ed15704e9d8755a7a5a6426d73de7a3ae",
  "front": {
    "aliases": [
      "chi-square-test",
      "pearsons-chi-squared-test"
    ],
    "kind": "concept",
    "msc": [
      "62H17",
      "62G10"
    ],
    "name": "Chi-squared test",
    "same_as": {
      "wikidata": "Q1071004",
      "wikipedia": "Chi-squared test"
    },
    "sources": [
      {
        "locator": "Pearson's chi-squared test",
        "url": "https://en.wikipedia.org/wiki/Chi-squared_test"
      },
      {
        "locator": "Example chi-squared test for categorical data",
        "url": "https://en.wikipedia.org/wiki/Chi-squared_test"
      }
    ],
    "tag": "0EN0V3NY20",
    "uses": [
      "087P03NEND",
      "0RFMMBHFTV",
      "0XCE070V8B"
    ]
  },
  "kind": "concept",
  "link": "https://math2.tamnd.com/node/0EN0V3NY20/",
  "links": [
    {
      "field": "uses",
      "target": "087P03NEND"
    },
    {
      "field": "uses",
      "target": "0RFMMBHFTV"
    },
    {
      "field": "uses",
      "target": "0XCE070V8B"
    }
  ],
  "markdown": "https://math2.tamnd.com/node/0EN0V3NY20.md",
  "msc": [
    "62H17",
    "62G10"
  ],
  "name": "Chi-squared test",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/0EN/0EN0V3NY20.md",
  "status": null,
  "tag": "0EN0V3NY20",
  "uri": "m2://0EN0V3NY20",
  "url": "https://math2.tamnd.com/wiki/chi-squared-test/",
  "writing": {
    "tag": "0EN0V3NY20",
    "kind": "concept",
    "level": "W1",
    "next": [
      {
        "what": "edge defines in",
        "note": "at least one definition",
        "have": 0,
        "want": 1
      },
      {
        "what": "edge instance_of in",
        "note": "at least two examples",
        "have": 0,
        "want": 2
      },
      {
        "what": "edge not_instance_of in",
        "note": "at least one non-example",
        "have": 0,
        "want": 1
      },
      {
        "what": "edge specializes both",
        "note": "the more general notions and the special cases",
        "have": 0,
        "want": 1
      }
    ]
  }
}
