{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nLet $X$ and $Y$ be categorical [[variables|0PNRKMRC55]] with values in $\\set{1, \\ldots, r}$ and $\\set{1, \\ldots, c}$, observed on $n$ units.\nThe $r \\times c$ *contingency table* of the sample is the matrix $N = (n_{ij})$, where $n_{ij}$ is the number of units with $X = i$ and $Y = j$.\nThe row totals are $n_{i+} = \\sum_j n_{ij}$, the column totals are $n_{+j} = \\sum_i n_{ij}$, and $\\sum_{i,j} n_{ij} = n$.\nA contingency table of $m \\ge 3$ variables is defined in the same way as an $m$-way array of counts.\n\n## Remarks\n\nThe cells correspond to a [[partition|08QMKTWF9T]] of the sample: each unit is counted in exactly one cell.\nExample: among $100$ people, $10$ smoke and exercise, $20$ smoke and do not exercise, $40$ do not smoke and exercise, and $30$ do neither.\nThe table is $\\begin{pmatrix} 10 \u0026 20 \\\\ 40 \u0026 30 \\end{pmatrix}$, with row totals $30, 70$, column totals $50, 50$, and grand total $100$.\nNon-example: in a survey where people may tick several sports, a table of persons by sport counts some people more than once.\nThen the cells do not partition the sample, and the entries need not add up to $n$.\nTo test independence, the expected counts are $E_{ij} = n_{i+} n_{+j} / n$, and Pearson's statistic is $\\sum_{i,j} (n_{ij} - E_{ij})^2 / E_{ij}$.\nUnder independence and for large $n$, it is approximately chi-squared with $(r - 1)(c - 1)$ degrees of freedom.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "defines": "PANSMHE0SW",
    "kind": "definition",
    "msc": [
      "62H17"
    ],
    "name": "Contingency table",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Contingency_table"
      }
    ],
    "tag": "RZHB962EMF",
    "uses": [
      "08QMKTWF9T",
      "0PNRKMRC55"
    ]
  },
  "kind": "definition",
  "link": "https://tamnd.github.io/math2/node/RZHB962EMF/",
  "links": [
    {
      "field": "defines",
      "target": "PANSMHE0SW"
    },
    {
      "field": "uses",
      "target": "08QMKTWF9T"
    },
    {
      "field": "uses",
      "target": "0PNRKMRC55"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/RZHB962EMF.md",
  "msc": [
    "62H17"
  ],
  "name": "Contingency table",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/RZH/RZHB962EMF.md",
  "status": null,
  "tag": "RZHB962EMF",
  "uri": "m2://RZHB962EMF",
  "url": "https://tamnd.github.io/math2/wiki/contingency-table-definition/",
  "writing": {
    "tag": "RZHB962EMF",
    "kind": "definition",
    "level": "W0",
    "next": [
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
