I've tried to use the dredge-function of the MuMin-Package for a negative binomial generalized linear mixed model fitted with the package glmmTMB.
Because my full-model failed to converge, I've tried the workaround as described here: Dredge with the global model failing to converge
But when I use a simplified model and rewrite the function in model$call$function, dredge ignores this change and uses the simplified model instead of the full model.
Is there maybe another workaround for functions of the glmmTMB-package?
Below some example code:
# The full_model does not converge
full_model <- glmmTMB(y ~ x1 * x2 * (x3 + x4 + x5 + x6) + (1|RE1/RE1.1/RE1.2) + (1|RE2), data = df, family = "nbinom2")
# The simple_model does converge
simple_model <- glmmTMB(y ~ x1 + x2 + x3 + x4 + x5 + x6 + (1|RE1/RE1.1/RE1.2) + (1|RE2), data = df, family = "nbinom2")
# Change formula in the model
simple_model$call$formula <- y ~ x1 * x2 * (x3 + x4 + x5 + x6) + (1|RE1/RE1.1/RE1.2) + (1|RE2)
# use dredge, but this ignores the changed formula
dredge(simple_model)
Thank you!
You would have to replace the elements of simple_model $ modelInfo $ allForm
. These are three formulas: "formula"
, "ziformula"
, and "dispformula"
, but in the case of your model only the first one is used.