I have a generalised linear mixed effect model with 5 fixed effects and two by-subject and by-item random intercepts. The outcome variable (Slide4_YesNo) is the participants' responses in a recognition memory task (Old = 1, New = 0). Old_Lure is the condition (i.e. Old, lure) and it is a factor with two levels. The other 4 fixed effect variables are some metrics.

This is my code:
model_glmer <- glmer(Slide4_YesNo ~ ZcNOF * Old_Lure + ZcMeanS * Old_Lure + 
ZcMeanCorStrWithin * Old_Lure + ZcSlope * Old_Lure + 
                (1 | Subject) +
                (1 | WordCat),
                family = "binomial",
                #nAGQ = 0,
                control = glmerControl(optCtrl=list(maxfun=6e4)), # <- this 
                is the controller, it means running to 60000 times
                data = pilot)

This is the outcome:

Fixed effects:
                           Estimate Std. Error z value Pr(>|z|)    
(Intercept)                    -2.11101    0.11298  -18.68  < 2e-16 ***
ZcNOF                           0.18156    0.08554    2.12 0.033807 *  
Old_LureOld                     4.00050    0.10043   39.83  < 2e-16 ***
ZcMeanS                         0.06337    0.09008    0.70 0.481798    
ZcMeanCorStrWithin             -0.08477    0.08046   -1.05 0.292105    
ZcSlope                        -0.24221    0.07932   -3.05 0.002261 ** 
ZcNOF:Old_LureOld              -0.49962    0.10051   -4.97 6.66e-07 ***
Old_LureOld:ZcMeanS            -0.30082    0.10894   -2.76 0.005756 ** 
Old_LureOld:ZcMeanCorStrWithin -0.03581    0.10051   -0.36 0.721625    
Old_LureOld:ZcSlope             0.35940    0.09247    3.89 0.000102 ***

I would like to test memory discrimination, in terms of the degree to which the probabiilty of responding old vs lure (slide4_YesNo, 1 or 0), depends on whether items are old or lure (Old_Lure, condition) when it interacts with some continuous metrics. So I am interested in the interactions (last four results). Basically I want to see the difference between conditions when holding the continuous variables. I guess I need some contrasts here, but I do not understand how to do them with multiple continuous variables. Any idea? Thank you


I think perhaps what you are looking for is a comparison of slopes of each of those continuous predictors, holding the others fixed. This can be done using the emmeans (estimated marginal means) package and emtrends() function.

emt1 <- emtrends(model_glmer, "Old_Lure", var = "ZcNOF")
emt1          ### estimated slopes of ZcNOF for each level of Old_Lure
pairs(emt1)   ### comparison of slopes

The estimated slopes, I believe, will be 0.18156 for Lure, and 0.18156 - 0.49962 = -.30186 for Old (based on the coefficients table). In other words, under the Lure condition, the logit probability of responding increases by .18 per unit change of ZcNOF, while for the Old condition, the logit probability decreases by .30 per unit change of ZcNOF.

And the difference will be -.49962, with an SE of .10051, a z ratio of -4.97, and a minuscule P value. In other words, since you have only one factor and it has only 2 levels, you can glean all the results you need from the table of regression coefficients. However, the emtrends function becomes considerably more useful with more complex situations.

A similar analysis applies to each of the other covariates.

  • 1
    $\begingroup$ This was very useful. Thanks. May I ask you another question. These data are based on a pilot study. In the current study, I added another level in my categorical variable (i.e., the condition Old_Lure became with 3 levels, OLD, LURE, NEW). The continuous variables remained the same, though. What does it change in term of analysis? I guess I will have two slope for the two non-baseline levels with their interactions. Shall i compare them or it is still the same? Thank you in advance $\endgroup$ – Lollo Feb 24 '18 at 14:09
  • $\begingroup$ That's when the emmeans package starts becoming useful. If you use the code shown, emtrends will estimate all 3 slopes, and pairs will estimate and test all three pairwise comparisons of slopes. You can get only two of those comparisons directly from the coefficients. $\endgroup$ – rvl Feb 24 '18 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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