Cole Robertson
Cole Robertson

Reputation: 639

lsmeans and difflsmeans return no output for lmer object

I'm trying to calculate the confidence intervals for fixed effects in an lmer mixed model, and difflsmeans and lsmeans simply return an empty table. I've tried lme() but am having trouble with model convergence (hence using lmer).

The data look like this (where bout is the dependent level 1 variable and TWaverage is the independent level 2 variable of interest and sex, location and RA are further nesting levels):

ID  bout TWaverage  sex location    RA
1   17  3.748333333 1   Big Society 1337
1   59  3.748333333 1   Big Society 1337
1   14  3.748333333 1   Big Society 1337
1   9   3.748333333 1   Big Society 1337
1   9   3.748333333 1   Big Society 1337
1   14  3.748333333 1   Big Society 1337
1   21  3.748333333 1   Big Society 1337
2   40  3.055833333 0   Big Society 1337
2   63  3.055833333 0   Big Society 1337
2   7   3.055833333 0   Big Society 1337
2   75  3.055833333 0   Big Society 1337
2   13  3.055833333 0   Big Society 1337
2   3   3.055833333 0   Big Society 1337
2   16  3.055833333 0   Big Society 1337
3   103 3.696666667 1   Big Society 1337
3   14  3.696666667 1   Big Society 1337
3   2   3.696666667 1   Big Society 1337
3   32  3.696666667 1   Big Society 1337

My model specification looks like this:

groupSizeRandom = lmer(bout ~ TWaverage + (TWaverage|ID), data, REML = F)

I'm calling the lsmeans like this (which I understand should give me the confidence intervals for all fixed effects in the model):

lsmeans(groupSizeRandom,test.effs = NULL)

However, it only returns an empty table (with no values):

Least Squares Means table:
     Estimate Standard Error DF t-value Lower CI Upper CI p-value

Anyone know why? Or how to calculate the CIs for the model I've specified above?

Upvotes: 3

Views: 1911

Answers (1)

Ben Bolker
Ben Bolker

Reputation: 226182

There are a few issues here.

  • If you just want the confidence intervals of the fixed-effect parameters, you can get likelihood profile CIs via confint(groupSizeRandom) or Wald CIs via confint(groupSizeRandom,method="Wald") (see ?confint.merMod).
  • as pointed out in the comments, there are two lsmeans functions
    • lmerTest::lsmeans will only report lsmeans for factor variables. As also pointed out in the comments, "factor" has a specific meaning in R - it means a categorical predictor (independent) variable. TWaverage is a continuous predictor, so in R terms it's not a "factor".
    • lsmeans::lsmeans will give you what you ask for if you use lsmeans(groupSizeRandom,spec="TWaverage") ...

Upvotes: 2

Related Questions