rlsmeanslmertest

Why do I get empty results with ls_means statement in lmerTest?


Here's my data:

subject     arm treat   bline   change
'subject1'  'L' N   6.3597  4.9281
'subject1'  'R' T   10.3499 1.8915
'subject3'  'L' N   12.4108 -0.9008
'subject3'  'R' T   13.2422 -0.7357
'subject4'  'L' T   8.7383  2.756
'subject4'  'R' N   10.8257 -0.531
'subject5'  'L' N   7.1766  2.0536
'subject5'  'R' T   8.1369  1.9841
'subject6'  'L' T   10.3978  9.0743
'subject6'  'R' N   11.3184  3.381
'subject8'  'L' T   10.7251  2.9658
'subject8'  'R' N   10.9818  2.9908
'subject9'  'L' T   7.3745   2.9143
'subject9'  'R' N   9.4863  -3.0847
'subject10' 'L' T   11.8132  -2.1629
'subject10' 'R' N   9.5287   0.1401
'subject11' 'L' T   8.2977   6.2219
'subject11' 'R' N   9.3691   0.7408
'subject12' 'L' T   12.6003  -0.7645
'subject12' 'R' N   11.7329  0.0342
'subject13' 'L' N   9.4918  2.0716
'subject13' 'R' T   9.6205  1.5705
'subject14' 'L' T   9.3945  4.6176
'subject14' 'R' N   11.0176 1.445
'subject16' 'L' T   8.0221  1.4751
'subject16' 'R' N   9.8307  -2.3697

When I fit a mixed model with treat and arm as factors:

m <- lmer(change ~ bline + treat + arm + (1|subject), data=change1)
ls_means(m, which = NULL, level=0.95, ddf="Kenward-Roger")

The ls_means statement returns no result. Can anyone help with what is going wrong?


Solution

  • I too see empty results:

    > ls_means(m, which = NULL, level=0.95, ddf="Kenward-Roger")
    Least Squares Means table:
    
         Estimate Std. Error df t value lower upper Pr(>|t|)
    
      Confidence level: 95%
      Degrees of freedom method: Kenward-Roger 
    

    However, the emmeans package works fine. You can use emmeans() or lsmeans() -- the latter just re-labels the emmeans() results. "Estimated marginal means" is a more generally-appropriate term.

    > library(emmeans)
    > lsmeans(m, "treat")
     treat lsmean   SE df lower.CL upper.CL
     N      0.996 0.72 15   -0.539     2.53
     T      2.290 0.72 15    0.755     3.82
    
    Results are averaged over the levels of: arm 
    Degrees-of-freedom method: kenward-roger 
    Confidence level used: 0.95 
    
    > lsmeans(m, "arm")
     arm lsmean    SE   df lower.CL upper.CL
     L     1.97 0.737 15.6    0.403     3.53
     R     1.32 0.737 15.6   -0.248     2.88
    
    Results are averaged over the levels of: treat 
    Degrees-of-freedom method: kenward-roger 
    Confidence level used: 0.95 
    

    I suspect that lmerTest::ls_means() does not support predictors of class "character". If you change treat and arm to factors, it may work.