# Significant dispersion test

I used DHARMa for my residual diagnostics. For two models, the dispersion test is significant even though the rest of the diagnostic output looks good. I am wondering if both my models are correct despite the dispersion test being significant.

I conducted an experiment at three different locations, each containing 4 plots. Each plot was subjected to a different treatment for one consecutive week. During this week, measurements were conducted two times a day (included as time_since_start (h) of experiment) and on each plot a camera trap was placed to observe animal behaviour. The experiment was repeated three times.

I would like to test if the time since the start of the experiment influences the duration of a certain behavioural trait recorded by the camera traps. To test this I created the following model:

glmmTMB(cbind(time_behaviour, total_video_duration- time_behaviour) ~
Treatment*I(sqrt(Time_since_start)) + Repetition + Location,
ziformula = ~ 1,family = "betabinomial")


Originally, I had thought to add the “Repetition” and “Location” as random effects in the model. However as n = 3 for both, I had to add them as fixed effects. When checking my model output using DHARMa the plots look good, but the Dispersion test is significant (P = 0.048).

Even though this is only just significant, a similar problem occurs with another model. For example:

glmmTMB(cbind(Nr_shoots_browsed, total_shoots_available- Nr_shoots_browsed) ~
Treatment*I(sqrt(Time_since_start)) + Repetition + Location,
ziformula = ~ 1,family = "betabinomial")


Interestingly, the dispersion test of the model above is not significant when I remove all NA’s in the dataset even though these NA’s occur in other variables than the ones used in the model. Removing these rows with NA’s, results in the removal of rows where the total_shoots_available is 1, where all with >1 remain in the dataset. Ecologically, it would be wrong to remove these and therefore I would leave them in. Furthermore, the cbind structure should account for differences in the total_shoot_available.

I have been playing around a lot with these models, but so far I haven’t found a solution yet. When looking at different posts, I am tempted to accept these models but I am not really sure if this is correct.

Now my question is: Is this significant dispersion a problem and if yes what could I do to make this model better?

I'm the developer of DHARMa. This is a pretty common question, and there is a section in the vignette giving guidance on that, but I just realised now that it's not very well placed, so I will change that. Anyway, that's what I wrote in the vignette about the dispersion tests:

A word of warning that applies also to all other tests that follow: significance in hypothesis tests depends on at least 2 ingredients: strength of the signal, and number of data points. Hence, the p-value alone is not a good indicator of the extent to which your residuals deviate from assumptions. Specifically, if you have a lot of data points, residual diagnostics will nearly inevitably become significant, because having a perfectly fitting model is very unlikely. That, however, doesn’t necessarily mean that you need to change your model. The p-values confirm that there is a deviation from your null hypothesis. It is, however, in your discretion to decide whether this deviation is worth worrying about. If you see a dispersion parameter of 1.01, I would not worry, even if the test is significant. A significant value of 5, however, is clearly a reason to move to a model that accounts for overdispersion.