Pairwise comparisons on lmer using lsmeans or difflsmeans

Viewed 5117

I am doing a reading experiment, comparing reading times in 2 groups across 4 conditions. I ran a lmer model with reading condition (factor w 4 levels) and group (factor w 2 levels) as the predictors and fixation duration as the dependent variable (numeric).

m1= lmer(IA_FIRST_FIXATION_DURATION ~ condition * group + (1 + condition + group | PARTICIPANT_ID) + (1 | TRIAL_LABEL), data=subset(NWC1, IA_ID == "2"))

Here is part of the output:

 Fixed effects:
                          Estimate Std. Error      df t value Pr(>|t|)    
(Intercept)                232.341      8.802 106.000  26.395  < 2e-16 ***
conditionFamUn              -2.122     11.193 462.900  -0.190 0.849742    
conditionNovelInf           37.234     11.547 146.300   3.225 0.001556 ** 
conditionNovelUn            44.425     11.897 133.100   3.734 0.000278 ***
groupL2                     68.245     15.381  60.200   4.437 3.95e-05 ***
conditionFamUn:groupL2     -11.414     15.710 586.700  -0.727 0.467783    
conditionNovelInf:groupL2  -15.760     16.536 127.300  -0.953 0.342374    
conditionNovelUn:groupL2   -20.165     16.948 117.000  -1.190 0.236515  

I need to do pairwise comparisons and in the past I have used lsmeans. Now it is deprecated and when I use lsmeansLT, I get the following error message:

lsmeansLT(m1, pairwise~ condition *group)
Error in match(x, table, nomatch = 0L) : 'match' requires vector arguments

I do not understand what this error message means.

I also tried difflsmeans and it works (see sample output below). But difflsmeans does not correct the p value for multiple comparisons.

> difflsmeans(m1, test.effs=NULL, ddf="Satterthwaite")
Differences of LSMEANS:
                                            Estimate Standard Error    DF t-value Lower CI Upper CI p-value  
condition:group  FamInf L1 -  FamUn L1           2.1          11.19 463.0    0.19   -19.87    24.12   0.850    
condition:group  FamInf L1 -  NovelInf L1      -37.2          11.55 146.3   -3.22   -60.05   -14.41   0.002 ** 
condition:group  FamInf L1 -  NovelUn L1       -44.4          11.90 133.1   -3.73   -67.96   -20.89   3e-04 ***
condition:group  FamInf L1 -  FamInf L2        -68.2          15.38  60.2   -4.44   -99.01   -37.48  <2e-16 ***
condition:group  FamInf L1 -  FamUn L2         -54.7          14.65  83.5   -3.73   -83.85   -25.57   3e-04 ***
condition:group  FamInf L1 -  NovelInf L2      -89.7          18.60  48.1   -4.82  -127.12   -52.31  <2e-16 ***

Can anyone provide a solution? I can either understand and fix the error of lsmeansLT or somehow adjust the p values and keep using difflsmeans. (I have loaded the lsmeans and lmerTest libraries) Thank you!

2 Answers

With the lsmeans package?

library(lme4)
m1 <- lmer(Informed.liking ~ Gender*Information +(1|Consumer), data=ham)

library(lsmeans)
lsmeans(m1, pairwise ~ Gender:Information)

#$lsmeans
# Gender Information   lsmean        SE     df lower.CL upper.CL
# 1      1           5.707317 0.2174879 153.61 5.277664 6.136970
# 2      1           5.556250 0.2201897 153.61 5.121259 5.991241
# 1      2           6.000000 0.2174879 153.61 5.570347 6.429653
# 2      2           5.662500 0.2201897 153.61 5.227509 6.097491

#Degrees-of-freedom method: satterthwaite 
#Confidence level used: 0.95 

#$contrasts
# contrast     estimate        SE     df t.ratio p.value
# 1,1 - 2,1  0.15106707 0.3094907 153.61   0.488  0.9616
# 1,1 - 1,2 -0.29268293 0.2347185 565.00  -1.247  0.5972
# 1,1 - 2,2  0.04481707 0.3094907 153.61   0.145  0.9989
# 2,1 - 1,2 -0.44375000 0.3094907 153.61  -1.434  0.4803
# 2,1 - 2,2 -0.10625000 0.2376343 565.00  -0.447  0.9702
# 1,2 - 2,2  0.33750000 0.3094907 153.61   1.091  0.6959
# 
#P value adjustment: tukey method for comparing a family of 4 estimates 

I changed the * in your code to | and I used lsmeans and it works fine.

lsmeans(m1, pairwise ~ condition|group)

Related