Random effects and fixed effects in GLMM I have the following model written. I have chosen for field as a random factor. I understood that an interaction between a fixed and random will be written as a fixed effect. As a result, I have the following model:
myGLMM4R <- glmmTMB(spp.richness ~ treatment + moment_datacollection + treatment * moment_datacollection +
                      (1|field) + field*treatment + field * moment_datacollection  ,
                   data = metaspecies, na.action = na.fail)

After model selection (dredge) the following model is selected: Model: spp.richness ~ field + moment_datacollection + treatment + (1 | field) + field:moment_datacollection
I was wondering why field is included in this model both as fixed and random. Is that because the interaction includes field and is a fixed effect? Is it a problem that field is now twice in the model? I included field as a random effect, to lower the df. But now it is included also as a fixed effect so will increase the df. Is there a way to solve this?
Thanks!
 A: With field being a factor, you consider a formula right-hand side of the form:
... + field + (1 | field) + ...

That means you model the interaction of intercept and field as both a fixed and a random effect, which leads to redundancy. You could e.g. set the fixed effects to the optimal value and the random effect for all levels to zero.
The lme4 package renders a warning that "parameters are not uniquely determined". glmmTMB, on the other hand, doesn't complain, at least not in my experiment, but it sets all the random effects to (almost) zero.
So, my recommendation is to choose only one of those two terms.
A: I found the problem myself and is actually quite simple. Due to the fact that I have written the model the following
spp.richness ~ treatment + moment_datacollection + treatment*moment_datacollection +(1|field) + field*treatment + field*moment_datacollection

Here I have written the interaction using an asterisk (*). Therefor R will take the interaction field&treatment and both factors also separate field and treatment . Because the interaction is written as a fixed factor, both separated factors are also fixed factors.
By using a colon (:) instead of an asterisk (*) in the model, R will take only the interaction, and not both factors also septerated.
spp.richness ~ treatment + moment_datacollection + treatment:moment_datacollection +(1|field) + field:treatment + field:moment_datacollection

therfore after model selection I get now the following model
Model: spp.richness ~ moment_datacollection + treatment + (1 | field) + field:moment_datacollection

