0

I have a glm that I would like to get adjusted means for using lsmeans. The following code makes the model (and seems to be doing it correctly):

library(lmerTest)
data$group <- as.factor(data$grp)
data$site <- as.factor(data$site)
data$stimulus <- as.factor(data$stimulus)

data.acc1 = glmer(accuracy ~ site + grp*stimulus + (1|ID), data=data, family=binomial)

However, using when I try to use any of the below code to get adjusted means for the model, I get the error

Error in lsmeansLT(model, test.effs = test.effs, ddf = ddf) :
The model is not linear mixed effects model.

lsmeans(data.acc1, "stimulus")

or

data.lsm <- lsmeans(data.acc1, accuracy ~ stimulus ~ grp)
pairs(data.lsm)

Any suggestiongs?

wjchulme
  • 1,928
  • 1
  • 18
  • 28
user5826447
  • 357
  • 1
  • 5
  • 13
  • 1
    Possible duplicate of [I can't get lsmeans output in glmer](http://stackoverflow.com/questions/28752417/i-cant-get-lsmeans-output-in-glmer) – wjchulme Mar 20 '17 at 16:40
  • The error message comes from the **lmerTest** package. Try the **lsmeans** package instead. – Russ Lenth Mar 23 '17 at 03:13

1 Answers1

1

The problem is that you have created a generalised linear mixed model using glmer() (in this case a mixed logistic regression model) not a linear mixed model using lmer(). The lsmeans() function does not accept objects created by glmer() because they are not linear mixed models.

Answers in this post might help: I can't get lsmeans output in glmer

And this post might be useful if you want to understand/compute marginal effects for mixed GLMs: Is there a way of getting "marginal effects" from a `glmer` object

Community
  • 1
  • 1
wjchulme
  • 1,928
  • 1
  • 18
  • 28