广义线性模型(Generalized Linear Models)

The Poisson regression model naturally arises when we want to model the average number of occurrences per unit of time or space. For example, the incidence of rare cancer, the number of car crossing at the crossroad, or the number of earthquakes.

当我们要每单位发生的时间或空间的平均数量的T型车,他泊松回归模型自然就出现了。 例如,罕见癌症的发生率,十字路口的汽车穿越次数或地震次数。

One feature of the Poisson distribution is that the mean equals the variance. However, over- or underdispersion happens in Poisson models, where the variance is larger or smaller than the mean value, respectively. In reality, overdispersion happens more frequently with a limited amount of data.

泊松分布的一个特征是均值等于方差。 但是,在Poisson模型中会发生过度分散分散不足的情况,其中方差分别大于或小于平均值。 实际上,在数据量有限的情况下,过度分散会更加频繁地发生。

The overdispersion issue affects the interpretation of the model. It is necessary to address the problem in order to avoid the wrong estimation of the coefficients.

过度分散问题影响模型的解释。 为了避免错误地估计系数,有必要解决该问题。

In this post, I am going to discuss some basic methods to adjust for the overdispersion phenomenon in the Poisson regression model. The implementation will be shown in R codes. I hope this article is helpful.

在本文中,我将讨论一些用于调整Poisson回归模型中过度分散现象的基本方法。 该实现将在R代码中显示。 希望本文对您有所帮助。

Suppose we want to model count responses Yi using a vector of predictors xi. We know that the response variable Yi follows a Poisson distribution with parameter μi.

假设我们要使用预测因子xi的向量对计数响应Yi建模 我们知道响应变量Yi遵循参数μi的泊松分布。

Yi follows the Poisson distribution
Yi遵循泊松分布

where the probability function is

概率函数在哪里

The Poisson PMF
泊松PMF

The log link function is used to link the linear combination of the predictors, Xi with the Poisson parameter μi.

对数链接函数用于链接预测变量Xi与泊松参数μi的线性组合。

The Poisson regression model.
泊松回归模型。

Let’s build a simple model with the example introduced in Faraway’s book.

让我们用Faraway的书中介绍的示例构建一个简单的模型。

## R codelibrary(faraway)data(gala)gala = gala[,-2]pois_mod = glm(Species ~ .,family=poisson,gala)summary(pois_mod)

This is the summary of the Poisson model.

这是泊松模型的摘要。

Call:glm(formula = Species ~ ., family = poisson, data = gala)

Deviance Residuals:     Min       1Q   Median       3Q      Max  -8.2752  -4.4966  -0.9443   1.9168  10.1849  

Coefficients:              Estimate Std. Error z value Pr(>|z|)    (Intercept)  3.155e+00  5.175e-02  60.963  < 2e-16 ***Area        -5.799e-04  2.627e-05 -22.074  < 2e-16 ***Elevation    3.541e-03  8.741e-05  40.507  < 2e-16 ***Nearest      8.826e-03  1.821e-03   4.846 1.26e-06 ***Scruz       -5.709e-03  6.256e-04  -9.126  < 2e-16 ***Adjacent    -6.630e-04  2.933e-05 -22.608  < 2e-16 ***---Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for poisson family taken to be 1)

    Null deviance: 3510.73  on 29  degrees of freedomResidual deviance:  716.85  on 24  degrees of freedomAIC: 889.68

Number of Fisher Scoring iterations: 5

Don’t be fooled by the super significant coefficients. Those beautiful p-values are exactly the consequences of the overdispersion issue. We can check the overdispersion either visually or quantitatively.

不要被超有效系数所迷惑。 这些漂亮的p值正是过度分散问题的结果。 我们可以目测或定量检查过度分散。

Let’s first plot out the estimated variance against the mean.

让我们首先绘制相对于均值的估计方差。

## R codeplot(log(fitted(pois_mod)),log((gala$Species-fitted(pois_mod))^2),xlab=expression(hat(mu)),ylab=expression((y-hat(mu))^2),pch=20,col="blue")abline(0,1) ## 'varianc = mean' line
Overdispersion Diagnosis
过度分散诊断

We can see that the majority of the variance is larger than the mean, which is a warning of overdispersion.

我们可以看到,大多数方差大于平均值,这是过度分散的警告。

Quantitatively, the dispersion parameter φ can be estimated using Pearson’s Chi-squared statistic and the degree of freedom.

可以使用Pearson卡方统计量和自由度来定量估计色散参数φ

Estimation of the dispersion parameter
色散参数的估计

When φ is larger than 1, it is overdispersion. To manually calculate the parameter, we use the code below.

当φ大于1时,它是过度分散的。 要手动计算参数,我们使用以下代码。

## R codedp = sum(residuals(pois_mod,type ="pearson")^2)/pois_mod$df.residualdp

which gives us 31.74914 and confirms this simple Poisson model has the overdispersion problem.

得出31.74914,并确认此简单的Poisson模型存在过度分散问题。

Alternatively, we can apply a significance test directly on the fitted model to check the overdispersion.

另外,我们可以直接在拟合模型上应用显着性检验以检查过度分散。

## R codelibrary(AER)dispersiontest(pois_mod)

which yields,

产生

Overdispersion test

data:  pois_modz = 3.3759, p-value = 0.0003678alternative hypothesis: true dispersion is greater than 1sample estimates:dispersion   25.39503

This overdispersion test reports the significance of the overdispersion issue within the model.

此过度分散测试报告了模型内过度分散问题的重要性。

We can check how much the coefficient estimations are affected by overdispersion.

我们可以检查多少系数估计受过度分散影响。

## R codesummary(pois_mod,dispersion = dp)

which yields,

产生

Call:glm(formula = Species ~ ., family = poisson, data = gala)

Deviance Residuals:     Min       1Q   Median       3Q      Max  -8.2752  -4.4966  -0.9443   1.9168  10.1849  

Coefficients:              Estimate Std. Error z value Pr(>|z|)    (Intercept)  3.1548079  0.2915897  10.819  < 2e-16 ***Area        -0.0005799  0.0001480  -3.918 8.95e-05 ***Elevation    0.0035406  0.0004925   7.189 6.53e-13 ***Nearest      0.0088256  0.0102621   0.860    0.390    Scruz       -0.0057094  0.0035251  -1.620    0.105    Adjacent    -0.0006630  0.0001653  -4.012 6.01e-05 ***---Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for poisson family taken to be 31.74914)

    Null deviance: 3510.73  on 29  degrees of freedomResidual deviance:  716.85  on 24  degrees of freedomAIC: 889.68

Number of Fisher Scoring iterations: 5

Now around half of the predictors become insignificant, which changes the entire interpretation of the model.

现在,大约一半的预测变量变得微不足道,这改变了模型的整个解释。

Alright, let’s address the problem in the following two ways.

好吧,让我们通过以下两种方式解决问题。

允许色散估计 (Allow Dispersion Estimation)

A simple way to adjust the overdispersion is as straightforward as to estimate the dispersion parameter within the model. This could be done via the quasi-families in R.

调整过度分散的简单方法与估算模型中的分散参数一样简单。 这可以通过R中的准族来完成。

qpoi_mod = glm(Species ~ .,family=quasipoisson, gala)summary(qpoi_mod)

which yields,

产生

Call:glm(formula = Species ~ ., family = quasipoisson, data = gala)

Deviance Residuals:     Min       1Q   Median       3Q      Max  -8.2752  -4.4966  -0.9443   1.9168  10.1849  

Coefficients:              Estimate Std. Error t value Pr(>|t|)    (Intercept)  3.1548079  0.2915901  10.819 1.03e-10 ***Area        -0.0005799  0.0001480  -3.918 0.000649 ***Elevation    0.0035406  0.0004925   7.189 1.98e-07 ***Nearest      0.0088256  0.0102622   0.860 0.398292    Scruz       -0.0057094  0.0035251  -1.620 0.118380    Adjacent    -0.0006630  0.0001653  -4.012 0.000511 ***---Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for quasipoisson family taken to be 31.74921)

    Null deviance: 3510.73  on 29  degrees of freedomResidual deviance:  716.85  on 24  degrees of freedomAIC: NA

Number of Fisher Scoring iterations: 5

We can see that the dispersion parameter is estimated to be 31.74921, which is very close to our manual calculation as aforementioned. This procedure tells us that only three of the predictors’ coefficients are significant.

我们可以看到,色散参数估计为31.74921,这与我们前面提到的手动计算非常接近。 这个过程告诉我们,只有三个预测变量系数是有效的。

用负二项式代替泊松 (Replace Poisson with Negative Binomial)

Another way to address the overdispersion in the model is to change our distributional assumption to the Negative binomial in which the variance is larger than the mean.

解决模型中过度分散的另一种方法是将分布假设更改为负二项式,其中方差大于均值

Let’s implement the negative binomial model in R.

让我们在R中实现负二项式模型。

## R codelibrary(MASS)nb_mod = glm.nb(Species ~ .,data = gala)summary(nb_mod)

which yields,

产生

Call:glm.nb(formula = Species ~ ., data = gala, init.theta = 1.674602286,     link = log)

Deviance Residuals:     Min       1Q   Median       3Q      Max  -2.1344  -0.8597  -0.1476   0.4576   1.8416  

Coefficients:              Estimate Std. Error z value Pr(>|z|)    (Intercept)  2.9065247  0.2510344  11.578  < 2e-16 ***Area        -0.0006336  0.0002865  -2.211 0.027009 *  Elevation    0.0038551  0.0006916   5.574 2.49e-08 ***Nearest      0.0028264  0.0136618   0.207 0.836100    Scruz       -0.0018976  0.0028096  -0.675 0.499426    Adjacent    -0.0007605  0.0002278  -3.338 0.000842 ***---Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for Negative Binomial(1.6746) family taken to be 1)

    Null deviance: 88.431  on 29  degrees of freedomResidual deviance: 33.196  on 24  degrees of freedomAIC: 304.22

Number of Fisher Scoring iterations: 1

              Theta:  1.675           Std. Err.:  0.442 

 2 x log-likelihood:  -290.223

It is a better fit to the data because the ratio of deviance over degrees of freedom is only slightly larger than 1 here.

这是对数据的更好拟合,因为此处偏差与自由度的比率仅略大于1。

结论 (Conclusions)

A. Overdispersion can affect the interpretation of the poisson model.

过度分散会影响泊松模型的解释。

B. To avoid the overdispersion issue in our model, we can use a quasi-family to estimate the dispersion parameter.

B.为了避免模型中的过度分散问题,我们可以使用准族来估计分散参数。

C. We can also use the negative binomial instead of the poisson model.

C.我们也可以使用负二项式代替泊松模型。

翻译自: https://towardsdatascience.com/adjust-for-overdispersion-in-poisson-regression-4b1f52baa2f1


http://www.taodudu.cc/news/show-3644536.html

相关文章:

  • 《应用商务统计分析》第六章 泊松回归
  • [机器学习算法]机泊松回归算法原理详解和应用
  • 零膨胀泊松回归案例分析
  • 用于时间序列数据的泊松回归模型
  • Stata面板设置与面板数据多元线性回归与泊松回归命令
  • Python+statsmodels实现多元线性回归和泊松回归
  • matlab泊松回归程序,如何实现泊松回归?
  • R语言进行泊松回归
  • [机器学习原理]泊松回归
  • 泊松分布和泊松回归_在eBay上通过泊松回归预测键盘销售率
  • 广义线性模型(逻辑回归、泊松回归)
  • 泊松回归R语言实例
  • matlab泊松回归程序,R - 泊松回归( Poisson Regression)
  • Stata的多元线性回归与泊松回归
  • R语言标准化死亡率 (SMR)计算(2)
  • 性能优化模式-美团技术博客
  • 读美团的营销业务实践以及领域驱动设计有后感
  • 美团技术四面1
  • 美团热更新方案 ASM 实践
  • 美团如何缓解数据倾斜与shuffle调优
  • 大厂技术博客汇总/美团/腾讯/网易/百度/头条
  • 【美团技术博客】Hive SQL的编译过程
  • 地理空间距离计算优化_附近的人(转自美团技术博客)
  • 美团技术分享:深度解密美团的分布式ID生成算法
  • 推荐的博客
  • 美团技术:设计模式在美团外卖营销业务中的实践
  • 转自美团技术博客的jvm内存泄露分析
  • 美团技术分享博客地址
  • 美团技术博客地址
  • 美团智能客服核心技术与实践

调整泊松回归中的过度分散相关推荐

  1. 大数据分析R中泊松回归模型实例

    如果您知道如何以及何时使用泊松回归,它可能是一个非常有用的工具.在大数据分析R中泊松回归模型实例中,我们将深入研究泊松回归,它是什么以及R程序员如何在现实世界中使用它. 具体来说,我们将介绍: 1)泊 ...

  2. Topic 6 SCI 文章之计数变量泊松回归

    这期继续说说统计这些事,泊松分布大家可能熟悉些,但是用它来做模型还是需要细细品味一下**.** 泊松回归,也被称为对数线性模型,当结果变量是一个计数(即数值型,但不像连续变量的范围那么大)时,使用泊松 ...

  3. 泊松回归与类泊松回归(《R语言实践(第二版)》)

    泊松回归与类泊松回归 0. 背景介绍 0.1 泊松回归: 0.2 本示例要做的事: 1.导包 2.导入数据 3.作图 4. 拟合泊松回归: 4.1解释模型参数 4.2 检验过度离势(Overdispe ...

  4. matlab泊松回归程序,R - 泊松回归( Poisson Regression)

    R - 泊松回归( Poisson Regression) 泊松回归涉及回归模型,其中响应变量是计数而不是分数的形式. 例如,足球比赛系列中的出生人数或获胜次数. 此外,响应变量的值遵循泊松分布. 泊 ...

  5. R语言广义线性模型函数GLM、R中有几种泊松回归扩展和变异、变时段泊松回归、零膨胀泊松回归、鲁棒泊松回归、pscl包的zeroinfl拟合零膨胀泊松回归、robust包中的glmRob函数拟合鲁棒模型

    R语言广义线性模型函数GLM.glm函数构建泊松回归模型.R中有几种泊松回归扩展和变异.变时段泊松回归.零膨胀泊松回归.鲁棒泊松回归.pscl包的zeroinfl拟合零膨胀泊松回归.robust包中的 ...

  6. R语言广义线性模型函数GLM、glm函数构建泊松回归模型、模型中存在过离散(Overdispersion)、则将连接函数从possion函数替换为quasipoisson函数重新构建泊松回归模型

    R语言广义线性模型函数GLM.glm函数构建泊松回归模型(Poisson regression).模型中存在过离散(Overdispersion).则将连接函数从possion函数替换为quasipo ...

  7. Lasso 和 Ridge回归中的超参数调整技巧

    在这篇文章中,我们将首先看看Lasso和Ridge回归中一些常见的错误,然后我将描述我通常采取的步骤来优化超参数.代码是用Python编写的,我们主要依赖scikit-learn.本文章主要关注Las ...

  8. R语言泊松回归对保险定价建模中的应用:风险敞口作为可能的解释变量

    最近我们被客户要求撰写关于保险定价建模的研究报告,包括一些图形和统计输出. 在保险定价中,风险敞口通常用作模型索赔频率的补偿变量.如果我们必须使用相同的程序,但是一个程序的暴露时间为6个月,而另一个则 ...

  9. 用于时间序列数据的泊松回归模型

    泊松和类泊松回归模型常用于基于计数的数据集,即包含整数计数的数据.例如,每小时走进医院急诊室的人数就是一个这样的数据集. 基于普通最小二乘回归的线性模型或非线性模型(例如基于基于神经网络的回归技术的线 ...

最新文章

  1. python 自动化办公 案例_python自动化工具之pywinauto实例详解
  2. 一分钟在Linux环境下创建一台SFTP服务器(含账户创建)
  3. [傅里叶变换及其应用学习笔记] 二十六. 高维傅里叶变换的推导
  4. 【软考】2017年11月软件设计师上午真题9-12题答案解析
  5. 计算未来轻沙龙 | AI=知识+推理,知识工程与数据管理专场来了!
  6. Linux查看Bios信息
  7. phpmyadmin登录远程mysql数据库
  8. 服务器是多用户服务的计算机,Win10权限管理与多用户远程登录(多方案)
  9. LeetCode:Permutations, Permutations II(求全排列)
  10. 隐马尔可夫模型python_隐马尔可夫模型HMM及Python实现
  11. 第六章 多元函数微分学
  12. 年薪五万程序员的生活及他的理财梦
  13. RK3288 Android5.1 隐藏 蓝牙网络共享与移动网络设置项
  14. 玩《刀塔传奇》,玩的就是一种策略
  15. orcad的噪声分析
  16. 计算机专业考研集成电路,准备考研,“控制科学与工程”与“集成电路”,该怎么选?...
  17. 网页服务器版本,华为网页版本进云服务器
  18. VirtualBox找不到桥接网卡问题解决
  19. Google play ASO 关键字指南
  20. 金仓数据库KingbaseES使用ksql连接时,密码含有特殊字符时报错认证失败

热门文章

  1. 伍迷创意随想集 之 爱情博物馆
  2. python hexdump_Python hexdump包_程序模块 - PyPI - Python中文网
  3. IIS建网站以及建FTP
  4. CRM项目(SSM)总结
  5. 【太平轮(上)】下载
  6. [小说]时光。记忆(非学术)
  7. 泛微协同OA农业电子商务解决方案
  8. sshclient上传文件报错:encountered 1 errors during the transfer解决方法
  9. linux中setfacl命令,Linux 中的Setfacl命令
  10. 学生信息管理系统 —— 前端篇