# 多水平逻辑回归

多水平逻辑回归是一种针对二分类结局的回归方法，它在多个层级上加入正态分布的随机效应（例如医院中的医生所辖的患者），以对聚类结构建模。它是普通逻辑回归的混合模型扩展，在流行病学和卫生服务研究中应用极多，在这些领域，多水平模型和分层模型的发表使用量一直在快速增加。<sup>[1](https://onlinelibrary.wiley.com/doi/10.1002/sim.7336)</sup>

| 关键事实 | 详细说明 |
|---|---|
| 模型 | \( \mathrm{logit}(\pi_{ij}) = a_i + x_{ij}' \cdot \beta \)，其中 \( a_i \sim N(0, \sigma_{a}^{2}) \)，第1层误差服从方差为 \( \pi^{2}/3 \) 的标准逻辑分布<sup>[2](https://grodri.github.io/multilevel/pop510slides5.pdf)</sup> |
| logit尺度上的ICC与MOR | \( \rho_{I} = \sigma_{u0}^{2}/(\sigma_{u0}^{2} + 3.29) \)；\( \mathrm{MOR} = \exp(0.954\sqrt{\sigma_{u0}^{2}}) \)<sup>[3](https://www.ncbi.nlm.nih.gov/books/NBK565714/)</sup> |
| 估计 | 似然函数是对随机效应的积分，没有闭式解，因此使用拉普拉斯近似、自适应求积或PQL近似<sup>[4](https://pmc.ncbi.nlm.nih.gov/articles/PMC3866838/)</sup> |
| PQL偏倚 | 一阶PQL将固定效应系数低估23%至26%，将方差成分低估27%至90%；二阶PQL的系数偏倚为1%至7%，但方差仍被低估8%至27%<sup>[2](https://grodri.github.io/multilevel/pop510slides5.pdf)</sup> |
| 系数含义 | 个体特定比值比与总体平均比值比不同；在一项医院分娩示例中，个体特定的大学教育比值比为2.81，而GEE总体平均值为2.21<sup>[2](https://grodri.github.io/multilevel/pop510slides5.pdf)</sup> |
| 样本量建议 | 为获得有效估计，建议至少约50个组、每组约50个个体<sup>[5](https://link.springer.com/article/10.1186/1471-2288-7-34)</sup> |
| 软件 | Stata的melogit（自适应Gauss-Hermite，默认每个效应7个积分点）、R的glmer和glmmTMB、SAS的PROC GLIMMIX和NLMIXED、HLM、MLwiN、SuperMix<sup>[2](https://grodri.github.io/multilevel/pop510slides5.pdf)</sup><sup> • </sup><sup>[4](https://pmc.ncbi.nlm.nih.gov/articles/PMC3866838/)</sup> |

## 工作原理

随机截距模型写作 \( \mathrm{logit}(\pi_{ij}) = \beta_{0} + \beta_{1} \cdot x_{1ij} + \cdots + u_{0j} \)，其中 \( u_{0j} \sim N(0, \sigma_{u0}^{2}) \) 是聚类 \( j \) 中所有成员共享的聚类效应。<sup>[3](https://www.ncbi.nlm.nih.gov/books/NBK565714/)</sup> 潜变量（阈值）解释将每个二分类响应视为一个连续变量 \( Y^{*}_{ij} \) 的符号：系统部分建模 \( a_i + x_{ij}' \cdot \beta \)，残差 \( e_{ij} \) 服从均值为0、方差为 \( \pi^{2}/3 \) 的标准逻辑分布（若采用probit连接，则为 \( N(0,1) \)）。<sup>[2](https://grodri.github.io/multilevel/pop510slides5.pdf)</sup> 由于在该潜变量尺度上第1层方差固定为 \( \pi^{2}/3 \)，它无法从似然中辨识；只有更高层的方差被估计。<sup>[6](https://link.springer.com/article/10.1186/1471-2288-11-77)</sup>

在logit尺度上，组内相关系数（方差划分系数）通过潜响应公式报告，这是若干方法中最广泛使用的一种；中位比值比（MOR）以单个比值比概括聚类异质性。<sup>[1](https://onlinelibrary.wiley.com/doi/10.1002/sim.7336)</sup><sup> • </sup><sup>[3](https://www.ncbi.nlm.nih.gov/books/NBK565714/)</sup> 方差成分无法在加入协变量的不同模型之间直接比较，因为潜变量被重新标度了。<sup>[1](https://onlinelibrary.wiley.com/doi/10.1002/sim.7336)</sup>

系数是聚类特定的（个体特定的）。在聚类特定模型下，边际模型给出的总体平均估计更接近零，正如纽豪斯（Neuhaus）及其同事所表明的，因此这两种参数化回答的是不同的问题，两组估计相对于彼此都没有偏倚。<sup>[1](https://onlinelibrary.wiley.com/doi/10.1002/sim.7336)</sup>

## 如何实施

与线性混合模型不同，GLMM的似然是对随机效应的积分，没有闭式解，因此所有实际估计都是近似的。<sup>[4](https://pmc.ncbi.nlm.nih.gov/articles/PMC3866838/)</sup> 主要的边际方法有拉普拉斯近似、自适应高斯求积和惩罚拟似然或边际拟似然（PQL/MQL）。MQL仅用预测子的固定部分展开泰勒级数，而PQL围绕当前估计的残差展开；这两个名称都来自布雷斯洛（Breslow）和克莱顿（Clayton）。<sup>[7](https://www.bristol.ac.uk/media-library/sites/cmm/migrated/documents/binary-response-multilevel-models-improved-approximations.pdf)</sup> 自适应求积以随机效应的经验贝叶斯估计以及该子优化得到的海森矩阵为中心和尺度来设置求积点。<sup>[4](https://pmc.ncbi.nlm.nih.gov/articles/PMC3866838/)</sup>

对于每个随机效应具有中等至大量观测值的情形，自适应高斯求积和拉普拉斯近似非常准确，随着每个效应的观测数增加，求积法更可取，而PQL的偏倚最大。<sup>[4](https://pmc.ncbi.nlm.nih.gov/articles/PMC3866838/)</sup>

计算成本增长很快：有 \( k \) 个相关随机效应时，需要估计 \( k(k+1)/2 \) 个协方差参数，而每个效应 \( Q \) 个积分点的非自适应求积总共需要 \( Q^{k} \) 个积分点，这种指数级负担增加了不收敛的风险。<sup>[8](https://pmc.ncbi.nlm.nih.gov/articles/PMC3839969/)</sup>

Stata的melogit默认使用自适应Gauss-Hermite，每个效应7个积分点；R的glmer在多于单个标量随机效应时只支持一个积分点（nAGQ=1）；SPSS的GENLINMIXED提供伪似然（包括RSPL）、MQL和PQL估计方法。<sup>[2](https://grodri.github.io/multilevel/pop510slides5.pdf)</sup><sup> • </sup><sup>[4](https://pmc.ncbi.nlm.nih.gov/articles/PMC3866838/)</sup><sup> • </sup><sup>[9](https://web.pdx.edu/~newsomj/mlrclass/ho_binary.pdf)</sup>

在使用SAS NLMIXED配合自适应高斯求积的模拟中，对于100个组、组规模为50或更大的情形，固定效应估计无偏，而方差-协方差成分即使在该规模下仍略有偏倚；作者建议至少50个组、每组50个个体，对于低患病率结局，每组预期事件数应超过1，这需要更大的样本量。<sup>[5](https://link.springer.com/article/10.1186/1471-2288-7-34)</sup> 麦克尼什（McNeish）和斯泰普尔顿（Stapleton）发现，自适应求积和拉普拉斯近似在少于约50个组时效果不佳，建议100个或更多组；限制性PQL（RPQL）在组数较少时更可取，但目前仅在SAS中可用。<sup>[9](https://web.pdx.edu/~newsomj/mlrclass/ho_binary.pdf)</sup>

## 起源

乔治·Y·王（George Y. Wong）和威廉·M·梅森（William M. Mason）于1985年发表在《美国统计学会会刊》上的论文《用于多水平分析的分层逻辑回归模型》提出了一个针对分组二分类数据的分层逻辑模型，其中微观层面的逻辑系数被处理为宏观回归变量的函数，用经验贝叶斯程序估计，并将其应用于世界生育率调查中个体嵌套于国家的数据。<sup>[10](https://doi.org/10.1080/01621459.1985.10478148)</sup> 戈德斯坦（Goldstein）1986年发表在《Biometrika》上的论文为多水平线性模型发展了迭代广义最小二乘（IGLS）算法，这一计算基础后来被扩展到离散响应。<sup>[11](https://doi.org/10.1093/biomet/73.1.43)</sup> 戈德斯坦（Goldstein）1991年发表在《Biometrika》上关于非线性多水平模型的论文将该框架应用于离散响应数据，采用边际拟似然。<sup>[12](https://doi.org/10.1093/biomet/78.1.45)</sup> 布雷斯洛（Breslow）和克莱顿（Clayton）1993年发表在《美国统计学会会刊》上的论文《广义线性混合模型中的近似推断》命名了PQL和MQL并应用了拉普拉斯方法，<sup>[13](https://doi.org/10.1080/01621459.1993.10594284)</sup> 而沃尔芬格（Wolfinger）和奥康奈尔（O'Connell）1993年的伪似然方法与PQL等价。<sup>[14](https://doi.org/10.1080/00949659308811554)</sup> 罗德里格斯（Rodriguez）和戈德曼（Goldman）1995年发表在《皇家统计学会会刊A辑》上的评估表明，对于第1层聚类规模小、随机参数值大的二分类响应，PQL和MQL可能严重偏倚，<sup>[15](https://doi.org/10.2307/2983404)</sup> 而戈德斯坦（Goldstein）和拉什巴什（Rasbash）1996年发表在《皇家统计学会会刊A辑》上的论文引入了二阶PQL近似，在很大程度上消除了这些偏倚。<sup>[16](https://doi.org/10.2307/2983328)</sup> 劳登布什（Raudenbush）、杨（Yang）和约塞夫（Yosef）2000年发表在《计算与图形统计杂志》上的论文发展了六阶多元拉普拉斯近似，模拟显示其精度与高斯求积相当。<sup>[17](https://doi.org/10.1080/10618600.2000.10474870)</sup> 泽格（Zeger）和卡里姆（Karim）1991年发表在《美国统计学会会刊》上的论文通过将广义线性随机效应模型置于贝叶斯框架下并用Gibbs采样器，避免了数值积分。<sup>[18](https://doi.org/10.1080/01621459.1991.10475006)</sup> 莱萨夫雷（Lesaffre）和斯皮森斯（Spiessens）2001年发表在《应用统计学》上的论文表明，逻辑随机效应模型的结果对求积点数目敏感。<sup>[19](https://doi.org/10.1111/1467-9876.00237)</sup>

## 变体

随机截距模型是最简单的情形。随机斜率模型让协变量系数随聚类变化，用lme4风格的语法指定，如 time\|block；三水平模型将医生的随机截距嵌套于医院之中。<sup>[20](https://cran.r-project.org/web/packages/glmmTMB/vignettes/glmmTMB.pdf)</sup><sup> • </sup><sup>[21](https://stats.oarc.ucla.edu/r/dae/mixed-effects-logistic-regression/)</sup> 交叉分类模型结合随机个体效应和随机题目效应，这种安排用于教育测量中的项目反应理论；对混合分层与交叉分类随机结构的高效多水平处理与拉什巴什（Rasbash）和戈德斯坦（Goldstein）1994年发表在《教育与行为统计杂志》上的论文相关。<sup>[22](https://journals.sagepub.com/doi/10.3102/10769986028004369)</sup><sup> • </sup><sup>[23](https://doi.org/10.3102/10769986019004337)</sup> 在用于项目功能差异的随机系数分层逻辑回归中，DIF系数被建模为跨聚类的正态分布随机变量。<sup>[24](https://www.colorado.edu/cadre/media/100)</sup> 多变量响应版本为每家医院给出若干相关随机效应，每个二分类质量指标一个。<sup>[25](https://onlinelibrary.wiley.com/doi/10.1002/sim.8484)</sup>

## 应用

医院结局画像是一项主要用途。一个贝叶斯多变量随机效应逻辑模型被应用于6个二分类指标（包括30天生存率），涉及102家医院的10,881名急性心肌梗死患者，使得可以就某医院在一个或同时多个指标上表现不佳的概率作出陈述。<sup>[25](https://onlinelibrary.wiley.com/doi/10.1002/sim.8484)</sup> 在教育测量中，当考生存在聚类时，推荐使用随机截距分层逻辑回归而非标准逻辑DIF模型。<sup>[24](https://www.colorado.edu/cadre/media/100)</sup>

## 局限与替代方法

PQL和MQL会衰减固定效应和方差成分；一阶PQL将系数低估23%至26%，将方差低估27%至90%，二阶PQL仍将方差低估8%至27%，且可能不收敛。<sup>[2](https://grodri.github.io/multilevel/pop510slides5.pdf)</sup> 分离现象——即协变量的某个线性组合完美预测结局——会使某些回归系数不存在，其估计在拟合过程中发散；这在结局不平衡、样本量小和效应强时很普遍。<sup>[26](https://bmcmedresmethodol.biomedcentral.com/articles/10.1186/s12874-022-01641-6)</sup> 在小样本稀疏数据中，随机效应方差的频率派最大似然估计往往恰好为零，标准误无法确定，而贝叶斯后验均值强烈依赖先验。<sup>[6](https://link.springer.com/article/10.1186/1471-2288-11-77)</sup> 沃尔德检验依赖渐近理论，在最高层单位很少时可能不准确；蒙特卡洛模拟、从最高层向下自助抽样和贝叶斯估计是替代方案。<sup>[21](https://stats.oarc.ucla.edu/r/dae/mixed-effects-logistic-regression/)</sup>

GEE给出有效的总体平均估计及稳健标准误，但针对的是不同的参数化。<sup>[2](https://grodri.github.io/multilevel/pop510slides5.pdf)</sup> 对二分类数据，为每组设单独截距的无条件最大似然由于附带参数问题对 \( \beta \) 不一致，而安德森（Andersen）的条件logit方法消除了组截距，对斜率系数一致，但它会丢弃组内结局无变异的组，这可能丢弃多达90%的数据。<sup>[2](https://grodri.github.io/multilevel/pop510slides5.pdf)</sup> 随机效应可视为正则化（收缩）的固定效应，未调整的多水平模型易受组水平混杂影响；Mundlak调整加入所纳入协变量的聚类均值以处理这种混杂，但无论它还是聚类稳健标准误，通常都不能保证与固定效应逻辑回归的系数或标准误完全相等。<sup>[27](https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8101D49CFD3B129F5753FC878F416980/S1047198720000418a.pdf/div-class-title-understanding-choosing-and-unifying-multilevel-and-fixed-effect-approaches-div.pdf)</sup><sup> • </sup><sup>[28](https://www.bls.gov/osmr/research-papers/2018/pdf/ec180020.pdf)</sup>

## References

1. [Intermediate and advanced topics in multilevel logistic regression analysis (Statistics in Medicine, 2017)](https://onlinelibrary.wiley.com/doi/10.1002/sim.7336)
2. [Multilevel Models - 5. Multilevel Logit Models (Rodríguez course notes)](https://grodri.github.io/multilevel/pop510slides5.pdf)
3. [Multilevel Logistic Regression Using MLwiN: Referrals to Physiotherapy (CMM textbook chapter, NCBI Bookshelf)](https://www.ncbi.nlm.nih.gov/books/NBK565714/)
4. [An assessment of estimation methods for generalized linear mixed models with binary outcomes](https://pmc.ncbi.nlm.nih.gov/articles/PMC3866838/)
5. [A simulation study of sample size for multilevel logistic regression models (BMC Medical Research Methodology)](https://link.springer.com/article/10.1186/1471-2288-7-34)
6. [Logistic random effects regression models: a comparison of statistical packages for binary and ordinal outcomes (BMC Medical Research Methodology, 2011)](https://link.springer.com/article/10.1186/1471-2288-11-77)
7. [Improved Approximations for Multilevel Models with Binary Responses (Goldstein & Rasbash, JRSS-A 1996)](https://www.bristol.ac.uk/media-library/sites/cmm/migrated/documents/binary-response-multilevel-models-improved-approximations.pdf)
8. [Logistic Regression with Multiple Random Effects: A Simulation Study of Estimation Methods and Statistical Packages](https://pmc.ncbi.nlm.nih.gov/articles/PMC3839969/)
9. [Multilevel Models with Binary and other Noncontinuous Dependent Variables (Newsom class notes)](https://web.pdx.edu/~newsomj/mlrclass/ho_binary.pdf)
10. [George Y. Wong, William M. Mason (1985). The Hierarchical Logistic Regression Model for Multilevel Analysis. Journal of the American Statistical Association.](https://doi.org/10.1080/01621459.1985.10478148)
11. [H. GOLDSTEIN (1986). Multilevel mixed linear model analysis using iterative generalized least squares. Biometrika.](https://doi.org/10.1093/biomet/73.1.43)
12. [HARVEY GOLDSTEIN (1991). Nonlinear multilevel models, with an application to discrete response data. Biometrika.](https://doi.org/10.1093/biomet/78.1.45)
13. [N. E. Breslow, D. G. Clayton (1993). Approximate Inference in Generalized Linear Mixed Models. Journal of the American Statistical Association.](https://doi.org/10.1080/01621459.1993.10594284)
14. [Russ Wolfinger, Michael O'connell (1993). Generalized linear mixed models a pseudo-likelihood approach. Journal of Statistical Computation and Simulation.](https://doi.org/10.1080/00949659308811554)
15. [German Rodriguez, Noreen Goldman (1995). An Assessment of Estimation Procedures for Multilevel Models with Binary Responses. Journal of the Royal Statistical Society Series A (Statistics in Society).](https://doi.org/10.2307/2983404)
16. [Harvey Goldstein, Jon Rasbash (1996). Improved Approximations for Multilevel Models with Binary Responses. Journal of the Royal Statistical Society Series A (Statistics in Society).](https://doi.org/10.2307/2983328)
17. [Stephen W. Raudenbush, Meng-Li Yang, Matheos Yosef (2000). Maximum Likelihood for Generalized Linear Models with Nested Random Effects via High-Order, Multivariate Laplace Approximation. Journal of Computational and Graphical Statistics.](https://doi.org/10.1080/10618600.2000.10474870)
18. [Scott L Zeger, M. Rezaul Karim (1991). Generalized Linear Models with Random Effects; a Gibbs Sampling Approach. Journal of the American Statistical Association.](https://doi.org/10.1080/01621459.1991.10475006)
19. [Emmanuel Lesaffre, Bart Spiessens (2001). On the Effect of the Number of Quadrature Points in a Logistic Random Effects Model: An Example. Journal of the Royal Statistical Society Series C (Applied Statistics).](https://doi.org/10.1111/1467-9876.00237)
20. [Getting started with the glmmTMB package (vignette, version 4.5.2)](https://cran.r-project.org/web/packages/glmmTMB/vignettes/glmmTMB.pdf)
21. [Mixed Effects Logistic Regression | R Data Analysis Examples (UCLA OARC)](https://stats.oarc.ucla.edu/r/dae/mixed-effects-logistic-regression/)
22. [Cross-Classification Multilevel Logistic Models in Psychometrics (Journal of Educational and Behavioral Statistics)](https://journals.sagepub.com/doi/10.3102/10769986028004369)
23. [Jon Rasbash, Harvey Goldstein (1994). Efficient Analysis of Mixed Hierarchical and Cross-Classified Random Structures Using a Multilevel Model. Journal of Educational and Behavioral Statistics.](https://doi.org/10.3102/10769986019004337)
24. [Using Hierarchical Logistic Regression to Study DIF and DIF Variance in Multilevel Data](https://www.colorado.edu/cadre/media/100)
25. [Comparing a multivariate response Bayesian random effects logistic regression model with a latent variable item response theory model for provider profiling on multiple binary indicators simultaneously (Statistics in Medicine)](https://onlinelibrary.wiley.com/doi/10.1002/sim.8484)
26. [An investigation of penalization and data augmentation to improve convergence of generalized estimating equations for clustered binary outcomes (BMC Medical Research Methodology, 2022)](https://bmcmedresmethodol.biomedcentral.com/articles/10.1186/s12874-022-01641-6)
27. [Understanding, choosing, and unifying multilevel and fixed effect approaches (Political Analysis)](https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8101D49CFD3B129F5753FC878F416980/S1047198720000418a.pdf/div-class-title-understanding-choosing-and-unifying-multilevel-and-fixed-effect-approaches-div.pdf)
28. [bls.gov](https://www.bls.gov/osmr/research-papers/2018/pdf/ec180020.pdf)

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

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Statistical inference, estimation, sampling, and testing › Regression analysis › Multilevel and mixed-effects regression

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/multilevel-logistic-regression

English original: https://www.edgepedia.org/multilevel-logistic-regression
