2
$\begingroup$

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.

$\endgroup$
8
  • $\begingroup$ Can you confirm that R is storing your factor variables as "factors" in the dataset? e.g.(str(myDataset)). How many observation do you have nested per person? How many individuals overall? And how much variability is there in your DV? Just curious in terms of trying to reproduce all of the conditions for this example. $\endgroup$ Commented Jul 5, 2017 at 4:35
  • $\begingroup$ You may also find this discussion helpful click here $\endgroup$ Commented Jul 5, 2017 at 4:39
  • $\begingroup$ Matt, thank you for comments. I can confirm that R is storing factors I mentioned as factors. I have 21 individuals overall with min 10, max 103 observations, average 24 observations and standard deviation 19.95 . $\endgroup$
    – makak
    Commented Jul 6, 2017 at 4:15
  • $\begingroup$ Is there any chance you can provide any additional summary info for all variables in the model and/or something like the first 25 rows of data? $\endgroup$ Commented Jul 7, 2017 at 15:00
  • 1
    $\begingroup$ At first instance try using scale(numeric1)+scale(numeric2)+scale(numeric3)+scale(numeric4) instead of numeric1+numeric2+numeric3+numeric4 and see if rescale your numerical variables help. $\endgroup$
    – usεr11852
    Commented Jul 8, 2017 at 10:09

1 Answer 1

4
+50
$\begingroup$

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.

$\endgroup$
3
  • 1
    $\begingroup$ Not being able to comment is not a good reason for using an answer to comment. $\endgroup$ Commented Jul 7, 2017 at 18:44
  • $\begingroup$ But they were also correct... See @makak's latest comment on the question. $\endgroup$
    – mikeck
    Commented Jul 12, 2017 at 20:25
  • $\begingroup$ Well, time to pay my debts. I think that your answer/comment was pretty close, so bounty is yours. And I think, that intention to help is sometimes a good reason to break the rules, so I would not be very concerned about some comments with different opinion. And if I remember it correctly, I did the same thing, somewhere on stack overflow. $\endgroup$
    – makak
    Commented Jul 14, 2017 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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