R中负二项式回归的警告消息前进和后退

如何解决R中负二项式回归的警告消息前进和后退

我正在做一些计数数据分析。数据在此链接中: [1]:https://www.dropbox.com/s/q7fwqicw3ebvwlg/stackquestion.csv?dl=0

列A为计数数据,其他列为自变量。最初,我使用Poisson回归对其进行分析:

m0<-glm(A~.,data=d,family="poisson")
summary(m0)
#We see that the residual deviance is greater than the degrees of freedom so that we have over-dispersion. 

Call:
glm(formula = A ~ .,family = "poisson",data = d)

Deviance Residuals: 
     Min        1Q    Median        3Q       Max  
-28.8979   -4.5110    0.0384    5.4327   20.3809  

Coefficients:
              Estimate Std. Error z value Pr(>|z|)    
(Intercept)  8.7054842  0.9100882   9.566  < 2e-16 ***
B           -0.1173783  0.0172330  -6.811 9.68e-12 ***
C            0.0864118  0.0182549   4.734 2.21e-06 ***
D            0.1169891  0.0301960   3.874 0.000107 ***
E            0.0738377  0.0098131   7.524 5.30e-14 ***
F            0.3814588  0.0093793  40.670  < 2e-16 ***
G           -0.3712263  0.0274347 -13.531  < 2e-16 ***
H           -0.0694672  0.0022137 -31.380  < 2e-16 ***
I           -0.0634488  0.0034316 -18.490  < 2e-16 ***
J           -0.0098852  0.0064538  -1.532 0.125602    
K           -0.1105270  0.0128016  -8.634  < 2e-16 ***
L           -0.3304606  0.0155454 -21.258  < 2e-16 ***
M            0.2274175  0.0259872   8.751  < 2e-16 ***
N            0.2922063  0.0174406  16.754  < 2e-16 ***
O            0.1179708  0.0119332   9.886  < 2e-16 ***
P            0.0618776  0.0260646   2.374 0.017596 *  
Q           -0.0303909  0.0060060  -5.060 4.19e-07 ***
R           -0.0018939  0.0037642  -0.503 0.614864    
S            0.0383040  0.0065841   5.818 5.97e-09 ***
T            0.0318111  0.0116611   2.728 0.006373 ** 
U            0.2421129  0.0145502  16.640  < 2e-16 ***
V            0.1782144  0.0090858  19.615  < 2e-16 ***
W           -0.5105135  0.0258136 -19.777  < 2e-16 ***
X           -0.0583590  0.0043641 -13.373  < 2e-16 ***
Y           -0.1554609  0.0042604 -36.489  < 2e-16 ***
Z            0.0064478  0.0001184  54.459  < 2e-16 ***
AA           0.3880479  0.0164929  23.528  < 2e-16 ***
AB           0.1511362  0.0050471  29.945  < 2e-16 ***
AC           0.0557880  0.0181129   3.080 0.002070 ** 
AD          -0.6569099  0.0368771 -17.813  < 2e-16 ***
AE          -0.0040679  0.0003960 -10.273  < 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: 97109.0  on 56  degrees of freedom
Residual deviance:  5649.7  on 26  degrees of freedom
AIC: 6117.1

Number of Fisher Scoring iterations: 6

然后我认为我应该对过度分散数据使用负二项式回归。如您所见,我有许多自变量,所以我想选择重要的变量。我决定使用逐步回归来选择自变量。首先,我创建一个完整的模型:

full.model <- glm.nb(A~.,maxit=1000)
# when not indicating maxit,or maxit=100,it shows Warning messages: 1: glm.fit: algorithm did not converge; 2: In glm.nb(A ~ .,data = d,maxit = 100) : alternation limit reached
# When indicating maxit=1000,the warning message disappear.

summary(full.model)

Call:
glm.nb(formula = A ~ .,maxit = 1000,init.theta = 2.730327193,link = log)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-2.5816  -0.8893  -0.3177   0.4882   1.9073  

Coefficients:
              Estimate Std. Error z value Pr(>|z|)   
(Intercept) 11.8228596  8.3004322   1.424  0.15434   
B           -0.2592324  0.1732782  -1.496  0.13464   
C            0.2890696  0.1928685   1.499  0.13393   
D            0.3136262  0.3331182   0.941  0.34646   
E            0.3764257  0.1313142   2.867  0.00415 **
F            0.3257785  0.1448082   2.250  0.02447 * 
G           -0.7585881  0.2343529  -3.237  0.00121 **
H           -0.0714660  0.0343683  -2.079  0.03758 * 
I           -0.1050681  0.0357237  -2.941  0.00327 **
J            0.0810292  0.0566905   1.429  0.15291   
K            0.2582978  0.1574582   1.640  0.10092   
L           -0.2009784  0.1543773  -1.302  0.19296   
M           -0.2359658  0.3216941  -0.734  0.46325   
N           -0.0689036  0.1910518  -0.361  0.71836   
O            0.0514983  0.1383610   0.372  0.70974   
P            0.1843138  0.3253483   0.567  0.57105   
Q            0.0198326  0.0509651   0.389  0.69717   
R            0.0892239  0.0459729   1.941  0.05228 . 
S           -0.0430981  0.0856391  -0.503  0.61479   
T            0.2205653  0.1408009   1.567  0.11723   
U            0.2450243  0.1838056   1.333  0.18251   
V            0.1253683  0.0888411   1.411  0.15820   
W           -0.4636739  0.2348172  -1.975  0.04831 * 
X           -0.0623290  0.0508299  -1.226  0.22011   
Y           -0.0939878  0.0606831  -1.549  0.12142   
Z            0.0019530  0.0015143   1.290  0.19716   
AA          -0.2888123  0.2449085  -1.179  0.23829   
AB           0.1185890  0.0696343   1.703  0.08856 . 
AC          -0.3401963  0.2047698  -1.661  0.09664 . 
AD          -1.3409002  0.4858741  -2.760  0.00578 **
AE          -0.0006299  0.0051338  -0.123  0.90234   
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

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

    Null deviance: 516.494  on 56  degrees of freedom
Residual deviance:  61.426  on 26  degrees of freedom
AIC: 790.8

Number of Fisher Scoring iterations: 1


              Theta:  2.730 
          Std. Err.:  0.537 

 2 x log-likelihood:  -726.803 

当未指示maxit或maxit = 100时,它显示警告消息:1:glm.fit:算法未收敛; 2:在glm.nb(A〜。,data = d,maxit = 100)中:达到交替极限。 当指示maxit = 1000时,警告消息消失。

然后我创建第一个模型:

first.model <- glm.nb(A ~ 1,data = d)

然后我尝试了逐步逐步回归:

step.model <- step(first.model,direction="forward",scope=formula(full.model))
#Error in glm.fit(X,y,wt,offset = offset,family = object$family,control = object$control) : 
#NA/NaN/Inf in 'x'
#In addition: Warning message:
#  step size truncated due to divergence 
#What is the problem?

它给我错误消息:glm.fit(X,y,wt,offset = offset,family = object $ family,control = object $ control)中的错误: NA / NaN / Inf in'x' 另外:警告消息: 步长因差异而被截断

我还尝试了向后回归:

step.model2 <- step(full.model,direction="backward")

#the final step
Step:  AIC=770.45
A ~ B + C + E + F + G + H + I + K + L + R + T + V + W + Y + AA + 
    AB + AD

       Df Deviance    AIC
<none>      62.375 770.45
- AB    1   64.859 770.93
- H     1   65.227 771.30
- V     1   65.240 771.31
- L     1   65.291 771.36
- Y     1   65.831 771.90
- B     1   66.051 772.12
- C     1   67.941 774.01
- AA    1   69.877 775.95
- K     1   70.411 776.48
- W     1   71.526 777.60
- I     1   71.863 777.94
- E     1   72.338 778.41
- G     1   73.344 779.42
- F     1   73.510 779.58
- AD    1   79.620 785.69
- R     1   80.358 786.43
- T     1   95.725 801.80
Warning messages:
1: glm.fit: algorithm did not converge 
2: glm.fit: algorithm did not converge 
3: glm.fit: algorithm did not converge 
4: glm.fit: algorithm did not converge 

我的问题是:为什么在使用正向和反向逐步回归时会有所不同?为什么执行向前选择时出现错误消息?另外,这些警告消息到底是什么意思?而我应该如何处理呢?

我不是统计人员,但需要对我的研究数据进行静态分析。因此,我正在努力学习如何使用实际数据进行不同的回归分析。我在网上搜索了类似的问题,但我仍然可以理解...并且,如果我在回归分析中做错了什么,请告诉我。如果您能帮助我解决这些问题,我将不胜感激!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-