What interaction effect glmulti generates in A*B*C*D and A+B+C+D?

372 views Asked by At

I am using glmulti to run hierarchical linear models and select the best model. I have 4 predictors (A, B, C, D) to the DV, and my goal is to run all main effect models plus all combination of interaction effects (i.e., A:B, A:C, A:D). How do the following two models differ from each other?

library(glmulti)

# wrapper
glmer.glmulti <- function(formula, data, random = ""){
glmer(paste(deparse(formula), random), data = data, family = binomial)}

# model 1
glmulti(DV ~ A+B+C+D, level = 2, fitfunction = glmer.glmulti, random = "+ (1|ID)", 
method = "g", data = df)

# model 2
glmulti(DV ~ A*B*C*D, level = 2, fitfunction = glmer.glmulti, random = "+ (1|ID)", 
method = "g", data = df)

I know that "when an interaction between two factors is included in a model, then adding or not these factors as main effects does not change the model" (Calcagno, 2010). Seem that model 1 and model 2 should produce the same results because A*B*C*D essentially includes the main effect of each predictor. But the two codes select a different best model.

Thanks!

0

There are 0 answers