# Model validation in R - Gamma GLMM

I'm trying to model a response variable y with respect to a nested variable x in R. First of all, I fitted a linear mixed model (LMM) as it follows:

m0 <- lmer(y ~ x + (x | group), data=df)


But, after looking at the residuals and the qqplot, I note that the LMM model violates the normality and homoscedastic assumptions. Also I observe that the higher the values of the fitted values, higher is the variance of residuals.

Alternatively, I try to fit a GLMM model with a Gamma family and log link:

m1 <- glmer(y ~ x + (x | group), data=df, family=Gamma(link='log'))


Now, the residuals show more homogeneity and the AIC value is considerably smaller: AIC
m0  42159,54
m1  39429,50


What are the possible steps for a model validation in this case?

A qqplot for a gamma distribution family seems to be unfeasible.

Are there any statistical tests to check the validity of the model?

• What is the experimental/study design here ? According to your model formula, I dont see how x is nested. The model says that y is nested in group, while x is a covariate with a fixed effect which also varies by group May 16, 2019 at 16:00
• I am trying to model the effect of the productivity (x) of a given person (group) on the quality (y) of her/his work. The (x | group) part of the model specifies a random intercept and slope for each one of these persons May 16, 2019 at 16:07
• Ok, so x is not nested. How are quality and productivity measured ? May 16, 2019 at 16:14
• Yes, you are right. Quality is measured as the average impact factor of all journals a person published in a year, and productivity as the count of works in the same year. To account the inflation over the years, we rescaled the measures by a deflation factor, so we can compare measures of different years. So the productivitity measure is not a count data anymore. May 16, 2019 at 16:21
• How, exactly, did you rescale the count variable ? May 16, 2019 at 18:51

The shape of your residuals suggest that you have a bounded outcome variable $$y$$. Perhaps you could consider a Beta mixed effects or in case you only have a lower bound but no upper bound a mixed model for semi-continuous data.
• Thank you for your response, Dimitris. I have a doubt: assuming that the family is a beta distribution isn't the same thing as assuming the $y_{i}$ to be distributed over the interval 0-1? And a semi-continuous data model supposes that the zero values are modeled one way and the rest of data is modeled another, which isn't the case, am I right? May 16, 2019 at 18:39
• If your outcome is defined in an interval $(a, b)$, you can transform it to get in the $(0, 1)$ interval where the Beta distribution is defined. Regarding the semi-continuous option, you’re right that this is the assumption. If you have a truly continuous outcome this makes sense because the probability that a continuous outcome takes a particular value is zero, but if you have too many zeros, this is violated. May 17, 2019 at 20:34