Solved – Problem fitting glmer model with factor and numeric predictors

I'm trying to fit logistic regression with formula like this:

mod <- glmer(response ~  factor1+factor2+numeric1+numeric2+numeric3+numeric4 +(1|factor3),             data=myDataset,family = binomial,             control=glmerControl(optimizer="bobyqa")) 

Factor1 and factor2 are categorical variables with (5 and 2 categories). Factor3 is id of subject. The rest of predictors are numeric variables – all of them scaled with scale().

I am getting following error/warning:

Warning messages: 1: Some predictor variables are on very different scales: consider rescaling  2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :   Model failed to converge with max|grad| = 0.406353 (tol = 0.001, component 1) 3: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :   Model is nearly unidentifiable: very large eigenvalue  - Rescale variables?;Model is nearly unidentifiable: large eigenvalue ratio  - Rescale variables? 

When I am trying to fit the model without factor1 and factor2 variables, model fits without complain, so I am assuming that problem is in my factor predictors. But I have no idea how to fix it. Should I recode my factor variables to dummy variables myself and then scale them? Will it help? Any idea will be very appreciated.

Not enough reputation to comment so I'm replying as an answer.

You mention that the model fits fine when excluding your factor variables but complains when you include them. Is there any possibility of a structure/relationship between your factor<1/2> and your id variable? I have encountered this problem before with a client who was interested in exploring the effect of two categorical variables and did multiple replicates for the experimental levels of those variables, but only one control. One control that was at the zero level of both the variables. So we could estimate the effect of each factor individually but not jointly because the effect of the control level of one factor was inseparable from the control level of the other factor. I didn't realize this until I got convergence warnings trying to fit the model.

Without actually seeing your data we cannot be sure, but I would suggest going back and double check to see if there is structure that is preventing the model from being able to estimate certain levels of your factors.

Similar Posts:

Rate this post

Leave a Comment