0

This is the code I'm using which has the error message fails to converge

Q1glmm3<-lmer(log10.stock ~ log10.GDP +(log10.GDP|Area) + (Year|Area), data=LOG10.STOCK.VS.GDP.GLMM)

Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = 
control$checkConv,  :
  unable to evaluate scaled gradient
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = 
control$checkConv,  :
  Model failed to converge: degenerate  Hessian with 3 negative 
eigenvalues
3: Model failed to converge with 3 negative eigenvalues: -2.9e-02 
-1.5e+00 -2.7e+03 

I have also tried to center the GDP data, the model then wouldn't run and this is the error message

CenteredQ1M3<-lmer(Stock.Head ~ Centered.GDP + (Centered.GDP|Area) 
+ (Year|Area), data= Trial.LOG10.STOCK.VS.GDP.GLMM)
Error in initializePtr() : Downdated VtV is not positive definite
In addition: Warning message:
Some predictor variables are on very different scales: consider 
rescaling 

And when I scaled the data - although the model ran - this is the message I got:- Warning messages: 1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : unable to evaluate scaled gradient 2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model failed to converge: degenerate Hessian with 3 negative 3: Model failed to converge with 3 negative eigenvalues: -5.5e-02 -8.8e-02 -7.8e-01

The model did run - but this is the message I got at the bottom .. optimizer (nloptwrap) convergence code: 0 (OK) unable to evaluate scaled gradient Model failed to converge: degenerate Hessian with 3 negative eigenvalues

summary(STOCK.VS.GDP.GLMM)
Area                       Year        Stock.Head             GDP           
C\xf4te d'Ivoire:  11   Min.   :2010   Min.   :      111   Min.  :1.974e+08  
T\xfcrkiye      :  11   1st Qu.:2012   1st Qu.:   203234   1st Qu.:1.037e+10  
Afghanistan     :  11   Median :2015   Median :  1524580    Median :3.591e+10  
Albania         :  11   Mean   :2015   Mean   :  8025244   Mean   :4.703e+11  
Algeria         :  11   3rd Qu.:2018   3rd Qu.:  5540044   3rd Qu.:2.194e+11  
Angola          :  11   Max.   :2020   Max.   :218190768   Max.    :2.137e+13  
(Other)         :2022                                      NA's    :1          
           X       
            :2086  
     checked:   2  
    
TLG1
  • 1
  • 1

1 Answers1

0

It's hard to know exactly what's going on here without more info, but as a start:

The first warning you get ("Some predictor variables are on very different scales") comes up because your intercept is 13 orders of magnitude larger than your slope with respect to GDP (6e6 vs. -3e-7). This will very likely go away if you center and scale your GDP variable (see Schielzeth Methods in Ecology and Evolution 2010 for a nice introduction to the meaning and importance of scaling and centering). Scaling and centering may make other problems go away, too.

I've never seen your error from summary(): I would be very interested to see a reproducible example!

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • Thank you for your comments Ben - how do I attach a reproducible example? Excuse my ignorance, I'm very new to this and GLMM models! – TLG1 Feb 03 '23 at 06:46
  • Unfortunately it's not always easy for biggish data sets. `dput()` is good for small-to-medium, otherwise you can link to your data (if it's OK to make public). Do you still get the same problems with a small subset of the data? Can you include the results of `summary(STOCK.VS.GDP.GLMM)` in your question? https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Ben Bolker Feb 03 '23 at 13:45
  • I did try dput to insert data but got an error message I couldn't resolve. I then ran GLMM model again using Log10 transformed data, great, no Warning message but same error message using the random effect = (GDP|Area) which is - Error in vcov.merMod(object, use.hessian = use.hessian) : trying to get slot "factors" from an object of a basic class ("matrix") with no slots In addition: Warning message: In vcov.merMod(object, use.hessian = use.hessian) : Computed variance-covariance matrix problem: not a positive definite matrix; returning NA matrix – TLG1 Feb 04 '23 at 12:32
  • I would still love a reproducible example. Is there any chance you can share the data privately? – Ben Bolker Feb 04 '23 at 19:43
  • how about `table(table(STOCK.VS.GDP.GLMM$Area))` ? – Ben Bolker Feb 04 '23 at 19:44
  • Hi Ben yes absolutely - no problem to share any or all of the data - shall I email it to you? Or can I attach the csv file here? Whatever you prefer? – TLG1 Feb 05 '23 at 15:35
  • How big is it? ... – Ben Bolker Feb 05 '23 at 15:37
  • > table(table(STOCK.VS.GDP.GLMM$Area)) 2 9 11 1 2 188 – TLG1 Feb 05 '23 at 17:45
  • the STOCK.VS.GDP.GLMM is 90KB and the one with the additional Log10 transformed data, which I ended up using, is 123KB – TLG1 Feb 05 '23 at 17:50
  • And this is the dataset with the Log10 transformed variables and the countries removed where there was just one entry ..... table(table(LOG10.STOCK.VS.GDP.GLMM$Area)) 9 11 2 188 – TLG1 Feb 05 '23 at 17:58
  • sure, e-mail me or post a link on a new issue at https://github.com/lme4/lme4/issues – Ben Bolker Feb 06 '23 at 00:24
  • I sent you an email Ben – TLG1 Feb 06 '23 at 21:01