0

I am conducting a linear mixed effect model with random intercept and slopes with the lme function from the ````nlme``` package in R.

library(readr)
library(nlme)

#Data
post = read_csv("C:/data.csv")
post$regions <- as.numeric(as.factor(post$regions))
post.sc = data.frame(scale(post))
post.sc = na.omit(post.sc)

#Regressions
lm.reg <- lm(V1 ~ V2+V3+V4+V5+V6+V7+V8+V9+V10, data = post.sc)

lmm.null <- lme(V1 ~ 1, data = post.sc, random = ~1 | regions, method = 'ML')

lmm.reg <- lme(V1 ~ V2+V3+V4+V5+V6+V7+V8+V9+V10, data = post.sc, random = ~1 | regions, method = 'ML')

lmm.reg.slope <- lme(V1 ~ V2+V3+V4+V5+V6+V7+V8+V9+V10, data = post.sc, random = ~1+V1 ~ V2+V3+V4+V5+V6+V7+V8+V9+V10| regions, method = 'ML', control = lmeControl(maxIter = 10000, msMaxIter = 10000))

I get the following error message:

Error in lme.formula(V1 ~ V2+V3+V4+V5+V6+V7+  : 
  nlminb problem, convergence error code = 1
  message = function evaluation limit reached without convergence (9)

I have not encountered questions with similar problems.

Is there a way to fix this?

Thomas
  • 441
  • 3
  • 16
  • Unfortunately you did not make a [self-contained example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), but you may try to increase iterations using `lme(..., control=lmeControl(maxIter=1e3))`. – jay.sf Oct 22 '22 at 09:52

0 Answers0