3
$\begingroup$

I am comparing two models in order to see if a specific interaction (SessionGroup) is significant. Mod1 is the full model, Mod2 is the full model MINUS the SessionGroup interaction.

mod1 = lmer(accuracy ~ session + trialtype + group + session*trialtype +     
session*group + session*group*trialtype + trialtype*group + 
(1+trialtype|subject), data=data, REML=FALSE)

mod2 = lmer(accuracy ~ session + trialtype + group + session*trialtype + 
session*group*trialtype + trialtype*group + (1+trialtype|subject), 
data=data, REML=FALSE)

Here is my identical output:

Data: data
Models:
mod1: accuracy ~ session + trialtype + group + session * trialtype + 
mod1:     session * group + session * group * trialtype + trialtype * 
mod1:     group + (1 + trialtype | subject)
mod2: accuracy ~ session + trialtype + group + session * trialtype + 
mod2:     session * group * trialtype + trialtype * group + (1 + trialtype 
| 
mod2:     subject)
     Df    AIC    BIC  logLik deviance Chisq Chi Df Pr(>Chisq)
mod1 27 4026.4 4150.3 -1986.2   3972.4                        
mod2 27 4026.4 4150.3 -1986.2   3972.4     0      0          1

Something is wrong with the code, I just can't figure it out. Also, is this the correct way to compare 2 models when looking at main effects/interactions? I've never taken an MLM class, so I've been teaching myself as I do this.

Thank you in advance!

$\endgroup$

1 Answer 1

6
$\begingroup$

The second model also includes the interaction between session and group.

The function terms allows for looking at all main effects and interactions created by a formula.

# formula of model 1
form1 <- accuracy ~ session + trialtype + group + session*trialtype + session*group + session*group*trialtype + trialtype*group + (1+trialtype|subject)

# formula of model 2
form2 <- accuracy ~ session + trialtype + group + session*trialtype + session*group*trialtype + trialtype*group + (1+trialtype|subject)

# terms of formula 1
attr(terms(form1), "term.labels")
# [1] "session"                 "trialtype"               "group"                  
# [4] "1 + trialtype | subject" "session:trialtype"       "session:group"          
# [7] "trialtype:group"         "session:trialtype:group"

# terms of formula 2
attr(terms(form2), "term.labels")
# [1] "session"                 "trialtype"               "group"                  
# [4] "1 + trialtype | subject" "session:trialtype"       "session:group"          
# [7] "trialtype:group"         "session:trialtype:group"

identical(attr(terms(form1), "term.labels"), attr(terms(form2), "term.labels"))
# TRUE

As you can see, both formulas result in identical predictors and hence identical models. Note that session*group*trialtype (which is present in both formulas) expands to session + group + trialtype + session : group + session : trialtype + group : trialtype + session : group : trialtype.

If you want to exclude the interaction between session and groupfrom the second model, you have to modify its formula:

accuracy ~ session + trialtype + group + session*trialtype + trialtype*group + (1+trialtype|subject)

Note: In the above formula, the higher-order interaction between three variables has been removed too, since it is highly recommended to not include higher-order interactions when interactions of lower order or the corresponding main effects are absent.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.