I am trying to fit the gamma distribution to my data as the residuals are not normally distributed but it has been much more difficult than I anticipated. The dependent variable is response times and the predictors are all categorical. The linear model:

enter image description here

First, when I try to model it, it always shows convergence issues that I am not sure how to fix without scaling the variable which leads to negative values and the following warning:

Error in eval(family$initialize, rho) : non-positive values not allowed for the 'gamma' family

The model :

glmer <- glmer(RT ~ V1*V2*V3 + (1|Participant), data= Data, family = Gamma(link = "log"),                      

Throws this warning but like I said before, I am not sure how to rescale a gamma distribution.

  Warning messages:
  1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
     Model failed to converge with max|grad| = 0.00889002 (tol = 0.002, component 1)
  2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
     Model is nearly unidentifiable: very large eigenvalue
   - Rescale variables?

When I use this code to check the assumptions, it looks really weird. I have read that this may not be appropriate for mixed models.

   simulationOutput <- simulateResiduals(fittedModel = glmer, use.u = T)

enter image description here

I then used this code to check the residuals:

  residuals <- residuals(glmer, type = "response", retype="normalized")

enter image description here

How can I solve these issues or does this mean the gamma distribution is not a good fit for my data?

  • $\begingroup$ Please explain your study design and how the data arise. Also please include the plots for the linear model. $\endgroup$ Aug 12, 2020 at 3:02
  • $\begingroup$ I posted some plots of the linear model here: stats.stackexchange.com/questions/482141/… $\endgroup$
    – CatM
    Aug 12, 2020 at 3:10
  • $\begingroup$ It looks like those plots are for a log model AND I don't see much description of the study design and how the data were measured $\endgroup$ Aug 12, 2020 at 3:12
  • $\begingroup$ Sorry, just added the information to this post for the linear model. This is a simple response time task with one of the variables representing two types of trials in the task congruent or incongruent, block which is the within session time dimension and the final one - session because participants were tested twice, this is a repeated measures study. $\endgroup$
    – CatM
    Aug 12, 2020 at 3:18
  • $\begingroup$ You don't seem to want provide much information ? How many participants ? What is your research question(s) ? So V1 is trial type (2 levels), V2 is block (how many levels ?) and V3 is session number (1 or 2). Are you specifically interested in the effect of time (session number ?) $\endgroup$ Aug 12, 2020 at 3:28

1 Answer 1


The first problem here is:

Error in eval(family$initialize, rho) : non-positive values not allowed for the 'gamma' family

This is because you scaled the response variable to be centred around zero and the gamma model is only for positive values.

The other issues, that were fleshed out in the comments/chat is that glmer was having problems converging due to the way it approximates the integrals over the random effects in the definition of the marginal likelihood. The package GLMMAdaptive uses adaptive gauss hermite quadrature and was able to solve this problem with the log-transformed response. However this results in a model that is much harder to interpet than the linear model, while providing almost the same inferences and answers to the research questions.

Having said all that, the root issue in the question is that the gamma model fitted clearly has very poor fit to the data. The recommendation is to explore a model fitted on log response times since all response times are greater than 1, this should not be a problem, although there may be difficulties with interpretation.


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.