# DHARMa diagnostics: residuals vs. predicted for categorial predictor

I fitted different response variables (one after each other) to the same categorial predictor. Since it's a categorical predictor I get a boxplot for the residual vs. fitted with the DHARMa diagnostics. In Florian Hartig’s vignette he explains very neatly different examples for continuous predictors, but I struggle interpreting the boxplots.

First, my plots are missing the quantile lines. Setting quantreg = T seems to have no effect. Is there a way to fix this?

Second, I would like an opinion on the following examples of my diagnostics. What would you consider fine and where do you see problems and why? What general things would you watch out for in this boxplot style output and are there rules of thumb e.g. "if one box is double the size of another..."? (Comments on the shape of the QQ plot are welcome but not the main focus of this question.)

My models have this structure and use DHARMa diagnostics:

    mod <- glmmTMB(response ~ cat_predictor + (1|sampleID), ziformula = ~ cat_predictor, family = "poisson", data = seeds)

sim <- simulateResiduals(mod)
plot(sim, quantreg = T, n = 250)


cat_predictor: has 4 level, with differing amounts of zeros per level

response: n = 320 , so per level 80 observations

response1 = count variable using family = poisson:

response2 = count variable using family = nbinom1:

response3 = binomial variable using family = binomial:

response4 = continuous variable using family = tweedie(without ziformula):

response5 = proportion variable using family = beta (values are 0 <= y <= 1):

response6 = proportion variable using family = tweedie(including ziformula, values are 0 <= y <= ~4)

I am looking forward to hearing your opinions!

• The quantile lines are not necessary here because they correspond to the elements of a boxplot. Feb 23, 2021 at 13:31

1. quantreg: there is currently no option to plot quantile regressions for categorical predictors. The reason is that it both doesn't make sense for unordered factors, and that quantile regressions will crash with too few unique values on x. 4 is definitely too many. Only if you have an ordered factor, and if you have a large number of levels, you could overrule this by using as.numeric(orderedCategorialPredictor) as predictor in plotResiduals, in which case the standard scatter plot would be drawn.
2. Regarding your plots: I can see light variations of the dispersion between the groups in your plot. I don't think it's a large concern. The interpretation depends also on your data size, as stochasticity of these plots will increase for smaller datasets. If your data is reasonably large (say n>100), you could try adding dispformula ~ cat_predictor to your model, which would model variable dispersion in the groups specified by your cat_predictor