[R-sig-ME] Convergence Issue

Phillip Alday me @end|ng |rom ph||||p@|d@y@com
Thu Sep 2 22:06:38 CEST 2021


Why not just use a contrast coding scheme that represents your
hypotheses directly in the model rather than computing them post-hoc
with emmeans? That's both a general commentary on scientific practice
and relevant advice for this situation because emmeans may struggle with
a model that's having some convergence issues. (I agree with Ben though
-- all the optimizers gave the same answer, so you're probably fine with
the result.)


On 02/09/2021 11:54, Alex Waldman wrote:
> Thanks! I plotted the fixed-effect estimates and CIs and they all look quite similar (attached). Since I'm interested in extracting the marginal means with emmeans and performing contrasts, I guess I shouldn't worry?
>
> Warm Regards,
> Alex
>
> On 9/2/21, 5:04 PM, "R-sig-mixed-models on behalf of Ben Bolker" <r-sig-mixed-models-bounces using r-project.org on behalf of bbolker using gmail.com> wrote:
>
>        Without digging in deeply: the results across optimizers all look 
>     very similar to each other, so unless you need extremely precise answers 
>     I would say everything's OK.
>
>        You could dig in further to look at the fixed-effect estimates (if 
>     that's what you're interested in) in conjunction with the approximate 
>     (Wald) confidence intervals, e.g.:
>
>     library(lme4)
>     library(broom.mixed)
>     library(purrr)
>     library(ggplot2)
>
>     gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
>                         data = cbpp, family = binomial)
>     aa <- allFit(gm1)
>
>     tt <- purrr::map_dfr(aa, tidy, effect = "fixed", .id="optimizer")
>     ggplot(tt, aes(x=term, y=estimate, ymin=estimate-2*std.error,
>              ymax =    estimate+2*std.error, colour=optimizer)) +
>               geom_pointrange(position=position_dodge(width=0.25))
>
>        (with apologies to people who are allergic to the tidyverse)
>
>
>     On 9/2/21 11:32 AM, Alex Waldman wrote:
>     > Thank you! This was helpful.
>     > 
>     > When I tried double-checking the Hessian calculation, I got the following error:
>     > 
>     > Error in chol.default(hess) : the leading minor of order 6 is not positive definite
>     > 
>     > Could this provide any indication as to why the model isn't converging?
>     > 
>     > I also tested all the optimizers and got the following result but was unsure how to interpret:
>     > 
>     > $which.OK
>     >                         bobyqa                   Nelder_Mead
>     >                           TRUE                          TRUE
>     >                     nlminbwrap                         nmkbw
>     >                           TRUE                          TRUE
>     >                optimx.L-BFGS-B nloptwrap.NLOPT_LN_NELDERMEAD
>     >                           TRUE                          TRUE
>     >      nloptwrap.NLOPT_LN_BOBYQA
>     >                           TRUE
>     > 
>     > $msgs
>     > $msgs$bobyqa
>     > NULL
>     > 
>     > $msgs$Nelder_Mead
>     > [1] "Model failed to converge with max|grad| = 0.0555727 (tol = 0.002, component 1)"
>     > 
>     > $msgs$nlminbwrap
>     > NULL
>     > 
>     > $msgs$nmkbw
>     > [1] "Model failed to converge with max|grad| = 0.0083782 (tol = 0.002, component 1)"
>     > 
>     > $msgs$`optimx.L-BFGS-B`
>     > NULL
>     > 
>     > $msgs$nloptwrap.NLOPT_LN_NELDERMEAD
>     > NULL
>     > 
>     > $msgs$nloptwrap.NLOPT_LN_BOBYQA
>     > [1] "Model failed to converge with max|grad| = 0.0122376 (tol = 0.002, component 1)"
>     > 
>     > 
>     > $fixef
>     >                                (Intercept)     Level1     Level2 LesionType1 LesionType2
>     > bobyqa                          -1.607709 -0.5906779 -0.7133361    1.633654    1.169556
>     > Nelder_Mead                     -1.609343 -0.5990970 -0.7248756    1.637308    1.166614
>     > nlminbwrap                      -1.607742 -0.5906431 -0.7133012    1.633691    1.169589
>     > nmkbw                           -1.612150 -0.5911478 -0.7154765    1.638517    1.173022
>     > optimx.L-BFGS-B                 -1.612203 -0.5921513 -0.7152118    1.638355    1.173146
>     > nloptwrap.NLOPT_LN_NELDERMEAD   -1.612326 -0.5921231 -0.7148693    1.638615    1.173143
>     > nloptwrap.NLOPT_LN_BOBYQA       -1.608554 -0.5974722 -0.7194175    1.634395    1.169306
>     >                                Level1:LesionType1 Level2:LesionType1 Level1:LesionType2
>     > bobyqa                                -0.3646982         -0.2118206          0.3897427
>     > Nelder_Mead                           -0.3570757         -0.2053771          0.4027594
>     > nlminbwrap                            -0.3647408         -0.2118542          0.3897106
>     > nmkbw                                 -0.3675755         -0.2125293          0.3896785
>     > optimx.L-BFGS-B                       -0.3660791         -0.2125631          0.3904246
>     > nloptwrap.NLOPT_LN_NELDERMEAD         -0.3663036         -0.2131734          0.3905315
>     > nloptwrap.NLOPT_LN_BOBYQA             -0.3597335         -0.2075374          0.3969647
>     >                                Level2:LesionType2
>     > bobyqa                                 0.1426930
>     > Nelder_Mead                            0.1586086
>     > nlminbwrap                             0.1426555
>     > nmkbw                                  0.1436730
>     > optimx.L-BFGS-B                        0.1426133
>     > nloptwrap.NLOPT_LN_NELDERMEAD          0.1423522
>     > nloptwrap.NLOPT_LN_BOBYQA              0.1474815
>     > 
>     > $llik
>     >                         bobyqa                   Nelder_Mead
>     >                      -530.1908                     -530.1818
>     >                     nlminbwrap                         nmkbw
>     >                      -530.1908                     -530.1810
>     >                optimx.L-BFGS-B nloptwrap.NLOPT_LN_NELDERMEAD
>     >                      -530.1810                     -530.1810
>     >      nloptwrap.NLOPT_LN_BOBYQA
>     >                      -530.1812
>     > 
>     > $sdcor
>     >                                ID.(Intercept)
>     > bobyqa                              1.227682
>     > Nelder_Mead                         1.232220
>     > nlminbwrap                          1.227685
>     > nmkbw                               1.231678
>     > optimx.L-BFGS-B                     1.231639
>     > nloptwrap.NLOPT_LN_NELDERMEAD       1.231837
>     > nloptwrap.NLOPT_LN_BOBYQA           1.231765
>     > 
>     > $theta
>     >                                ID.(Intercept)
>     > bobyqa                              1.227682
>     > Nelder_Mead                         1.232220
>     > nlminbwrap                          1.227685
>     > nmkbw                               1.231678
>     > optimx.L-BFGS-B                     1.231639
>     > nloptwrap.NLOPT_LN_NELDERMEAD       1.231837
>     > nloptwrap.NLOPT_LN_BOBYQA           1.231765
>     > 
>     > $times
>     >                                user.self sys.self elapsed user.child sys.child
>     > bobyqa                            0.633    0.003   0.638          0         0
>     > Nelder_Mead                       2.401    0.003   2.405          0         0
>     > nlminbwrap                        0.581    0.001   0.585          0         0
>     > nmkbw                             0.885    0.004   0.894          0         0
>     > optimx.L-BFGS-B                   1.390    0.005   1.407          0         0
>     > nloptwrap.NLOPT_LN_NELDERMEAD     0.976    0.003   0.984          0         0
>     > nloptwrap.NLOPT_LN_BOBYQA         0.996    0.002   1.004          0         0
>     > 
>     > $feval
>     >                         bobyqa                   Nelder_Mead
>     >                            572                          2605
>     >                     nlminbwrap                         nmkbw
>     >                             NA                           728
>     >                optimx.L-BFGS-B nloptwrap.NLOPT_LN_NELDERMEAD
>     >                             44                           904
>     >      nloptwrap.NLOPT_LN_BOBYQA
>     >                            972
>     > 
>     > Warm Regards,
>     > Alex
>     > 
>     > On 9/2/21, 4:04 PM, "Phillip Alday" <me using phillipalday.com> wrote:
>     > 
>     >      I don't have time to give more thorough help at the moment, but look at
>     >      the help page on converge, accessible via ?convergence in R or mirrored
>     >      online, e.g. https://rdrr.io/cran/lme4/man/convergence.html
>     > 
>     >      Hope that helps
>     > 
>     >      Phillip
>     > 
>     >      On 02/09/2021 09:58, Alex Waldman wrote:
>     >      > Dear All,
>     >      >
>     >      > I have a dataset with 119 individuals with information on the presence of lesions of various types (1,2,3) at various levels (1,2,3) and want to understand the effect of type and location on lesion presence. Therefore, I ran the following:
>     >      >
>     >      > glmer.model<-glmer(LesionPresence ~ Location*Type + (1 | ID), data=lesion_proportion_staged_level, family="binomial")
>     >      >
>     >      > Unfortunately, I ran into the following warning:
>     >      >
>     >      > In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
>     >      > Model failed to converge with max|grad| = 0.048092 (tol = 0.002, component 1)
>     >      >
>     >      > I'm quite new to running mixed models and even with some googling am still unsure why I am running into this issue? Any insight would be much appreciated. I am attaching the model output below and the input data in case that is helpful and do let me know if you need any additional information:
>     >      > Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) [
>     >      > glmerMod]
>     >      > Family: binomial  ( logit )
>     >      > Formula: LesionPresence ~ Level * LesionType + (1 | ID)
>     >      >    Data: lesion_proportion_staged_level
>     >      >
>     >      >      AIC      BIC   logLik deviance df.resid
>     >      >   1080.4   1129.2   -530.2   1060.4      962
>     >      >
>     >      > Scaled residuals:
>     >      >     Min      1Q  Median      3Q     Max
>     >      > -1.6875 -0.5649 -0.3291  0.7170  4.2816
>     >      >
>     >      > Random effects:
>     >      > Groups Name        Variance Std.Dev.
>     >      > ID     (Intercept) 1.519    1.232
>     >      > Number of obs: 972, groups:  ID, 119
>     >      >
>     >      > Fixed effects:
>     >      >                    Estimate Std. Error z value Pr(>|z|)
>     >      > (Intercept)         -1.6081     0.2966  -5.423 5.87e-08 ***
>     >      > Level1              -0.6006     0.3900  -1.540 0.123600
>     >      > Level2              -0.7270     0.4094  -1.776 0.075782 .
>     >      > LesionType1          1.6362     0.3538   4.624 3.76e-06 ***
>     >      > LesionType2          1.1659     0.3524   3.309 0.000938 ***
>     >      > Level1:LesionType1  -0.3568     0.5022  -0.711 0.477379
>     >      > Level2:LesionType1  -0.2015     0.5211  -0.387 0.698986
>     >      > Level1:LesionType2   0.4030     0.5004   0.805 0.420607
>     >      > Level2:LesionType2   0.1608     0.5229   0.308 0.758387
>     >      > ---
>     >      > Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>     >      >
>     >      > Correlation of Fixed Effects:
>     >      >             (Intr) Level1 Level2 LsnTy1 LsnTy2 L1:LT1 L2:LT1 L1:LT2
>     >      > Level1      -0.603
>     >      > Level2      -0.574  0.447
>     >      > LesionType1 -0.703  0.498  0.475
>     >      > LesionType2 -0.694  0.503  0.479  0.582
>     >      > Lvl1:LsnTy1  0.480 -0.766 -0.339 -0.691 -0.400
>     >      > Lvl2:LsnTy1  0.461 -0.344 -0.775 -0.665 -0.385  0.466
>     >      > Lvl1:LsnTy2  0.468 -0.772 -0.344 -0.392 -0.692  0.598  0.268
>     >      > Lvl2:LsnTy2  0.453 -0.344 -0.773 -0.379 -0.665  0.267  0.607  0.468
>     >      > optimizer (Nelder_Mead) convergence code: 0 (OK)
>     >      > Model failed to converge with max|grad| = 0.048092 (tol = 0.002, component 1)
>     >      > _______________________________________________
>     >      > R-sig-mixed-models using r-project.org mailing list
>     >      > https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>     > 
>     > _______________________________________________
>     > R-sig-mixed-models using r-project.org mailing list
>     > https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>     > 
>
>     -- 
>     Dr. Benjamin Bolker
>     Professor, Mathematics & Statistics and Biology, McMaster University
>     Director, School of Computational Science and Engineering
>     Graduate chair, Mathematics & Statistics
>
>     _______________________________________________
>     R-sig-mixed-models using r-project.org mailing list
>     https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models



More information about the R-sig-mixed-models mailing list