2
$\begingroup$

I am currently learning statistics with R, and I am a bit confused about how to set custom contrasts for interaction effects. I tried removing the intercept from my model:

m1 <- lmer(RT ~ scale(Item) + POS*Complexity + (1+POS*Complexity|Subject), data=dat) 

->

fm.n <- lmer(RT ~ 0 + scale(Item) + POS*Complexity + (1+POS*Complexity|Subject), data=dat) 

But when I looked at the fixed effects, I was surprised to see that I seemed to be missing an interaction effect: "POSadjective:Complexitysimple".

Fixed effects:
                           Estimate Std. Error      df t value Pr(>|t|)    
scale(Item)                 -0.1613     0.2809 54.5200  -0.574 0.568121    
POSadjective                 5.5122     0.8404  5.2800   6.559 0.000999 ***
POSadverb                    4.8747     0.7015  8.6900   6.948 7.95e-05 ***
POSnoun                      5.1712     0.8536  9.2800   6.058 0.000167 ***
POSverb                      5.8640     1.0955  8.1100   5.353 0.000653 ***
Complexitysimple            -0.9177     1.1226  8.0000  -0.817 0.437313    
POSadverb:Complexitysimple   0.9263     1.8192  7.0500   0.509 0.626161    
POSnoun:Complexitysimple     1.5623     1.5896  7.1800   0.983 0.357649    
POSverb:Complexitysimple     1.3143     1.5350 34.3400   0.856 0.397819    

Am I wrong about missing an interaction effect? Is Complexitysimple some sort of intercept and semantically equivalent to POSadjective:Complexitysimple? If not, what can I do to be able to set contrasts for this interaction?

When I change the model to only include the interaction effects of POS and Complexity, i.e.,

fm.n <- lmer(RT ~ 0 + scale(Item) + POS:Complexity + (1+POS:Complexity|Subject), data=dat) 

"POSadjective:Complexitysimple" is included in the fixed effects.

Fixed effects:
                               Estimate Std. Error      df t value Pr(>|t|)    
scale(Item)                     -0.1613     0.2809 53.7700  -0.574 0.568182    
POSadjective:Complexitycomplex   5.5122     0.8404  5.2200   6.559 0.001046 ** 
POSadverb:Complexitycomplex      4.8747     0.7016  8.6900   6.949 7.97e-05 ***
POSnoun:Complexitycomplex        5.1715     0.8536  8.9600   6.059 0.000192 ***
POSverb:Complexitycomplex        5.8640     1.0955  8.1000   5.353 0.000657 ***
POSadjective:Complexitysimple    4.5945     0.7310 10.0500   6.285 8.88e-05 ***
POSadverb:Complexitysimple       4.8836     1.0687  4.0700   4.570 0.009876 ** 
POSnoun:Complexitysimple         5.8156     0.8664  6.6100   6.712 0.000352 ***
POSverb:Complexitysimple         6.2607     0.9345  6.7200   6.700 0.000332 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

But when I set contrasts for the main and interaction effects in two separate models, I got slightly different results. Any ideas on what I should do? Here is the rest of my code (please excuse the horrible spacing):

library(lme4)
library(multcomp) # glht
dat <- structure(list(Item = c(3L, 5L, 8L, 6L, 5L, 9L, 1L, 4L, 5L, 3L, 
                               8L, 7L, 9L, 5L, 4L, 3L, 3L, 6L, 8L, 6L, 3L, 1L, 3L, 4L, 8L, 5L, 
                               7L, 6L, 4L, 7L, 4L, 4L, 6L, 4L, 9L, 9L, 8L, 5L, 3L, 4L, 6L, 5L, 
                               7L, 1L, 2L, 1L, 8L, 1L, 2L, 4L, 5L, 1L, 1L, 9L, 5L, 9L, 6L, 2L, 
                               3L, 1L, 9L, 3L, 9L, 7L, 4L, 3L, 3L, 6L, 9L, 2L, 5L, 5L, 1L, 6L, 
                               1L, 3L, 9L, 7L, 6L, 3L, 6L, 6L, 7L, 4L, 2L, 8L, 8L, 4L, 9L, 7L, 
                               1L, 8L, 7L, 9L, 2L, 5L, 2L, 4L, 4L, 1L), Subject = c(3L, 1L, 
                                                                                    8L, 5L, 5L, 1L, 4L, 4L, 9L, 5L, 6L, 9L, 5L, 3L, 8L, 7L, 3L, 6L, 
                                                                                    6L, 5L, 5L, 3L, 1L, 5L, 4L, 4L, 8L, 9L, 9L, 1L, 9L, 4L, 1L, 8L, 
                                                                                    4L, 8L, 7L, 3L, 8L, 1L, 2L, 9L, 9L, 1L, 2L, 4L, 9L, 1L, 2L, 4L, 
                                                                                    7L, 8L, 3L, 2L, 9L, 6L, 4L, 3L, 2L, 5L, 1L, 2L, 5L, 5L, 3L, 5L, 
                                                                                    3L, 9L, 2L, 8L, 8L, 9L, 6L, 5L, 9L, 5L, 6L, 3L, 8L, 3L, 9L, 4L, 
                                                                                    7L, 8L, 2L, 1L, 6L, 3L, 6L, 7L, 1L, 8L, 6L, 3L, 9L, 1L, 1L, 8L, 
                                                                                    1L, 8L), RT = c(9L, 9L, 4L, 8L, 5L, 6L, 3L, 2L, 9L, 4L, 7L, 2L, 
                                                                                                    9L, 8L, 9L, 5L, 3L, 1L, 8L, 6L, 2L, 5L, 3L, 7L, 1L, 7L, 3L, 8L, 
                                                                                                    7L, 3L, 1L, 1L, 5L, 2L, 7L, 9L, 5L, 8L, 1L, 5L, 7L, 1L, 7L, 6L, 
                                                                                                    6L, 8L, 8L, 9L, 7L, 4L, 8L, 6L, 6L, 2L, 9L, 2L, 9L, 1L, 5L, 3L, 
                                                                                                    1L, 3L, 4L, 8L, 8L, 9L, 7L, 8L, 3L, 3L, 6L, 9L, 4L, 3L, 8L, 9L, 
                                                                                                    9L, 1L, 2L, 9L, 4L, 6L, 6L, 8L, 9L, 7L, 4L, 8L, 4L, 1L, 9L, 1L, 
                                                                                                    2L, 9L, 7L, 5L, 7L, 1L, 4L, 3L), Complexity = structure(c(2L, 
                                                                                                                                                              2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 
                                                                                                                                                              2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 
                                                                                                                                                              1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 
                                                                                                                                                              2L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 
                                                                                                                                                              1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 
                                                                                                                                                              1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 
                                                                                                                                                              2L, 2L, 1L), .Label = c("complex", "simple"), class = "factor"), 
                      POS = structure(c(4L, 4L, 3L, 1L, 1L, 3L, 4L, 3L, 3L, 2L, 
                                        2L, 2L, 4L, 2L, 3L, 1L, 2L, 1L, 3L, 3L, 2L, 3L, 2L, 1L, 1L, 
                                        4L, 4L, 3L, 4L, 3L, 1L, 3L, 3L, 1L, 4L, 1L, 2L, 2L, 1L, 2L, 
                                        4L, 4L, 3L, 1L, 3L, 4L, 1L, 1L, 3L, 1L, 1L, 1L, 1L, 2L, 2L, 
                                        2L, 2L, 2L, 3L, 2L, 4L, 1L, 2L, 2L, 4L, 2L, 1L, 1L, 1L, 3L, 
                                        4L, 3L, 1L, 2L, 3L, 3L, 4L, 3L, 1L, 4L, 2L, 4L, 3L, 1L, 4L, 
                                        4L, 2L, 3L, 1L, 4L, 2L, 2L, 3L, 4L, 1L, 1L, 2L, 4L, 3L, 1L
                      ), .Label = c("adjective", "adverb", "noun", "verb"), class = "factor")), .Names = c("Item", 
                                                                                                           "Subject", "RT", "Complexity", "POS"), class = "data.frame", row.names = c(NA, 
                                                                                                                                                                                      -100L))


m1 <- lmer(RT ~ scale(Item) + POS*Complexity + (1+POS*Complexity|Subject), data=dat) 
summary(m1)
fixef(m1)

#Removed intercept for contrasts:
fm.n <- lmer(RT ~ 0 + scale(Item) + POS*Complexity + (1+POS*Complexity|Subject), data=dat) 
summary(fm.n)
fixef(fm.n)
summary(glht(fm.n,linfct=matrix(c(0,0,0,0,0,.5,-.5,0,0),1,9)))
$\endgroup$

Your Answer

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

Browse other questions tagged or ask your own question.