# 对数线性模型

对数线性模型是一种用于列联表期望单元格计数的统计模型，其中每个期望计数的对数被写成分类变量各效应的线性组合，用于检验和描述这些变量之间的关联。<sup>[1](https://online.stat.psu.edu/stat504/Lesson10)</sup> 表中的所有变量被联合视为响应变量，不区分为响应变量和解释变量，因此该模型描述的是关联和交互模式，而非从其他变量预测某一变量。<sup>[1](https://online.stat.psu.edu/stat504/Lesson10)</sup> 在泊松抽样下，单元格计数被建模为独立的泊松变量；以总和为条件可得到等价的多项似然，以适当的边际为条件可得到乘积多项形式，因此在这些抽样方案下推断结果是相同的。<sup>[2](https://galton.uchicago.edu/~yibi/teaching/stat226/2017/lectures/C07.pdf)</sup>

| 关键事实 | 详情 |
|---|---|
| 建模对象 | 列联表的期望单元格计数，所有变量被联合视为响应变量<sup>[1](https://online.stat.psu.edu/stat504/Lesson10)</sup> |
| 独立性模型（二维） | \( \log(\mu_{ij}) = \lambda + \lambda_i^A + \lambda_j^B \)；最大似然拟合值为 \( n_{i+} \cdot n_{+j} / n \)<sup>[1](https://online.stat.psu.edu/stat504/Lesson10)</sup> |
| 饱和模型（二维） | 增加 \( \lambda_{ij}^{AB} \)；\( IJ \) 个非冗余参数，当所有单元格为正时 \( G^2 = 0 \) 且自由度为 0<sup>[1](https://online.stat.psu.edu/stat504/Lesson10)</sup><sup> • </sup><sup>[3](https://people.tamu.edu/~scottcrawford/stat659/chp7.pdf)</sup> |
| 拟合统计量 | 似然比 \( G^2 \) 和皮尔逊 \( X^2 \)，自由度 = 单元格数减去非冗余参数数<sup>[4](https://www.stat.unm.edu/~fletcher/SUPER/chap22.pdf)</sup> |
| 稀疏性经验法则 | 观测数除以单元格数应超过 5，卡方近似才可信<sup>[5](https://web.universiteitleiden.nl/fsw/methodenentechnieken/content_docs/mark/college-lla/class9.pdf)</sup> |
| 与其他模型的关系 | 是泊松误差和对数连接函数的广义线性模型的特例；仅在所述条件下等价于逻辑斯蒂模型<sup>[6](https://doi.org/10.2307/2347125)</sup><sup> • </sup><sup>[2](https://galton.uchicago.edu/~yibi/teaching/stat226/2017/lectures/C07.pdf)</sup> |
| 主要失效模式 | 抽样零可能导致最大似然估计不存在<sup>[7](https://projecteuclid.org/download/pdfview_1/euclid.aos/1342625459)</sup> |

## 工作原理

对数变换将分类变量之间的乘法结构转化为加法效应。对期望单元格频数取自然对数，将其表达为带有类似方差分析项的线性模型，因此在计数尺度上相乘的效应在对数尺度上相加。<sup>[8](https://conservancy.umn.edu/server/api/core/bitstreams/6ba5d59a-e8c5-4bdf-b37c-e86818f00a2b/content)</sup> 对于二维表，独立性模型为

\[ \log(\mu_{ij}) = \lambda + \lambda_i^A + \lambda_j^B, \]

其中 \( \lambda \) 项满足零和（方差分析型）约束；其最大似然拟合值等于 \( n_{i+} \cdot n_{+j} / n \)，因此独立性检验中熟悉的 \( X^2 \) 和 \( G^2 \) 即为该模型的拟合优度统计量。<sup>[1](https://online.stat.psu.edu/stat504/Lesson10)</sup> 饱和模型增加交互项 \( \lambda_{ij}^{AB} \)，得到 \( \log(\mu_{ij}) = \lambda + \lambda_i^A + \lambda_j^B + \lambda_{ij}^{AB} \)；它有 \( 1 + (I-1) + (J-1) + (I-1)(J-1) = IJ \) 个非冗余参数；当所有观测单元格为正时完全拟合，\( G^2 = 0 \) 且自由度为零；当观测计数为零时，在扩展最大似然估计下偏差为零，但有限最大似然估计可能不存在。<sup>[1](https://online.stat.psu.edu/stat504/Lesson10)</sup><sup> • </sup><sup>[3](https://people.tamu.edu/~scottcrawford/stat659/chp7.pdf)</sup>

对于三维表，饱和模型为 \( \log(\mu_{ijk}) = \lambda + \lambda_i^A + \lambda_j^B + \lambda_k^C + \lambda_{ij}^{AB} + \lambda_{ik}^{AC} + \lambda_{jk}^{BC} + \lambda_{ijk}^{ABC} \)，其中双因子交互项表示条件关联，三因子交互项度量对均匀关联的偏离。<sup>[1](https://online.stat.psu.edu/stat504/Lesson10)</sup> 均匀关联模型将三因子项设为零，\( \lambda_{ijk}^{XYZ} \equiv 0 \)，意味着 X–Y 优势比在 Z 的所有水平上相同。<sup>[9](http://web.stanford.edu/class/stats305b/notes/Loglinear.html)</sup><sup> • </sup><sup>[2](https://galton.uchicago.edu/~yibi/teaching/stat226/2017/lectures/C07.pdf)</sup> 该展开可直接推广到 n 维。<sup>[10](https://web.math.ku.dk/~lauritzen/papers/cont.pdf)</sup>

该模型是一个具有加法系统成分、泊松误差和对数连接函数的广义线性模型；Nelder 1974 年的论文以这种方式表述了它，推广了经典最小二乘法。<sup>[6](https://doi.org/10.2307/2347125)</sup>

## 操作方法

实践者将数据交叉分类为列联表，将分层模型指定为交互项（边际）的列表，并通过最大似然进行拟合。当不存在闭式解时，期望计数的最大似然估计通过迭代比例拟合（IPF）求得；其他模型类型通过牛顿-拉夫逊法或相关算法拟合。<sup>[11](https://jeroenvermunt.nl/esbs2005c.pdf)</sup> 在 R 中，`stats::loglin` 通过 IPF 拟合模型（有默认迭代上限和收敛容差），`MASS::loglm` 提供基于公式的前端；等价模型可用 `glm()` 配合 `family = poisson` 拟合。<sup>[12](https://stat.ethz.ch/R-manual/R-patched/RHOME/library/stats/html/loglin.html)</sup><sup> • </sup><sup>[13](https://stat.ethz.ch/CRAN/web/packages/vcdExtra/vignettes/a3-loglinear.html)</sup>

拟合优度用 \( G^2 = 2 \sum n_{ijk} \log(n_{ijk}/\hat{\mu}_{ijk}) \) 或 \( X^2 = \sum (n_{ijk} - \hat{\mu}_{ijk})^2 / \hat{\mu}_{ijk} \) 评估，自由度等于单元格数减去非冗余参数数；嵌套模型通过 \( G^2(R) - G^2(F) \) 进行比较。<sup>[4](https://www.stat.unm.edu/~fletcher/SUPER/chap22.pdf)</sup> 拟合系数的解释取决于软件施加的约束集，而从期望单元格频数计算的优势比则与程序无关。<sup>[14](https://journals.sagepub.com/doi/10.1177/004912417900700304)</sup>

## 起源

数学核心由 M. W. Birch 在 1963 年的论文《三维列联表中的最大似然》（Journal of the Royal Statistical Society, Series B）中提出，该文给出了 \( n \geq 3 \) 的 n 维表的最大似然结果，以及构成一般对数线性表示基础的单元格均值向量按 u 因子的对数展开。<sup>[15](https://doi.org/10.1111/j.2517-6161.1963.tb00504.x)</sup><sup> • </sup><sup>[16](https://www.stat.cmu.edu/tr/tr831/tr831.pdf)</sup> Leo A. Goodman 1964 年的论文《多维列联表中的交互作用》（The Annals of Mathematical Statistics）是该领域所依托的早期工作，<sup>[17](https://doi.org/10.1214/aoms/1177703561)</sup> 他 1970 年发表在 Journal of the American Statistical Association 上的论文提出了分层对数线性模型及用于 n 维表的似然比方法<sup>[16](https://www.stat.cmu.edu/tr/tr831/tr831.pdf)</sup><sup> • </sup><sup>[18](https://doi.org/10.1080/01621459.1970.10481076)</sup>；他 1971 年发表在 Technometrics 上的论文给出了逐步程序和直接估计方法。<sup>[17](https://doi.org/10.1214/aoms/1177703561)</sup><sup> • </sup><sup>[19](https://doi.org/10.1080/00401706.1971.10488753)</sup> Shelby J. Haberman 1973 年发表在 Annals of Statistics 上的论文提出了涵盖完全和不完全因子表及逻辑斯蒂模型的一般对数线性模型，包含充分统计量和似然方程；他 1972 年的 Algorithm AS 51 实现了列联表的对数线性拟合。<sup>[20](https://www.stat.cmu.edu/~brian/720-2007-source/week05/haberman-1973-ann-stat.pdf)</sup><sup> • </sup><sup>[21](https://doi.org/10.2307/2346506)</sup> Nelder 1974 年的论文将这些模型置于广义线性模型框架中，1975 年 Yvonne M. M. Bishop 等人合著的教科书《离散多元分析：理论与实践》整合了该领域。<sup>[6](https://doi.org/10.2307/2347125)</sup><sup> • </sup><sup>[8](https://conservancy.umn.edu/server/api/core/bitstreams/6ba5d59a-e8c5-4bdf-b37c-e86818f00a2b/content)</sup>

## 变体

分层模型要求：当某一交互项被固定为零时，所有包含其指标的高阶项也为零；例如，设 \( \lambda_{ab}^{AB} = 0 \) 迫使 \( \lambda_{abc}^{ABC} = 0 \)。其最小充分统计量是对应于最高阶交互项的边际，因此模型 {AB, BC} 从 AB 和 BC 边际进行估计。<sup>[11](https://jeroenvermunt.nl/esbs2005c.pdf)</sup>

关联模型对交互项进行结构化。线性乘线性模型 \( \log(\mu_{ij}) = \lambda + \lambda_i^X + \lambda_j^Y + \beta \cdot u_i \cdot v_j \) 使用一个自由度，在 \( \beta = 0 \) 时退化为独立性。<sup>[3](https://people.tamu.edu/~scottcrawford/stat659/chp7.pdf)</sup> Goodman 1979 年的论文引入了对数乘法 RC 关联模型 \( \log \mu_{ij} = \alpha_i + \beta_j + \gamma_i \cdot \delta_j \)，其中行和列得分从数据中估计。<sup>[22](https://doi.org/10.1080/01621459.1979.10481650)</sup><sup> • </sup><sup>[13](https://stat.ethz.ch/CRAN/web/packages/vcdExtra/vignettes/a3-loglinear.html)</sup> 准独立性模型在流动性表分析的背景下引入，对部分单元格拟合独立性而让其他单元格自由。<sup>[23](https://www.numdam.org/item/AFST_2002_6_11_4_525_0.pdf)</sup> 图对数线性模型将因子表示为图顶点，将双因子交互作用表示为边；可分解版本允许闭式最大似然估计。<sup>[24](https://digitalcommons.wayne.edu/cgi/viewcontent.cgi?article=2135&context=jmasm)</sup>

## 应用

对数线性模型广泛用于社会科学中的交叉分类分类数据。<sup>[24](https://digitalcommons.wayne.edu/cgi/viewcontent.cgi?article=2135&context=jmasm)</sup><sup> • </sup><sup>[14](https://journals.sagepub.com/doi/10.1177/004912417900700304)</sup> 准独立性模型最初在流动性表分析中引入。<sup>[23](https://www.numdam.org/item/AFST_2002_6_11_4_525_0.pdf)</sup> 在心理测量学和教育测试中，对数线性模型已被应用于标准参照测试和项目分析，对数几率线性模型与潜特质程序相联系，用于估计项目难度和区分度参数。<sup>[8](https://conservancy.umn.edu/server/api/core/bitstreams/6ba5d59a-e8c5-4bdf-b37c-e86818f00a2b/content)</sup> Christensen 的《对数线性模型与逻辑斯蒂回归》第三版（Springer，2025）增加了关于固定零和随机零、小样本精确条件检验以及对应分析的章节，并提出了二项回归的贝叶斯方法，使得无需大样本即可得出准确结论。<sup>[25](https://link.springer.com/book/10.1007/978-3-031-69038-9)</sup>

## 局限与替代方法

空单元格有两种：抽样零，即数据的一部分且期望值为正；结构零，即观测不可能发生的单元格；含结构零的表称为不完全表，需要特别处理。<sup>[5](https://web.universiteitleiden.nl/fsw/methodenentechnieken/content_docs/mark/college-lla/class9.pdf)</sup> 如果充分统计量中出现零，则最大似然估计不存在。<sup>[5](https://web.universiteitleiden.nl/fsw/methodenentechnieken/content_docs/mark/college-lla/class9.pdf)</sup> Haberman（1973）给出了一个充要条件：最大似然估计存在当且仅当线性流形中存在向量 b 使得对每个单元格 \( n_i + b_i > 0 \)，且最大似然估计在存在时唯一。<sup>[20](https://www.stat.cmu.edu/~brian/720-2007-source/week05/haberman-1973-ann-stat.pdf)</sup> 当最大似然估计不存在时，可通过扩展最大似然估计进行推断，自由度在可估计单元格的面集上计算，调整后的渐近 \( \chi^2 \) 检验仍可应用。<sup>[7](https://projecteuclid.org/download/pdfview_1/euclid.aos/1342625459)</sup> 标准软件（包括 R 的 `loglin` 和 `glm`）在充分统计量落在凸支撑边界上时可能失败或给出错误推断；`eMLEloglin` 包通过线性规划确定包含稀疏表数据的凸支撑面，并将其传递给 `glm()`，从而计算扩展最大似然估计和正确的残差自由度。<sup>[7](https://projecteuclid.org/download/pdfview_1/euclid.aos/1342625459)</sup><sup> • </sup><sup>[26](https://rdrr.io/cran/eMLEloglin/f/inst/doc/User_manual.pdf)</sup>

卡方近似需要足够的期望计数。常见的经验法则是观测数除以单元格数应超过 5；否则不应信任卡方分布。<sup>[5](https://web.universiteitleiden.nl/fsw/methodenentechnieken/content_docs/mark/college-lla/class9.pdf)</sup> 稀疏表还会导致优势比的严重偏差，向空单元格添加小常数（如 0.5）是常见做法，但模拟表明它可能扭曲 \( X^2 \) 统计量的分布，起到向独立性保守平滑的作用。<sup>[27](https://alanagresti.com/articles/agresti_yang_1987.pdf)</sup> 在稀疏表中，渐近概率值可能远大于精确值，已有人提出用于组合独立多项分布的精确无方向置换方法。<sup>[28](https://journals.sagepub.com/doi/10.2466/pr0.94.1.19-32)</sup>

## References

1. [Lesson 10: Log-Linear Models, STAT 504, Penn State](https://online.stat.psu.edu/stat504/Lesson10)
2. [STAT226 Chapter 7: Loglinear Models for Contingency Tables (UChicago)](https://galton.uchicago.edu/~yibi/teaching/stat226/2017/lectures/C07.pdf)
3. [Two-Way Contingency Tables (Stat 659 chapter, Texas A&M, Agresti-based)](https://people.tamu.edu/~scottcrawford/stat659/chp7.pdf)
4. [Chapter 22: Log-Linear Models: Describing Count Data (Christensen, Plane Answers to Complex Questions)](https://www.stat.unm.edu/~fletcher/SUPER/chap22.pdf)
5. [Building and applying Loglinear models, class 9 (M. de Rooij, Leiden University)](https://web.universiteitleiden.nl/fsw/methodenentechnieken/content_docs/mark/college-lla/class9.pdf)
6. [J. A. Nelder (1974). Log Linear Models for Contingency Tables: A Generalization of Classical Least Squares. Journal of the Royal Statistical Society Series C (Applied Statistics).](https://doi.org/10.2307/2347125)
7. [Maximum Likelihood Estimation in Log-Linear Models (Fienberg & Rinaldo, Annals of Statistics, 2012)](https://projecteuclid.org/download/pdfview_1/euclid.aos/1342625459)
8. [Educational and Psychometric Applications of Log-Linear Models (University of Minnesota repository)](https://conservancy.umn.edu/server/api/core/bitstreams/6ba5d59a-e8c5-4bdf-b37c-e86818f00a2b/content)
9. [Loglinear models (Chs. 9 & 10), STATS 305B, Stanford](http://web.stanford.edu/class/stats305b/notes/Loglinear.html)
10. [Lectures on Contingency Tables (Lauritzen)](https://web.math.ku.dk/~lauritzen/papers/cont.pdf)
11. [Log-linear analysis (Vermunt, Encyclopedia of Social and Behavioral Sciences, 2005)](https://jeroenvermunt.nl/esbs2005c.pdf)
12. [R stats::loglin documentation (R 4.5.0)](https://stat.ethz.ch/R-manual/R-patched/RHOME/library/stats/html/loglin.html)
13. [Log-linear Models (vcdExtra package vignette, CRAN)](https://stat.ethz.ch/CRAN/web/packages/vcdExtra/vignettes/a3-loglinear.html)
14. [Log-Linear Models for Contingency Table Analysis: On the Interpretation of Parameters (Sociological Methods & Research, 1979)](https://journals.sagepub.com/doi/10.1177/004912417900700304)
15. [M. W. Birch (1963). Maximum Likelihood in Three-Way Contingency Tables. Journal of the Royal Statistical Society Series B (Statistical Methodology).](https://doi.org/10.1111/j.2517-6161.1963.tb00504.x)
16. [Three Centuries of Categorical Data Analysis: Log-linear Models and Maximum Likelihood Estimation (Fienberg & Rinaldo, CMU TR 831)](https://www.stat.cmu.edu/tr/tr831/tr831.pdf)
17. [Leo A. Goodman (1964). Interactions in Multidimensional Contingency Tables. The Annals of Mathematical Statistics.](https://doi.org/10.1214/aoms/1177703561)
18. [Leo A. Goodman (1970). The Multivariate Analysis of Qualitative Data: Interactions among Multiple Classifications. Journal of the American Statistical Association.](https://doi.org/10.1080/01621459.1970.10481076)
19. [Leo A. Goodman (1971). The Analysis of Multidimensional Contingency Tables: Stepwise Procedures and Direct Estimation Methods for Building Models for Multiple Classifications. Technometrics.](https://doi.org/10.1080/00401706.1971.10488753)
20. [Log-Linear Models for Frequency Data: Sufficient Statistics and Likelihood Equations (Haberman, 1973, Annals of Statistics)](https://www.stat.cmu.edu/~brian/720-2007-source/week05/haberman-1973-ann-stat.pdf)
21. [S. J. Haberman (1972). Algorithm AS 51: Log-Linear Fit for Contingency Tables. Journal of the Royal Statistical Society Series C (Applied Statistics).](https://doi.org/10.2307/2346506)
22. [Leo A. Goodman (1979). Simple Models for the Analysis of Association in Cross-Classifications Having Ordered Categories. Journal of the American Statistical Association.](https://doi.org/10.1080/01621459.1979.10481650)
23. [Contributions to the statistical analysis of contingency tables (Goodman, 2002, Annales de la Faculté des sciences de Toulouse)](https://www.numdam.org/item/AFST_2002_6_11_4_525_0.pdf)
24. [Graphical Log-Linear Models: Fundamental Concepts and Applications (JMASM)](https://digitalcommons.wayne.edu/cgi/viewcontent.cgi?article=2135&context=jmasm)
25. [Christensen, Log-Linear Models and Logistic Regression, 3rd edition, Springer (2025)](https://link.springer.com/book/10.1007/978-3-031-69038-9)
26. [eMLEloglin R package user manual (sparse-table fitting via facial sets)](https://rdrr.io/cran/eMLEloglin/f/inst/doc/User_manual.pdf)
27. [An empirical investigation of some effects of sparseness in contingency tables (Agresti & Yang, 1987)](https://alanagresti.com/articles/agresti_yang_1987.pdf)
28. [Asymptotic Log-Linear Analysis: Some Cautions concerning Sparse Frequency Tables (Mielke, Berry & Johnston, 2004, Perceptual and Motor Skills 94:19-32)](https://journals.sagepub.com/doi/10.2466/pr0.94.1.19-32)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Multivariate association and dimension reduction › Titles A to Me

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/log-linear-model

English original: https://www.edgepedia.org/log-linear-model
