I originally ran my data in SPSS because figuring out the lmer package took some time for me to learn. I spent a few weeks writing up a script in R, but my output in R is different than what I'm getting using SPSS.
I have 3 Fixed Effects: Group, Session, and TrialType.
When I ran a mixed model in SPSS, I got the interaction Group*Session p=.08 OR p=.02, depending on which covariance structure I used. This is partly the reason I wanted to use R, because I didn't have enough information to help me decide which structure to use.
Here are my models in R. I'm using Log Likelihood Test to get a p-value for this Group*Session interaction.
Mod2 = lmer(accuracy ~ group*session*trialtype + (trialtype|subject), REML=F, data=data,
control = lmerControl(optimizer = "optimx", optCtrl=list(method='L-BFGS-B'))))
Mod5 = lmer(accuracy ~ session + trialtype + group + session*trialtype + trialtype*group + (trialtype|subject),
data=data, REML=FALSE,
control = lmerControl(optimizer = "optimx", optCtrl=list(method='L-BFGS-B')))
anova(Mod2, Mod5)
Data: data
Models:
Mod5: accuracy ~ session + trialtype + group + session * trialtype +
Mod5: trialtype * group + (trialtype | subject)
Mod2: accuracy ~ group * session * trialtype + (trialtype | subject)
Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
Mod5 23 -961.32 -855.74 503.66 -1007.3
Mod2 27 -956.32 -832.38 505.16 -1010.3 2.9989 4 0.558
I'll also note that I added the lmerControl based on the 2 warning/error messages I was getting. When I added, this, I got the singular boundary warning message.
Please comment if I need to specify additional information. Thank you!
Here is my syntax from SPSS:
MIXED Acc BY Test TrialType Group
/CRITERIA=CIN(95) MXITER(100) MXSTEP(10) SCORING(1) SINGULAR(0.000000000001) HCONVERGE(0,
ABSOLUTE) LCONVERGE(0, ABSOLUTE) PCONVERGE(0.000001, ABSOLUTE)
/FIXED=Test TrialType Group Test*TrialType Test*Group TrialType*Group Test*TrialType*Group |
SSTYPE(3)
/METHOD=ML
/PRINT=COVB DESCRIPTIVES G SOLUTION
/RANDOM=INTERCEPT TrialType | SUBJECT(Subject) COVTYPE(CS)
/REPEATED=Test | SUBJECT(Subject) COVTYPE(ID).
as.factor
? $\endgroup$anova(Mod2, Mod5)
compares the fit of the model with and without. A $p$-value for the interaction could be obtained by running a summary, although you'd have to use the packagelmerTest
, aslme4
does not (for good reason) include $p$-values in the summary by default. $\endgroup$\REPEATED
statement whose analogue is not included in R. I think you'd need thenlme
package for that anyway. $\endgroup$