2
$\begingroup$

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).
$\endgroup$
8
  • $\begingroup$ Is it possible that R is not recognizing a grouping variable in my data? I'm not sure how to identify this or correct it $\endgroup$ Commented Jun 30, 2019 at 20:35
  • $\begingroup$ Are all grouping variables declared somewhere as.factor? $\endgroup$
    – BruceET
    Commented Jun 30, 2019 at 21:55
  • 1
    $\begingroup$ Your question title suggests you are interested in the $p$-value of the interaction effect, but 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 package lmerTest, as lme4 does not (for good reason) include $p$-values in the summary by default. $\endgroup$ Commented Jun 30, 2019 at 22:58
  • $\begingroup$ I don't think the models are equivalent: In SPSS, you include the \REPEATED statement whose analogue is not included in R. I think you'd need the nlme package for that anyway. $\endgroup$ Commented Jul 1, 2019 at 5:45
  • 1
    $\begingroup$ @COOLSerdash You're right, I completely overlooked that. Thank you! I will try nlme $\endgroup$ Commented Jul 1, 2019 at 19:29

0

Your Answer

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

Browse other questions tagged or ask your own question.