I am trying to fit a generalised mixed effects model, but I am having convergence problems. The model I want to fit is

mod2 <- glmer(accuracy ~ reps * time + (1 | ID) + (1 | item),
             family = 'binomial',
             data = xdata)

The error I have is this one:

 Warning message:
In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge with max|grad| = 0.0167064 (tol = 0.001, component 1)

My predictors are time and number of repetitions. Time levels are immediate, 1 day and 1 week. The number of repetitions are 2, 4 or 6. I thought these should be treated as categorical, but now I'm not sure.

I have 240 observations at each combination of time/number of repetitions. I have 20 participants at each number of repetitions (between subjects design) and all of them were tested at the 3 time intervals (within subjects). I have 36 items, and a different subset of 12 was tested at each time delay. The order of these subsets was randomised across participants.

Most people I asked told me to scale my predictors and if this does not work, to try and optimiser such as bobyqa.

I tried to scale them in R but I get this error:

Error in colMeans(x, na.rm = TRUE) : 'x' must be numeric

That makes me think it is not even possible to scale them. Should I make the continuous even if I only have three points for each one?

Because the subjects are nested within the number of repetitions, another solution could be to add (1 | reps:ID) but I don't know if it makes sense.

Thank you for reading!

  • $\begingroup$ It would help if you posted the call you made to glmer(), not just the warning message. In particular, what type of generalized model are you trying to use? Also, please give some indication about the nature of the data: how many observations at each combination of time/number of repetitions, how many individuals your mixed effect(s) are trying to take into account. Scaling shouldn't generally be used or needed for categorical predictors unless you are using some type of penalization method like ridge regression or LASSO. $\endgroup$ – EdM Apr 14 '19 at 18:40
  • $\begingroup$ Rescaling is unlikely to help unless the variables are on vastly different scales, but in any case, rescaling a categorical variable is a very bad idea except in very limited circumstances. How many IDs do you have ? Did you try a different optimiser ? You could also try the package GLMMAdaptive instead of lme4 $\endgroup$ – Robert Long Apr 15 '19 at 12:57
  • $\begingroup$ One variable is time and the other one is number of repetitions, so they are indeed different. I am not sure if it's categorical or just numeric. I have 60 IDs. I used bobyqa and it converged but I was told to avoid using optimisers by our professor. Finally, I think I will end up using that package but it makes me nervous because I am a beginner and I am already overwhelmed. $\endgroup$ – Lili Apr 15 '19 at 18:10

As I and @RobertLong noted in comments, scaling categorical variables would not be a good (or effective) solution to your problem. You probably just face a practical problem with finding the solution, based on the combination of the form of your model, your data, and the default settings used by glmer(). The default settings for a function in a statistical package just might not work in particular situations. That's an important lesson for a beginner to learn.

There can be convergence issues with lme4 functions, some of which may just be false-positive warnings. These are related to the choice and settings for the optimizer used to find the solution. This answer on this site from Ben Bolker, a major contributor to that package, discusses a similar recent example with lmer(). Further complicating the issue, optimizer defaults have changed among versions of the package. That answer also provides further hints about how to deal with such issues.

It's not clear why your professor would tell you to "avoid using optimisers." The (restricted) maximum likelihood methods used to solve mixed models require some optimization method to find the solution. There are different choices for the type of optimizer to use and choices for optimizer settings, which are typically hidden within the standard defaults. Your success with bobyqa indicates that you found an optimization that works better than the default. There is nothing wrong with that.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.