# 列联表

列联表是一种计数矩阵，其中每个单元格记录落入两个或更多变量各类别组合的观察数，使分析者能够检验这些变量是否相关，并量化这种关联的强度。将一个具有 R 个互斥类别的变量与另一个具有 C 个互斥类别的变量交叉分类所得的表格，称为 R×C 列联表。<sup>[1](https://itl.nist.gov/div898/software/dataplot/refman1/auxillar/chistest.htm)</sup>

| 关键事实 | 详情 |
|---|---|
| 基本结构 | N 个观察按一个变量的 R 个类别和另一个变量的 C 个类别交叉分类，得到一个 R×C 的单元格计数表<sup>[1](https://itl.nist.gov/div898/software/dataplot/refman1/auxillar/chistest.htm)</sup> |
| 独立性下的期望计数 | 单元格 (i, j) 的估计期望频数为其行合计与列合计之积除以总计，\( \hat{E}(n_{ij}) = (r_i \cdot c_j)/n \)<sup>[2](https://itl.nist.gov/div898/handbook/prc/section4/prc45.htm)</sup> |
| 卡方统计量 | \( \chi^{2} = \sum_{i=1}^{k} (O_{i}-E_{i})^{2}/E_{i} \)，其中 \( O_i \) 为单元格 i 的观察计数，\( E_i \) 为其期望计数<sup>[3](https://www.itl.nist.gov/div898/handbook/eda/section3/eda35f.htm)</sup> |
| 独立性假设 | 形式上，对所有 i、j，\( P(\text{第 } i \text{ 行}, \text{第 } j \text{ 列}) = P(\text{第 } i \text{ 行}) \cdot P(\text{第 } j \text{ 列}) \)<sup>[1](https://itl.nist.gov/div898/software/dataplot/refman1/auxillar/chistest.htm)</sup> |
| 2×2 表的度量 | 2×2 表是比值比（OR）与相对危险度（RR）的基本形式；OR 按交叉乘积比 ad/bc 计算<sup>[4](https://biostatistics.yuchunlab.com/en/chapter/05/contingency-table/)</sup><sup> • </sup><sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC5363133/)</sup> |
| 小样本 | 当许多期望频数较小时，使用费希尔精确检验代替卡方近似；弗里曼–霍尔顿扩展（1951）可处理更大的表格<sup>[6](https://files.eric.ed.gov/fulltext/ED036901.pdf)</sup> |
| 规模 | 对数线性方法已被应用于一个由 15,014 条综合社会调查观察构建的、具有 \( 2.6 \times 10^{39} \) 个单元格的 70 维列联表<sup>[7](https://arxiv.org/abs/2603.07288)</sup> |

## 结构与记号

数据集中的每个观察都按一个或多个分类变量进行分类，共享每一类别组合的观察计数填入表格的一个单元格。行合计与列合计称为边际频数，分别概括每个变量的分布，而内部单元格则显示两种分类如何组合。<sup>[4](https://biostatistics.yuchunlab.com/en/chapter/05/contingency-table/)</sup> 在流行病学应用中，惯例是将同时代表暴露与结局存在的值置于第一行和第一列，以便计算出的度量具有其公认的含义。<sup>[8](https://www.cdc.gov/epiinfo/user-guide/command-reference/analysis-commands-tables.html)</sup>

## 独立性卡方检验

最常见的分析是询问行分类与列分类是否独立。卡方检验将观察到的单元格计数与独立性成立时所预期的计数进行比较。在独立性下，一个单元格的期望计数为其行合计乘以列合计再除以总计。<sup>[2](https://itl.nist.gov/div898/handbook/prc/section4/prc45.htm)</sup> 检验统计量将所有单元格的观察值减期望值之差的平方求和，每项再除以其期望计数：<sup>[3](https://www.itl.nist.gov/div898/handbook/eda/section3/eda35f.htm)</sup>

\[ \chi^{2} = \sum_{i=1}^{k} \frac{(O_{i}-E_{i})^{2}}{E_{i}} \]

当期望频数足够大时，该统计量近似服从卡方分布，临界值从该分布在所选显著性水平下读取。<sup>[1](https://itl.nist.gov/div898/software/dataplot/refman1/auxillar/chistest.htm)</sup> 在美国国家标准与技术研究院（NIST）的一个计算示例中，将晶圆缺陷按类型和生产班次分类，在 0.95 水平、6 个自由度下的临界值为 12.5916。<sup>[2](https://itl.nist.gov/div898/handbook/prc/section4/prc45.htm)</sup>

## 比例的齐性

同一套方法可用于检验若干总体是否具有相同比例的特征。对于来自 n 个总体（如批次、供应商或生产运行）的样本，一个两行 n 列的列联表检验比例无差异的零假设，备择假设为 n 个总体比例并非全部相等，所用的是同样的基于观察与期望单元格频数的卡方统计量。<sup>[9](https://itl.nist.gov/div898/handbook/prc/section4/prc46.htm)</sup>

## 2×2 表中的关联度量

当两个变量都只有两个水平时，该表除显著性检验外还支持效应量度量。比值比比较病例组中的暴露比值与对照组中的暴露比值，相对危险度则直接比较概率；二者之间的选择取决于研究设计，病例对照研究通常仅限于比值比，因为无法从该设计直接估计风险和相对危险度。<sup>[4](https://biostatistics.yuchunlab.com/en/chapter/05/contingency-table/)</sup> 比值比可以简单地按四个单元格的交叉乘积比 ad/bc 计算。<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC5363133/)</sup> 两种度量的置信区间均在对数尺度上构建，检验统计量的形式为 \( Z = \log(OR)/SE[\log(OR)] \)。<sup>[4](https://biostatistics.yuchunlab.com/en/chapter/05/contingency-table/)</sup> P < 0.05 的卡方检验或费希尔精确检验只能确定两个比例之间的差异具有统计学显著性；比值比或相对危险度则量化该差异有多大。<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC5363133/)</sup>

## 小样本与精确检验

当期望计数较小时，卡方近似会退化。费希尔精确检验以行和列的边际合计为条件，并使用超几何分布，是单元格数值较小的 2×2 表的标准替代方法；皮尔逊卡方检验虽然在技术上适用，但在这种情况下通常不宜使用。<sup>[10](https://arxiv.org/abs/1404.2992)</sup><sup> • </sup><sup>[6](https://files.eric.ed.gov/fulltext/ED036901.pdf)</sup> 弗兰克·耶茨（Frank Yates）1934 年关于计数较小的列联表与 χ² 检验的论文是对这一问题的早期处理。<sup>[11](https://rss.onlinelibrary.wiley.com/doi/abs/10.2307/2983604)</sup> 对于期望频数较小、大于 2×2 的表格，适用精确检验的弗里曼–霍尔顿扩展（1951）。<sup>[6](https://files.eric.ed.gov/fulltext/ED036901.pdf)</sup>

## 历史与扩展

卡尔·皮尔逊（Karl Pearson）于 1900 年发表了卡方检验，到 1904 年它已被应用于列联表。对交叉分类计数的分析有更早的根源：斯蒂格勒（Stigler）提到凯特勒（Quetelet，1849）关于关联度量的工作、比耶奈梅（Bienaymé）对某表格的超几何分析，以及高尔顿（Galton）于 1892 年引入的期望值形式，后者后来被用作独立性卡方检验的基线。<sup>[12](https://afst.centre-mersenne.org/item/10.5802/afst.1039.pdf)</sup><sup> • </sup><sup>[13](https://www.sciencedirect.com/science/article/pii/S0378375807001073)</sup>

后来的工作推广了二维分析。对数线性模型将独立性检验扩展到多维表，计算技术的进步如今使得对超大表进行对数线性建模成为可能；最近的一种方法在综合社会调查数据上作了演示，该数据由 15,014 条观察构成一个具有 \( 2.6 \times 10^{39} \) 个单元格的 70 维列联表。<sup>[7](https://arxiv.org/abs/2603.07288)</sup> 稀疏表——其中许多单元格的计数为零——是一个公认的、需要专门拟合优度统计量的情形。<sup>[14](https://arxiv.org/abs/1006.2620)</sup>

## References

1. [Chi-Square Independence Test, NIST/SEMATECH e-Handbook, Dataplot reference manual](https://itl.nist.gov/div898/software/dataplot/refman1/auxillar/chistest.htm)
2. [7.4.5. How can we compare the results of classifying according to several categories?, NIST/SEMATECH e-Handbook](https://itl.nist.gov/div898/handbook/prc/section4/prc45.htm)
3. [1.3.5.15. Chi-Square Goodness-of-Fit Test, NIST/SEMATECH e-Handbook](https://www.itl.nist.gov/div898/handbook/eda/section3/eda35f.htm)
4. [Contingency Tables, Odds Ratios, and Relative Risks, Biostatistics Study Notes](https://biostatistics.yuchunlab.com/en/chapter/05/contingency-table/)
5. [Biostatistics Series Module 8: Assessing Risk, PMC](https://pmc.ncbi.nlm.nih.gov/articles/PMC5363133/)
6. [ED036901: computational procedures for categorical data analysis, ERIC](https://files.eric.ed.gov/fulltext/ED036901.pdf)
7. [Loglinear modelling of huge contingency tables, arXiv](https://arxiv.org/abs/2603.07288)
8. [Analysis Commands: TABLES, Epi Info User Guide, CDC](https://www.cdc.gov/epiinfo/user-guide/command-reference/analysis-commands-tables.html)
9. [7.4.6. Do all the processes have the same proportion of defectives?, NIST/SEMATECH e-Handbook](https://itl.nist.gov/div898/handbook/prc/section4/prc46.htm)
10. [Comparing Evolutionary Rates Using An Exact Test for 2x2 Tables with Continuous Cell Entries, arXiv](https://arxiv.org/abs/1404.2992)
11. [Contingency Tables Involving Small Numbers and the χ2 Test, F. Yates (1934), Supplement to the Journal of the Royal Statistical Society](https://rss.onlinelibrary.wiley.com/doi/abs/10.2307/2983604)
12. [The missing early history of contingency tables, Annals of the Faculty of Sciences of Toulouse](https://afst.centre-mersenne.org/item/10.5802/afst.1039.pdf)
13. [Three centuries of categorical data analysis: Log-linear models and maximum likelihood estimation, Computational Statistics & Data Analysis](https://www.sciencedirect.com/science/article/pii/S0378375807001073)
14. [Goodness of fit statistics for sparse contingency tables, arXiv](https://arxiv.org/abs/1006.2620)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Statistical inference, estimation, sampling, and testing › Hypothesis testing › Sequential tests and stopping-based inference

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/contingency-table

English original: https://www.edgepedia.org/contingency-table
