警告 glmer:GLMM 失败

如何解决警告 glmer:GLMM 失败

我必须运行一个带有连续响应变量的 glmer,两个变量作为固定效应和随机效应:

       glmer.1 <- glmer(Conc ~ Metodo * Kit +
               (1|Especie),data = Input_2,family = Gamma(link = "inverse"))

我收到此警告消息:

           Warning messages:
           1: In checkConv(attr(opt,"derivs"),opt$par,ctrl = control$checkConv,:
           Model failed to converge with max|grad| = 0.0652105 (tol = 0.002,component 1)
           2: In checkConv(attr(opt,:
           Model is nearly unidentifiable: very large eigenvalue
            - Rescale variables?

我使用 bobyqa() 作为优化参数进行了尝试,并收到了以下警告消息:

           glmer.Conc<-glmer(Conc ~ Metodo * Kit 
              +  (1 | Especie),control = glmerControl(optimizer = "bobyqa"),family = Gamma)

           Warning messages:
           1: In checkConv(attr(opt,:
             Model failed to converge with max|grad| = 0.0747655 (tol = 0.002,:
             Model is nearly unidentifiable: very large eigenvalue
            - Rescale variables?

我的总结如下:

            summary(glmer.1)
            Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']                                                
             Family: Gamma  ( inverse )
            Formula: Conc ~ Metodo * Kit + (1 | Especie)
               Data: Input_2

                 AIC      BIC   logLik deviance df.resid 
              3202.0   3223.6  -1595.0   3190.0      264 

            Scaled residuals: 
                Min      1Q  Median      3Q     Max 
            -0.7347 -0.5647 -0.2876  0.2740 12.0396 

            Random effects:
             Groups   Name        Variance  Std.Dev.
             Especie  (Intercept) 5.264e-05 0.007256
             Residual             1.724e+00 1.313030
            Number of obs: 270,groups:  Especie,6

            Fixed effects:
                          Estimate Std. Error t value Pr(>|z|)   
            (Intercept)  0.0089191  0.0028893   3.087  0.00202 **
            Metodo      -0.0002581  0.0009247  -0.279  0.78013   
            Kit         -0.0009974  0.0007818  -1.276  0.20203   
            Metodo:Kit   0.0007497  0.0004608   1.627  0.10380   
            ---
            Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

            Correlation of Fixed Effects:
                       (Intr) Metodo Kit   
            Metodo     -0.531              
            Kit        -0.531  0.857       
            Metodo:Kit  0.449 -0.907 -0.897
            convergence code: 0
            Model failed to converge with max|grad| = 0.0652105 (tol = 0.002,component 1)
            Model is nearly unidentifiable: very large eigenvalue
             - Rescale variables?

Especie 代表物种的类型,metodo 和 kit 代表使用什么类型的方法和试剂盒获得浓度,Conc 是浓度值

我的数据框如下所示:

             Input_2 <- readr::read_table2("Especie Metodo  Kit Conc    A1  A2
                1   1   1   70.4    1.5 0.9
                1   1   1   57.2    1.7 1.4
                1   1   1   22.2    1.6 1.1
                1   1   1   60.6    1.5 0.9
                1   1   1   50.2    1.6 1
                1   1   2   40.5    2.1 1.7
                1   1   2   86.6    2.1 2.1
                1   1   2   53.9    1.8 1.3
                1   1   2   50.3    1.9 0.2
                1   1   2   44.1    2   1.5
                1   1   3   159.1   2.1 2.3
                1   1   3   246 2.1 2.4
                1   1   3   81.5    2   1.3
                1   1   3   107.9   2.1 1.9
                1   1   3   125 2   1.7
                1   2   1   72.9    1.6 1.1
                1   2   1   38.1    1.6 1.1
                1   2   1   8.3 1.3 1.8
                1   2   1   31  1.6 0.8
                1   2   1   36.3    1.3 1.2
                1   2   2   16.8    1.9 1.8
                1   2   2   4.8 2.2 1
                1   2   2   20.4    1.4 1
                1   2   2   31.8    1.9 0.4
                1   2   2   5   1.6 1
                1   2   3   17.9    2   2.2
                1   2   3   14.9    2.6 2.5
                1   2   3   5.3 1.6 0.5
                1   2   3   17.1    2.2 1.3
                1   2   3   17.1    1.9 1
                1   3   1   67.3    1.6 1
                1   3   1   11.3    1.4 0.7
                1   3   1   4.2 1   1
                1   3   1   9.7 1.1 0.8
                1   3   1   20  1.4 0.8
                1   3   2   4.3 1.4 1.3
                1   3   2   4.1 1.6 2
                1   3   2   11.4    1.5 0.3
                1   3   2   12.5    1.4 0.2
                1   3   2   11  1.5 0.9
                1   3   3   59.7    1.9 2.4
                1   3   3   81.4    2.3 2.4
                1   3   3   32.2    1.9 1.6
                1   3   3   24.9    1.8 1.2
                1   3   3   50.9    2.1 1.2
                2   1   1   185 1.6 1
                2   1   1   146.2   1.7 1.2
                2   1   1   239 1.8 1.4
                2   1   1   141.9   2   2
                2   1   1   303.7   1.9 1.8
                2   1   2   53.6    1.9 0.6
                2   1   2   424.8   2.1 1.5
                2   1   2   30.3    1.9 0.4
                2   1   2   291 2.1 1.5
                2   1   2   471.6   2.1 2.1
                2   1   3   132.8   1.9 1.4
                2   1   3   124.5   2.1 1.7
                2   1   3   484.4   2.1 2.1
                2   1   3   251.3   2.2 2.2
                2   1   3   598.6   2.1 2.2
                2   2   1   15.6    1.4 0.9
                2   2   1   107.6   1.7 1.1
                2   2   1   172.2   1.8 1.6
                2   2   1   210.2   1.9 1.9
                2   2   1   699.7   2   2.2
                2   2   2   20  1.7 0.2
                2   2   2   86.2    2   0.9
                2   2   2   36.8    2.1 0.3
                2   2   2   434.4   2.1 2.3
                2   2   2   209.5   2.2 1.5
                2   2   3   37  2.1 1.6
                2   2   3   94.8    2.1 1.8
                2   2   3   220.2   2.2 2.1
                2   2   3   17.7    2.3 0.8
                2   2   3   145.3   2.1 1.9
                2   3   1   33.4    1.5 0.8
                2   3   1   87  1.7 1.2
                2   3   1   98.9    1.8 1.8
                2   3   1   176.6   2   2.2
                2   3   1   180.7   1.9 1.9
                2   3   2   20.8    1.8 0.3
                2   3   2   226.2   2.1 1.1
                2   3   2   227.8   2.1 1.7
                2   3   2   40.8    2.1 0.4
                2   3   2   83.4    2.1 0.9
                2   3   3   35.7    2.1 1.2
                2   3   3   191.9   2.1 1.8
                2   3   3   203.2   2.2 2.2
                2   3   3   143.3   2.2 2
                2   3   3   70.7    2.1 1.7
                3   1   1   190.7   2.1 2
                3   1   1   456.5   2   2.2
                3   1   1   520.9   2   2.2
                3   1   1   535.5   2   2.1
                3   1   1   894.3   2   2.3
                3   1   2   265.2   2.1 1.7
                3   1   2   392.2   2.1 2.3
                3   1   2   241.3   2.1 1.4
                3   1   2   156.9   2.1 1.7
                3   1   2   277.2   2.1 1.7
                3   1   3   431.6   2.1 2.1
                3   1   3   669.9   2.2 2.3
                3   1   3   342.5   2.1 2.1
                3   1   3   572.3   2.1 2.2
                3   1   3   435.2   2.1 2.1
                3   2   1   498.6   2   2.1
                3   2   1   1137.2  2.1 2.3
                3   2   1   764.5   2.1 2.3
                3   2   1   746.4   2.1 2.2
                3   2   1   737.2   2.1 2.2
                3   2   2   98.1    2   1.4
                3   2   2   237.9   2.1 2.2
                3   2   2   144 2   1.2
                3   2   2   240.3   2.1 2.1
                3   2   2   253.4   2.1 1.8
                3   2   3   247.3   2.2 1.7
                3   2   3   155.3   2.1 1.8
                3   2   3   179.3   2.2 1.6
                3   2   3   225.7   2.1 2.2
                3   2   3   274.4   2.1 2.1
                3   3   1   944.9   2.1 2.3
                3   3   1   978.4   2.1 2.3
                3   3   1   785.9   2   2.1
                3   3   1   510.7   2   2.1
                3   3   1   164.5   2   2.2
                3   3   2   48.1    2   0.3
                3   3   2   427.7   2.1 2.2
                3   3   2   75  2   0.9
                3   3   2   153 2.1 1.3
                3   3   2   293.8   2.1 2.4
                3   3   3   335.8   2.1 1.9
                3   3   3   395.5   2.1 2.1
                3   3   3   181.1   2.1 1.9
                3   3   3   468.4   2.1 2.2
                3   3   3   348 2.1 2.1
                4   1   1   335.8   2   1.9
                4   1   1   188.1   1.9 1.5
                4   1   1   219 2   2
                4   1   1   104.1   1.9 1.3
                4   1   1   273.7   2   2
                4   1   2   573.2   2.2 1.8
                4   1   2   115.3   2.1 2.1
                4   1   2   56.7    2   0.4
                4   1   2   316.5   2.1 1.6
                4   1   2   85.2    2.1 1.9
                4   1   3   585 2.2 2.3
                4   1   3   377.5   2.1 2
                4   1   3   47.1    2.1 1.6
                4   1   3   73.1    2   1.4
                4   1   3   91.9    2   1.2
                4   2   1   374.8   2   1.7
                4   2   1   85.8    1.9 1.9
                4   2   1   53.1    1.8 1.8
                4   2   1   34.3    1.8 1.1
                4   2   1   27  1.9 1.1
                4   2   2   182.9   2.1 1.3
                4   2   2   25.3    1.8 0.4
                4   2   2   4.4 2.4 0.1
                4   2   2   117.8   2.2 2.1
                4   2   2   6.6 1.9 0.8
                4   2   3   158.9   2.2 2.2
                4   2   3   44.5    2   1
                4   2   3   12.6    1.7 0.5
                4   2   3   22.5    2.3 1
                4   2   3   91  2   1.3
                4   3   1   212.1   1.7 1.2
                4   3   1   101.7   1.9 1.8
                4   3   1   63.4    1.4 0.9
                4   3   1   67.9    1.8 1.3
                4   3   1   40.4    1.6 0.9
                4   3   2   73  2.1 0.9
                4   3   2   33.1    2.1 0.6
                4   3   2   7.8 2   0.3
                4   3   2   10.9    1.9 1.4
                4   3   2   11.6    2   0.2
                4   3   3   382.8   2.2 2.3
                4   3   3   7   2.4 0.4
                4   3   3   13.1    2   0.7
                4   3   3   24.7    2.2 1.1
                4   3   3   42.9    2   0.9
                5   1   1   340 1.4 0.9
                5   1   1   48.6    1.5 0.6
                5   1   1   53.7    1.4 0.6
                5   1   1   33.3    1.3 0.5
                5   1   1   86  1.3 0.5
                5   1   2   11.4    1.4 0.5
                5   1   2   27  1.6 1
                5   1   2   33.7    1.7 0.9
                5   1   2   14.2    1.8 1.3
                5   1   2   16.2    1.9 0.8
                5   1   3   606 1.6 0.7
                5   1   3   265.8   1.7 1
                5   1   3   73.5    1.5 2.6
                5   1   3   189 1.6 0.7
                5   1   3   223.1   1.6 0.7
                5   2   1   101.5   1.5 0.6
                5   2   1   7.2 1.2 0.5
                5   2   1   49.7    1.4 0.7
                5   2   1   61.9    1.5 0.6
                5   2   1   6.9 1.1 0.6
                5   2   2   20.6    1.4 0.7
                5   2   2   13.7    1.7 1
                5   2   2   48.5    1.8 1
                5   2   2   6.8 1.6 0.7
                5   2   2   5.7 1.3 0.7
                5   2   3   239.5   1.7 0.8
                5   2   3   152.5   1.7 0.8
                5   2   3   2065.4  1.5 1
                5   2   3   112.7   1.6 0.6
                5   2   3   104.5   1.6 0.7
                5   3   1   40.7    1.3 0.5
                5   3   1   82  1.4 0.9
                5   3   1   20.6    1.3 1
                5   3   1   21.4    1.4 0.6
                5   3   1   29.6    1.4 0.6
                5   3   2   4.3 1.1 0.5
                5   3   2   38.5    1.3 1.3
                5   3   2   22.9    1.7 1.1
                5   3   2   10.3    1.7 1
                5   3   2   4.9 1.3 0.6
                5   3   3   216.8   1.7 0.8
                5   3   3   220.7   1.7 0.9
                5   3   3   51.8    1.3 1.3
                5   3   3   161 1.6 0.7
                5   3   3   144.4   1.6 0.6
                6   1   1   79.9    2.1 1.8
                6   1   1   295.3   2.1 2.1
                6   1   1   136.4   2.1 2.1
                6   1   1   177.3   2   2.1
                6   1   1   116.4   1.7 1.1
                6   1   2   93.1    2.1 2.2
                6   1   2   385.9   2.1 2.3
                6   1   2   318.6   2.1 1.8
                6   1   2   20.3    2.1 1.4
                6   1   2   131.5   2.1 1.4
                6   1   3   53.9    2.2 2.7
                6   1   3   156.9   2.2 1.8
                6   1   3   344.7   2.1 2
                6   1   3   15.5    2.6 0.6
                6   1   3   33.7    2.1 1.3
                6   2   1   137.8   1.8 1.2
                6   2   1   104 2.1 2
                6   2   1   151.7   2.1 2
                6   2   1   15.4    2.1 1.6
                6   2   1   31.5    1.9 2.1
                6   2   2   8   2.1 1.5
                6   2   2   23.9    2   0.9
                6   2   2   14.8    2.2 0.4
                6   2   2   8.6 1.8 0.4
                6   2   2   18.2    2.2 0.3
                6   2   3   35  2.2 2.7
                6   2   3   61  2.2 1.7
                6   2   3   136.9   2.1 2.3
                6   2   3   3.1 8.5 0.2
                6   2   3   8.7 1.6 1.1
                6   3   1   155.7   2   2.2
                6   3   1   48.5    1.7 0.9
                6   3   1   77.7    2   1.5
                6   3   1   45.6    1.6 1.2
                6   3   1   142 1.6 1.1
                6   3   2   5.6 1.4 1.3
                6   3   2   7.4 2.2 0.1
                6   3   2   66.4    1.9 1.4
                6   3   2   6.8 2.3 0.7
                6   3   2   10.3    1.9 2.2
                6   3   3   42.9    2.1 2.5
                6   3   3   48.3    2.3 1.2
                6   3   3   62.6    2.3 1.4
                6   3   3   6.9 2.2 0.3
                6   3   3   3.9 1.8 0.5")

我是否忘记了要包含在 GLMM 中的任何内容?谢谢!

编辑 1:

我已将 Method 和 Kit 变量转换为因子格式:

           Input_2$Metodo<-as.factor(Input_2$Metodo)

           Input_2$Kit<-as.factor(Input_2$Kit)

获得不同的变暖:

               Warning messages:
               1: In checkConv(attr(opt,:
               Model failed to converge with max|grad| = 0.00649539 (tol = 0.002,component 1)
               2: In checkConv(attr(opt,:
                Model is nearly unidentifiable: very large eigenvalue
                - Rescale variables?

我该如何解决这些问题?

根据建议,我尝试重新调整我的价值观:

            numcols <- grep("^c\\.",names(Input_2))
            dfs <- Input_2
            dfs[,numcols] <- scale(dfs[,numcols])
            m1_sc <- update(glmer.1,data=dfs)

           Obtaining the next warming message:

           Warning messages:
           1: In checkConv(attr(opt,:
           Model failed to converge with max|grad| = 0.00649539 (tol = 0.002,component                1)
           2: In checkConv(attr(opt,:
             Model is nearly unidentifiable: very large eigenvalue
            - Rescale variables?

Edit2:根据建议,我删除了我的交互 * for + 此外,我已将物种列转换为一个因子:

           Input_2$Especie<-as.factor(Input_2$Especie)

           glmer.1 <- glmer(Conc ~ Metodo + Kit +
                              (1|Especie),family = Gamma(link = "inverse"))

然后我得到下一次变暖:

         Warning messages:
         1: In checkConv(attr(opt,:
           Model failed to converge with max|grad| = 0.00513611 (tol = 0.002,component 1)
         2: In checkConv(attr(opt,:
           Model is nearly unidentifiable: very large eigenvalue
          - Rescale variables?

第二个建议是将 glmer 更改为 glm 以查看模型是否因更简单的策略而饱和(因为 glm 需要固定所有因子,我将物种变量更改为固定因子):

                   glmer.1 <- glm(Conc ~ Metodo + Kit +Especie,family = Gamma(link = "inverse"))

当我执行它时,我没有问题。

如何使用 glmer 解决这些问题?我的错误是什么?

提前致谢

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 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-