# Gamma回归

Gamma回归是一种广义线性模型（GLM），适用于严格为正、右偏的连续结果变量，其条件方差与条件均值的平方成正比，因此变异系数在各观测之间保持恒定。<sup>[1](https://cran.r-project.org/web/packages/glmbayes/vignettes/Chapter-11.html)</sup> 对于费用和索赔严重程度这类结果变量，它是标准选择——在原始尺度上做普通最小二乘拟合效果很差，而在变换后的尺度上做普通最小二乘又可能严重偏倚参数估计。<sup>[2](https://www.york.ac.uk/media/economics/documents/herc/wp/10_01.pdf)</sup><sup> • </sup><sup>[3](https://civil.colorado.edu/%7Ebalajir/CVEN6833/lectures/GammaGLM-01.pdf)</sup>

| 关键事实 | 详情 |
|---|---|
| 结果变量取值域 | 严格为正、右偏的连续响应变量<sup>[1](https://cran.r-project.org/web/packages/glmbayes/vignettes/Chapter-11.html)</sup> |
| 方差函数 | \( \mathrm{Var}(Y_i) = \phi \cdot \mu_i^2 \)，即变异系数恒定<sup>[1](https://cran.r-project.org/web/packages/glmbayes/vignettes/Chapter-11.html)</sup><sup> • </sup><sup>[4](https://www.math.cit.tum.de/fileadmin/w00ccg/math/Forschung/forschungsgruppen/statistics/academics/lec8.pdf)</sup> |
| 离散度 | \( \phi = 1/\nu \)，即Gamma形状参数的倒数<sup>[4](https://www.math.cit.tum.de/fileadmin/w00ccg/math/Forschung/forschungsgruppen/statistics/academics/lec8.pdf)</sup> |
| 标准连接函数 | 对数连接与倒数（逆）连接均被广泛使用；典范连接为负倒数，\( g(\mu) = -1/\mu \)<sup>[1](https://cran.r-project.org/web/packages/glmbayes/vignettes/Chapter-11.html)</sup><sup> • </sup><sup>[3](https://civil.colorado.edu/%7Ebalajir/CVEN6833/lectures/GammaGLM-01.pdf)</sup> |
| 系数含义（对数连接） | \( \exp(\beta_j) \) 为协变量每变化一个单位时期望响应的乘性变化<sup>[1](https://cran.r-project.org/web/packages/glmbayes/vignettes/Chapter-11.html)</sup> |
| 估计方法 | 迭代重加权最小二乘，最大化Gamma对数似然<sup>[5](https://www.maths.usyd.edu.au/u/jchan/GLM/Nelder1972GLM.pdf)</sup><sup> • </sup><sup>[6](https://files.eric.ed.gov/fulltext/ED607605.pdf)</sup> |
| 不允许零值 | 精确零值需要改用Tweedie（复合泊松-Gamma）或两部模型等替代方案<sup>[7](https://arxiv.org/pdf/1608.04910)</sup> |

## 工作原理

Gamma GLM是一种指数离散模型：均值为 \( \mathrm{E}(Y) = \mu = \kappa'(\theta) \)，方差为 \( \mathrm{Var}(Y) = \kappa''(\theta) \cdot \phi \)，其中 \( \phi \) 为离散度参数。<sup>[7](https://arxiv.org/pdf/1608.04910)</sup> 对于Gamma分布，方差函数为 \( b''(\theta) = 1/\theta^2 = \mu^2 \)，离散度为 \( \phi = 1/\nu \)，其中 \( \nu \) 为形状参数，于是 \( \mathrm{Var}(Y_i) = \phi \cdot \mu_i^2 \)。<sup>[4](https://www.math.cit.tum.de/fileadmin/w00ccg/math/Forschung/forschungsgruppen/statistics/academics/lec8.pdf)</sup> 用GLM的术语来说，离散度为 \( \phi = 1/k \)，因此形状 \( k \) 就是精度 \( 1/\phi \)。<sup>[8](https://rdrr.io/cran/glmbayes/f/inst/doc/Chapter-02-S05.Rmd)</sup> 线性预测子为 \( \eta_i = x_i^T \cdot \beta \)，均值为 \( \mu_i = g^{-1}(\eta_i) \)。<sup>[1](https://cran.r-project.org/web/packages/glmbayes/vignettes/Chapter-11.html)</sup>

连接函数的选择同时决定了解释方式和数值稳定性。在对数连接下，对数似然（忽略常数项）为 \( \ell(\beta) = \sum_{i=1}^n w_i\left[ -\frac{1}{\phi}\,\eta_i - \frac{1}{\phi}\,y_i \cdot e^{-\eta_i} \right] \)。<sup>[1](https://cran.r-project.org/web/packages/glmbayes/vignettes/Chapter-11.html)</sup> 对数连接之所以更受青睐，是因为它自动保证 \( \mu_i > 0 \)，给出乘性的系数解释，使似然在 \( \eta_i \) 上呈对数凹，且数值稳定。<sup>[1](https://cran.r-project.org/web/packages/glmbayes/vignettes/Chapter-11.html)</sup> 典范连接为 \( \theta = -1/\mu \)：它给出关于观测线性的充分统计量，但要求 \( \eta_i < 0 \)，从而需要对 \( \beta \) 施加约束以保证 \( \mu_i > 0 \)，因此并不常用。<sup>[4](https://www.math.cit.tum.de/fileadmin/w00ccg/math/Forschung/forschungsgruppen/statistics/academics/lec8.pdf)</sup><sup> • </sup><sup>[9](https://bura.brunel.ac.uk/bitstream/2438/2343/1/TR_03_86.pdf)</sup> 软件还提供恒等连接、幂连接（\( \eta = \mu^a \)）和平方根连接；NAG例程nag_glm_gamma（g02gdc）支持全部四种。<sup>[10](https://support.nag.com/numeric/nl/nagdoc_25/nagdoc_cl25/html/g02/g02gdc.html)</sup> 在对数连接下，\( \exp(\beta_j) \) 为协变量每变化一个单位、或从基线变为某一因子水平时期望响应的乘性变化。<sup>[1](https://cran.r-project.org/web/packages/glmbayes/vignettes/Chapter-11.html)</sup>

## 如何实现

拟合通过迭代重加权最小二乘求解最大似然方程，这是一种带权重函数的迭代过程。<sup>[5](https://www.maths.usyd.edu.au/u/jchan/GLM/Nelder1972GLM.pdf)</sup> 在R中，`glm()`配合`family = Gamma`即以这种方式拟合模型，最大化Gamma对数似然。<sup>[6](https://files.eric.ed.gov/fulltext/ED607605.pdf)</sup> 在Python中，`statsmodels.genmod.families.family.Gamma`将方差函数实现为`mu_squared`（\( V(\mu) = \mu^2 \)）；其默认连接为倒数连接，同时提供对数、恒等和倒数连接。<sup>[11](https://www.statsmodels.org/v0.14.3/generated/statsmodels.genmod.families.family.Gamma.html)</sup> Stata的`glm`和SAS的`proc genmod`采用标准的Gamma尺度设定，即方差与均值的平方成正比。<sup>[12](https://link.springer.com/article/10.1186/s12874-023-02113-1)</sup>

离散度在拟合之后估计。矩估计法使用Pearson卡方统计量，\( \hat{\phi} = \chi^2_P/(n - p) \)。<sup>[4](https://www.math.cit.tum.de/fileadmin/w00ccg/math/Forschung/forschungsgruppen/statistics/academics/lec8.pdf)</sup> R中对Gamma `glm`调用`summary()`只给出粗略的离散度估计；`MASS::gamma.dispersion()`提供更好的估计。<sup>[1](https://cran.r-project.org/web/packages/glmbayes/vignettes/Chapter-11.html)</sup> 在诊断方面，残差偏差 \( D(y, \hat{\mu}) \) 渐近服从 \( \sim \phi \cdot \chi^2(n-p) \)，尺度化偏差检验可用于检查离散度。<sup>[4](https://www.math.cit.tum.de/fileadmin/w00ccg/math/Forschung/forschungsgruppen/statistics/academics/lec8.pdf)</sup>

## 起源

该框架由J. A. Nelder和R. W. M. Wedderburn在《广义线性模型》（"Generalized Linear Models"）一文中提出，发表于《皇家统计学会杂志A辑（综合）》，1972年。<sup>[13](https://doi.org/10.2307/2344614)</sup> 该文用四种分布说明GLM：正态、二项、泊松和Gamma（最后一种用于方差成分），并给出Gamma对数似然 \( L = -p(z/\mu + \ln \mu - \ln z) - \ln z \)。<sup>[5](https://www.maths.usyd.edu.au/u/jchan/GLM/Nelder1972GLM.pdf)</sup> 如今，Gamma回归在McCullagh和Nelder（1989）以及Agresti（2015）等参考文献中已被视为标准GLM。<sup>[1](https://cran.r-project.org/web/packages/glmbayes/vignettes/Chapter-11.html)</sup> 关于形状（与离散度相关）参数的早期后续工作发展了偏倚近似和偏倚校正估计量，以及Pearson统计量期望与方差的近似。<sup>[9](https://bura.brunel.ac.uk/bitstream/2438/2343/1/TR_03_86.pdf)</sup>

## 变体

- **Gamma形状模型。** 有一种提议让协变量通过形状参数进入模型，使方差与均值成正比而非与均值的平方成正比；模拟显示，正确设定的模型比标准尺度模型参数偏倚更小、标准误更低、抽样分布偏度更小，并在美国退伍军人事务部费用数据上表现出更好的拟合（更高的R方、更小的均方根误差、按预测值划分的十分位组内更小的平均残差）。<sup>[12](https://link.springer.com/article/10.1186/s12874-023-02113-1)</sup>
- **Tweedie／复合泊松-Gamma。** Tweedie族具有 \( \mathrm{Var}(Y) = \phi \cdot \mu^p \)，在 \( p = 2 \) 时包含Gamma；当 \( p \) 在(1, 2)区间时，它是复合泊松-Gamma分布，支持精确零值，为费用数据提供了一种单一分布替代两部二项／Gamma模型和Tobit模型的方案。<sup>[7](https://arxiv.org/pdf/1608.04910)</sup>
- **广义Gamma与GAMLSS。** 广义Gamma（GG）回归模型具有位置（\( \mu \)）、尺度（\( \sigma \)）和形状（\( \nu \)）参数，在参数上嵌套了Gamma、Weibull和对数正态模型；它在GAMLSS框架中实现，\( \mu \) 和 \( \sigma \) 使用对数连接，\( \nu \) 使用恒等连接，并应用于医院费用数据。<sup>[14](https://jsm.yazd.ac.ir/article_1733_99bc9b7e9686814b9729113c2694a44c.pdf)</sup> 双重广义Gamma回归同时对均值和离散度建模，在CRAN包Bayesiangammareg中实现。<sup>[15](https://cran.r-project.org/web/packages/Bayesiangammareg/Bayesiangammareg.pdf)</sup>
- **贝叶斯拟合。** glmbayes R包通过对数凹似然的接受-拒绝抽样拟合Gamma GLM，提供固定离散度和可变离散度的采样器、用于Gibbs离散度估计的逆离散度 \( 1/\phi \) 的Gamma先验，以及通过bayesplot的`pp_check()`进行后验预测检验。<sup>[16](https://rdrr.io/cran/glmbayes/f/README.md)</sup>
- **稳健估计。** 一种用于Gamma回归的稳健估计量可处理离群值和多重共线性，已应用于乳腺癌数据。<sup>[17](https://www.nature.com/articles/s41598-025-25231-w)</sup>

## 应用

带对数连接的Gamma回归广泛用于医疗费用数据，继Blough、Madden和Hornbrook（1999）等工作之后；在GLM建模中，需要为以协变量为条件的原始尺度结果指定均值函数和方差函数。<sup>[18](https://www.nber.org/system/files/working_papers/t0293/t0293.pdf)</sup> 一个实际优势是预测直接在原始费用尺度上进行，无需逆变换，而异方差性通过分布族的选择来处理。<sup>[2](https://www.york.ac.uk/media/economics/documents/herc/wp/10_01.pdf)</sup> 在一项关于皮埃蒙特糖尿病登记的研究中，费用高度不对称（偏度14.3）且非正态，研究者使用了带对数连接的Gamma模型；该模型给出糖尿病与非糖尿病患者之间的糖尿病费用比为4.69。<sup>[19](https://link.springer.com/article/10.1186/s12913-015-1241-1)</sup> 保险索赔严重程度建模是另一个典型用途。<sup>[20](https://burning-cost.github.io/2026/04/02/robust-mmd-glm-severity-modelling-insurance-glm-tools-v020/)</sup>

## 局限与替代方案

**零值与边界值。** Gamma分布在零处没有概率质量，因此精确零值将其排除在外。加一个常数（\( \mathrm{cost} + 1 \)）来拟合对数线性模型是一种任意选择，可能使费用与协变量之间的关系产生偏倚。<sup>[19](https://link.springer.com/article/10.1186/s12913-015-1241-1)</sup> \( p \) 在(1, 2)区间的Tweedie模型在单一分布内处理零值；在一项应用中，Tweedie模型的拟合与两部模型相当，并优于Tobit模型。<sup>[7](https://arxiv.org/pdf/1608.04910)</sup> 另一种失败模式是拟合值落在边界 \( \hat{\mu} = 0.0 \)，这可能在小 \( y \) 值和不合适的模型下出现；NAG文档建议重新设定模型或剔除观测。<sup>[10](https://support.nag.com/numeric/nl/nagdoc_25/nagdoc_cl25/html/g02/g02gdc.html)</sup>

**对数变换后的OLS。** 对对数变换后的数据做OLS可给出一致的斜率估计，但截距约有 \( -\sigma^2/2 \) 的偏倚。<sup>[4](https://www.math.cit.tum.de/fileadmin/w00ccg/math/Forschung/forschungsgruppen/statistics/academics/lec8.pdf)</sup> 更根本地说，对人工变换后的数据做OLS建模的是 \( \mathrm{E}(g(y)) \) 而非 \( g(\mathrm{E}(y)) \)，这可能严重偏倚参数估计；GLM与OLS的估计仅在恒等连接下一致。<sup>[3](https://civil.colorado.edu/%7Ebalajir/CVEN6833/lectures/GammaGLM-01.pdf)</sup>

**对数正态与逆高斯。** Gamma分布和对数正态分布都适用于变异系数恒定的连续正偏数据，因此两者往往都能适合同一数据。<sup>[6](https://files.eric.ed.gov/fulltext/ED607605.pdf)</sup> 它们并不总是一致：在一个疫苗产品的真实临床试验数据集中，两种模型给出了不同结果，有人提出同时用两种模型分析同一数据集作为权宜策略。<sup>[21](https://www.tandfonline.com/doi/abs/10.1080/00031305.1999.10474437)</sup> 由于对数正态模型和对数连接Gamma模型都是乘性的，若不注意逆变换技术，估计的费用比较无法直接解释。<sup>[19](https://link.springer.com/article/10.1186/s12913-015-1241-1)</sup> 均值-方差关系可区分候选模型：正态方差与均值无关，泊松方差等于均值，Gamma方差为均值的平方，逆高斯方差为均值的立方。<sup>[22](http://support.sas.com/kb/60/335.html)</sup> Tweedie幂次 \( p \) 涵盖了这些情形及介于其间的非整数幂；SAS PROC GENMOD可对 \( p > 1.1 \) 估计幂次，修正Park检验是选择幂次的另一种方法。<sup>[22](http://support.sas.com/kb/60/335.html)</sup> 扩展估计方程（EEE）模型具有灵活的连接函数，在一项卫生支出研究中，其在四种分布下的表现与Gamma及其他GLM族模型相当或更好。<sup>[23](https://onlinelibrary.wiley.com/doi/10.1002/hec.1498)</sup>

**哪种连接最常用？** 已发表文献说法不一。讲义指出典范连接不常用而对数连接最常用，<sup>[4](https://www.math.cit.tum.de/fileadmin/w00ccg/math/Forschung/forschungsgruppen/statistics/academics/lec8.pdf)</sup> 而2025年的一篇论文指出倒数函数是Gamma回归模型中最常用的连接函数。<sup>[17](https://www.nature.com/articles/s41598-025-25231-w)</sup> 软件默认值也各不相同：statsmodels默认使用倒数连接，<sup>[11](https://www.statsmodels.org/v0.14.3/generated/statsmodels.genmod.families.family.Gamma.html)</sup> 而glmbayes的使用指南将对数连接视为更可取的实际选择。<sup>[1](https://cran.r-project.org/web/packages/glmbayes/vignettes/Chapter-11.html)</sup>

## References

1. [Chapter 11: Models for the Gamma family (glmbayes vignette)](https://cran.r-project.org/web/packages/glmbayes/vignettes/Chapter-11.html)
2. [Models For Health Care (University of York HERC working paper)](https://www.york.ac.uk/media/economics/documents/herc/wp/10_01.pdf)
3. [GLM with a Gamma-distributed Dependent Variable (CU Boulder lecture notes)](https://civil.colorado.edu/%7Ebalajir/CVEN6833/lectures/GammaGLM-01.pdf)
4. [Lecture 8: Gamma regression (TU Munich)](https://www.math.cit.tum.de/fileadmin/w00ccg/math/Forschung/forschungsgruppen/statistics/academics/lec8.pdf)
5. [Generalized Linear Models (Nelder & Wedderburn, 1972)](https://www.maths.usyd.edu.au/u/jchan/GLM/Nelder1972GLM.pdf)
6. [Comparing Gamma and Log-Normal GLMs in R Using Simulation (ERIC repository)](https://files.eric.ed.gov/fulltext/ED607605.pdf)
7. [Tweedie GLM for semicontinuous health care cost data (arXiv)](https://arxiv.org/pdf/1608.04910)
8. [glmbayes: inst/doc/Chapter-02-S05.Rmd](https://rdrr.io/cran/glmbayes/f/inst/doc/Chapter-02-S05.Rmd)
9. [TR/03/86 (Feb 1986): Improved Estimators for the Shape Parameter in Gamma Regression (Al-Abood, Bakir, Young)](https://bura.brunel.ac.uk/bitstream/2438/2343/1/TR_03_86.pdf)
10. [nag_glm_gamma (g02gdc): NAG Library, Mark 25](https://support.nag.com/numeric/nl/nagdoc_25/nagdoc_cl25/html/g02/g02gdc.html)
11. [statsmodels.genmod.families.family.Gamma, statsmodels 0.14.3](https://www.statsmodels.org/v0.14.3/generated/statsmodels.genmod.families.family.Gamma.html)
12. [Better performance for right-skewed data using an alternative gamma model (BMC Medical Research Methodology, 2023)](https://link.springer.com/article/10.1186/s12874-023-02113-1)
13. [J. A. Nelder, R. W. M. Wedderburn (1972). Generalized Linear Models. Journal of the Royal Statistical Society Series A (General).](https://doi.org/10.2307/2344614)
14. [Generalized gamma regression for hospital costs (Journal of Statistical Modelling, Yazd)](https://jsm.yazd.ac.ir/article_1733_99bc9b7e9686814b9729113c2694a44c.pdf)
15. [Bayesiangammareg: Double Generalized Gamma Regression Models (CRAN package documentation)](https://cran.r-project.org/web/packages/Bayesiangammareg/Bayesiangammareg.pdf)
16. [glmbayes: README.md](https://rdrr.io/cran/glmbayes/f/README.md)
17. [New robust estimator for handling outliers and multicollinearity in gamma regression model with application to breast cancer data | Scientific Reports](https://www.nature.com/articles/s41598-025-25231-w)
18. [Modeling Costs with Generalized Gamma Regression (NBER Working Paper t0293)](https://www.nber.org/system/files/working_papers/t0293/t0293.pdf)
19. [Is the choice of the statistical model relevant in the cost estimation of patients with chronic diseases? (BMC Health Services Research)](https://link.springer.com/article/10.1186/s12913-015-1241-1)
20. [RobustMMDGLM: Severity Modelling When Gamma GLMs Break | Burning Cost](https://burning-cost.github.io/2026/04/02/robust-mmd-glm-severity-modelling-insurance-glm-tools-v020/)
21. [When Log-Normal and Gamma Models Give Different Results: A Case Study (The American Statistician)](https://www.tandfonline.com/doi/abs/10.1080/00031305.1999.10474437)
22. [60335 - Choice of continuous response distribution in log-linked GLMs (SAS Knowledge Base)](http://support.sas.com/kb/60/335.html)
23. [Health expenditure estimation and functional form: applications of the generalized gamma and extended estimating equations models (Health Economics, 2009)](https://onlinelibrary.wiley.com/doi/10.1002/hec.1498)

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

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

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/gamma-regression

English original: https://www.edgepedia.org/gamma-regression
