I am doing some model comparison with a glmer fit with lme4. My global model has 4 fixed effects and 1 random effect, plus interactions between 3 of the fixed effects:
response ~ a + b * c * d + (1|e)
The dredge function returns models with both double and triple interactions, but the fixed effects are always included in the model when interactions involving that variable are included. I want to compare all model combinations with these variables, including models that have an interaction term without the main effect, for example:
response ~ a + b + b:c + (1|e) or response ~ a + c + b:c + a:b:c + (1|e)
Is this possible with the dredge() function? Or any other suggestions for ways to accomplish this? It is a LOT of models to specify by hand.
I'll start by warning that you should only violate the principle of marginality if you have good reason to do so/know what you're doing (there's a reason that
MuMIn
sets the defaults the way it does ...). With that said (untested because no reproducible example was given):model.matrix()
to construct a matrix containing all of the separate variables you need for the fixed-effect component:(this will also expand factor variables into contrast/dummy variables; if you don't want this, you have to be a little more precise)
reformulate()
to combine all of those variables with the random effects: