I am modelling a behavioural response (i.e., # times behaviour was observed/time observed [no longer an integer value]) in relation to disturbance levels (continuous) and the health status of the individual (2 categories: healthy/sick).

The behaviour was not observed in 311/352 observations, so I selected a zero-inflated linear mixed model for this analysis. The mixed component was included because most individuals were observed multiple times. After modelling the data, I used the DHARMa package to examine the residual plots, but since this is my first time using glmmTMB (and a zero-inflated linear mixed model), I'm uncertain about the interpretation of the resulting plots.

# my model
m1 <- glmmTMB(behaviour ~ disturbance * health + (1|id), 
             ziformula = ~1,
             data = df))
# checking plots
res1 <- simulateResiduals(m1)

enter image description here

Here's what I think this is showing:

  1. QQ plot residuals: the lower cluster of points are all the observations where the behaviour did not occur, and the upper points are all the observations where the behaviour did occur. Given that the points do not fall along the red line, the zero-inflation model is probably not accounting for all the excess zeros in the response.

  2. Residuals vs predicted: downward trend in the values might be a missing variable, and all the points near the top of the graph may represent outliers?

Anything else I'm missing? Or ideas for addressing these issues?


1 Answer 1


Given that you are modeling counts of a behaviour, why not use a Poisson distribution with time either as an offset or a covariate?

Also your intercept-only ziformula assumes that the probability of the behaviour not being observed does not vary by health status or along the disturbance level.

This publication on GlmmTMB is a very good intro to the package (besides the vignettes) and possibly relevant to your case:

Brooks, M. E., Kristensen, K., van Benthem, K. J., Magnusson, A., Berg, C. W., Nielsen, A., Skaug, H. J., Machler, M., & Bolker, B. M. (2017). glmmTMB balances speed and flexibility among packages for Zero-inflated Generalized Linear Mixed Modeling. The R Journal, 9(2), 378-400. https://doi.org/10.32614/RJ-2017-066

  • $\begingroup$ Thanks @Angelos Amyntas. I mentioned above, although perhaps it isn't clear enough, that the counts are divided by the duration of the observation (10-20 minutes). So while the poisson would be the correct distribution for purely count data, it doesn't fit anymore. $\endgroup$
    – tnt
    Jun 10, 2020 at 14:41
  • 1
    $\begingroup$ That is why I suggested an offset. (I am assuming that the raw data are available to you). Instead of baking your correction for duration differences into your response, which as you say would make Poisson and co. not an option, you can use an offset term to specify that the number of observations is proportional to the duration. Have a look at the "Getting started" of the package to see an example. You can also look for more info about offsets here in CV. $\endgroup$ Jun 10, 2020 at 15:46
  • $\begingroup$ Thanks! I tried the offset and the models look great. $\endgroup$
    – tnt
    Jun 12, 2020 at 21:00

Your Answer

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

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