Skip to content
Prev 20477 / 20628 Next

Convergence issues with nlme:lme

You don't have the model object, since R threw an error.


   If you run

model <- lme(y ~ x, random = ~ 1 + x | group, data = data, control = 
lmeControl(returnObject = TRUE))

   you will get an object returned. However, I don't see anything in the 
returned object that stores warning information.

   In these cases you need to set up some machinery to capture and store 
errors and warnings, et.c. from
https://github.com/lme4/lme4/blob/master/R/error_factory.R

mylme <- lme4:::factory(lme)
model2 <- mylme(y ~ x, random = ~ 1 + x | group, data = data, control = 
lmeControl(returnObject = TRUE))


attr(model2, "factory-warning")
## [1] "nlminb problem, convergence error code = 1\n  message = 
iteration limit reached without convergence (10)"

And now without setting returnObject = TRUE ...

model3 <- mylme(y ~ x, random = ~ 1 + x | group, data = data)

model3
[1] "An error occurred in the factory function"
attr(,"factory-error")
[1] "nlminb problem, convergence error code = 1\n  message = iteration 
limit reached without convergence (10)"
On 10/21/24 11:40, Robert Long wrote: