Is it possible to include interaction terms without main effects in the MuMIn::dredge function?

110 views Asked by At

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.

1

There are 1 answers

0
Ben Bolker On BEST ANSWER

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):

  1. use model.matrix() to construct a matrix containing all of the separate variables you need for the fixed-effect component:
X <- model.matrix(~ a + b*c*d, data = yourdata)
colnames(X) <- make.names(colnames(X)) ## convert to syntactically allowed names

(this will also expand factor variables into contrast/dummy variables; if you don't want this, you have to be a little more precise)

  1. make a new data frame containing these variables (and your random effects grouping variables) and use reformulate() to combine all of those variables with the random effects:
newdata <- data.frame(X, yourdata[c("e", "response")])
form <- reformulate(c(colnames(X), "(1|e)", response = "response")
  1. Fit the model:
model <- glmer(form, family = ..., data = newdata)
  1. Dredge away!