I am using the lme4
package in R and trying to fit in a random slope and random intercept model.
I would be really helpful if anyone can help me understanding this error when I run a random slope and random intercept model and what to do regarding this error:
mdl17<-lmer(yld.res ~ brk + (1+brk|state),data=data1,REML="FALSE")
Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
Model failed to converge with max|grad| = 1.84098 (tol = 0.002, component 3)
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
Model failed to converge: degenerate Hessian with 1 negative eigenvalues
Thanks a lot
As @CarlWitthoft stated the warning informs you about a convergence failure of your model. It can be either under- or overdefined. You should also check if the model you’re trying to fit makes sense at all. Furthermore, you should definitely install the most current version of the lme4
package by running update.packages("lme4")
or (if you want to update all packages) update.packages()
. The current lme4
packages contains its own page about convergence warnings. After you have loaded it via library(lme4)
you can access that man page by issuing ?convergence
. There you will find additional info about your warning message. (Note, that future version may not necessarily contain this page.) As an additional measure, you can search how to use a different optimizer. The new version of lme4
e.g. imports nloptr
which can be used.
You should also check lme4
’s Github page: https://github.com/lme4/lme4/ in cases were you encounter warning or error messages that you find worrying. For your specific case there is some information that might be relevant:
"Recent versions of
lme4 (e.g. 1.1-6)
give false convergence warnings. There is a summary post on r-sig-mixed-models. If you get warnings aboutmax|grad|
but the model passes this test:
dd <- fit@optinfo$derivs
with(dd,max(abs(solve(Hessian,gradient)))<2e-3)
then you are seeing a false-positive warning, and the problem will disappear in future versions
(1.1-7 and up)
."[1]
Should the Github
page contain relevant information (e.g. that the warning or error is specific to the current version on CRAN
) you should consider installing lme4
’s current master from Github
and check whether the problem disappears when you use it:
(1) First install devtools
: install.packages("devtools")
and attach it library(devtools)
to your namespace.
(2) Then use: install_github("lme4/lme4", dependencies = TRUE)
to install the latest master of the lme4
package from Github. (Should you encounter an error indicating that building the vignettes failed despite dependencies = TRUE
you should pass build_vignettes = FALSE
to your call of install_github()
.)
Here’s the link to the summary about convergence warnings: http://thread.gmane.org/gmane.comp.lang.r.lme4.devel/11893 (retrieved 2014-07-16T10:04+02:00)