I am trying to analyze a dataset using number of flowers as response variable and the interaction between two treatment variables (categorical with 2 and 3 levels) as covariates. I also have a random effect, which represents different areas where the data were collected. I run a mixed-effect model with a Poisson distribution:
fit1 <- glmer(FlowerNumber ~ Treatment1 * Treatment2 + (1 | area),
family = poisson, data = df_flowers)
I used the DHARMa package to test for dispersion and zero-inflation. Because the model diagnostics showed underdispersion and a zero-inflation, I used the glmmTMB package with a Zero-inflated generalized Poisson
fit2 <- glmmTMB(FlowerNumber ~ Treatment1 * Treatment2 + (1 | area),
ziformula=~1, family = genpois, data = df_flowers)
In this way, I solved the underdispersion problem:
DHARMa nonparametric dispersion test via sd of residuals fitted vs.
simulated
data: simulationOutput
ratioObsSim = 0.93318, p-value = 0.736
alternative hypothesis: two.sided
But not zero-inflation (although it's better, see first figure -Poisson- vs second figure -generalized zi Poisson):
DHARMa zero-inflation test via comparison to expected zeros with
simulation under H0 = fitted model
data: simulationOutput
ratioObsSim = 1.0308, p-value = 0.032
alternative hypothesis: two.sided
I am not sure what to do next. I found another post asking a very similar question, but the user didn't have problems with underdispersion so one of the suggestions was to run the same model with the GLMMadaptive package. I saw that GLMMadaptive doesn't include generalized Poisson, which I think I should use. Does anybody have any advice on how to proceed next?
~1
isn't sufficient as formula specification. What if you tryziformula=~.
? $\endgroup$