title: Warning lme4: Model failed to converge with max|grad|
body: <p>I have to run a lmer with a log transformed response variable, a continuous variable as fixed effect and and a nested random effect:</p>
  
  <pre><code>first&lt;-lmer(logterrisize~spm + (1|studyarea/teriid),
              data = Data_table_for_analysis_Character_studyarea,
              control=lmerControl(optimizer="Nelder_Mead",
                                   optCtrl=list(maxfun=1e4)))
  </code></pre>
  
  <p>I got this error message: Error in length(value &lt;- as.numeric(value)) == 1L : 
    Downdated VtV is not positive definite</p>
  
  <p>I tried this with bobyqa() as optimization argument and got this warning messages: </p>
  
  <pre><code>1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : 
  Model failed to converge with max|grad| = 0.753065 (tol = 0.002, component
  1) 2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,:
  Model is nearly unidentifiable: very large eigenvalue-Rescale variables?
  </code></pre>
  
  <p>my summary looks like this:</p>
  
  <pre><code>Linear mixed model fit by REML ['lmerMod'] 
  Formula: logterrisize ~ spm + (1 studyarea/teriid) Data: Data_table_for_analysis_Character_studyareaControl: lmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 10000)) REML criterion at convergence: -6079.6Scaled residuals: 
     Min         1Q     Median         3Q        Max 
  -3.639e-07 -4.962e-08  3.310e-09  5.293e-08  9.725e-07 
  Random effects:
   Groups           Name        Variance  Std.Dev.
   teriid:studyarea (Intercept) 1.291e-01 3.593e-01
   studyarea        (Intercept) 1.944e-02 1.394e-01
   Residual                     4.506e-15 6.712e-08
  Number of obs: 273, groups:  teriid:studyarea, 66; studyarea, 22
  Fixed effects:
   Estimate Std. Error t value
  (Intercept)  1.480e+00  5.631e-02   26.28
  spm         -5.785e-16  8.507e-10    0.00
  Correlation of Fixed Effects:
   (Intr) spm 0.000  convergence code: 0
  Model failed to converge with max|grad| = 0.753065 (tol = 0.002, component1)
  Model is nearly unidentifiable: very large eigenvalue - Rescale variables?
  </code></pre>
  
  <p>my data looks like following:</p>
  
  <pre><code>show(logterrisize) [1] 1.3317643 1.3317643 1.3317643 0.1295798 0.1295798 1.5051368 1.5051368 1.5051368 1.5051368 [10] 1.5051368 1.5051368 1.5051368 1.5051368 1.5051368 1.5051368 1.5051368 1.5051368 1.5051368 [19] 1.5051368 1.5051368 1.5051368 1.4665993 1.4665993 1.4665993 1.8282328 1.8282328 1.9252934 [28] 1.9252934 1.9252934 2.3006582 2.3006582 2.5160920 2.7774040 2.7774040 3.3398623 3.3398623 [37] 3.4759297 1.2563594 1.6061204 1.6061204 1.7835139 1.7835139 2.1669498 2.1669498 2.1669498 [46] 2.1669498 0.7264997 0.7458155 0.8380524 0.8380524 0.8380524 0.8380524 0.8380524 0.8380524
  
   show(spm)  [1] 18.461538 22.641509 35.172414 10.418006 15.611285  3.482143  3.692308  4.483986  4.821429 [10]  6.000000  6.122449  6.176471  6.220736  6.260870  6.593407  7.010309  9.200000  9.473684 [19]  9.600000 12.600000 14.200000 16.146179 28.125000 30.099010 13.731343 14.432990 11.089109 [28] 17.960526 32.903226  8.955224 33.311688  8.800000 11.578947 20.000000 14.455446 18.181818 [37] 28.064516 25.684211 17.866667 23.142857 18.208955 20.536913 11.419355 11.593220 12.703583 [46] 20.000000  3.600000 11.320755  6.200000  6.575342 12.800000 19.109589 20.124224 22.941176 [55]  4.600000  6.600000  6.771160  8.000000 19.200000 19.400000 22.773723  3.333333  4.214047
  </code></pre>
  
  <p>Studyarea are character names and teriID represents continuous numbers of the study sites.</p>
  
  <p>My data frame looks like this:<a href="https://i.stack.imgur.com/91kw5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/91kw5.jpg" alt="enter image description here"></a></p>
  
  <p>Did I forget anything to include to the equation while using a log transformed variable?
  Thanks!</p>
  
  <p>EDIT:
  I used ?convergence to check on convergence errors. I tried this:</p>
  
  <p>## 3. recompute gradient and Hessian with Richardson extrapolation</p>
  
  <pre><code>devfun &lt;- update(first, devFunOnly=TRUE)
  if (isLMM(first)) {
  pars &lt;- getME(first,"theta")
  } else {## GLMM: requires both random and fixed parameters
  pars &lt;- getME(first, c("theta","fixef"))
  }
  if (require("numDeriv")) {
   cat("hess:\n"); print(hess &lt;- hessian(devfun, unlist(pars)))
  cat("grad:\n"); print(grad &lt;- grad(devfun, unlist(pars)))
  cat("scaled gradient:\n")
  print(scgrad &lt;- solve(chol(hess), grad))}
  </code></pre>
  
  <p>and got this answer:</p>
  
  <pre><code>hess:
        [,1]      [,2]
  [1,] 147.59157 -14.37956
  [2,] -14.37956 120.85329
  grad:
  [1] -222.1020 -108.1038
  scaled gradient:
  [1] -19.245584  -9.891077
  </code></pre>
  
  <p>Unfortunately I don´t know what the answer should tell me.</p>
  
  <p>2nd EDIT:</p>
  
  <p>I tried numerous optimizer and while using this:</p>
  
  <pre><code>first&lt;-lmer(logterrisize~spm + (1|studyarea/teriid),REML=FALSE,
              data = Data_table_for_analysis_Character_studyarea,
              control=lmerControl(optimizer="optimx",
                                   optCtrl=list(method='nlminb')))
  </code></pre>
  
  <p>I only got one warning: <code>In optwrap(optimizer, devfun, getStart(start, rho$lower, rho$pp),  :
    convergence code 1 from optimx</code></p>
  
  <p>now my summary looks like this:</p>
  
  <pre><code>Linear mixed model fit by maximum likelihood  ['lmerMod']
  Formula: logterrisize ~ spm + (1 | studyarea/teriid)
  Data: Data_table_for_analysis_Character_studyarea
  Control: lmerControl(optimizer = "optimx", optCtrl = list(method ="nlminb"))
  AIC      BIC   logLik deviance df.resid 
   -3772.4  -3754.3   1891.2  -3782.4      268 
  Scaled residuals: 
     Min         1Q     Median         3Q        Max 
  -1.523e-04 -1.693e-05  1.480e-06  1.436e-05  3.332e-04 
  Random effects:
  Groups           Name        Variance  Std.Dev. 
  teriid:studyarea (Intercept) 8.219e-02 0.2866882
  studyarea        (Intercept) 7.478e-02 0.2734675
  Residual                     3.843e-10 0.0000196
  Number of obs: 273, groups:  teriid:studyarea, 66; studyarea, 22
  Fixed effects:
  Estimate Std. Error t value
  (Intercept) 1.551e+00  7.189e-02   21.58
  spm         3.210e-11  2.485e-07    0.00
  Correlation of Fixed Effects:
  (Intr)spm 0.000 
  convergence code: 1
  </code></pre>
  
  <p>So may I able to turn a blind eye on this warning message or will this be a huge mistake?</p>