I have a doubt with respect to the estimated marginal means of a linear mixed model. I performed a mixed model like the one in the example below:


model <- lmer(dep_variable ~ covariate * condition + (condition | subject), dataset)

After this, I checked the contrasts:

emmeans(model, pairwise ~ condition)
emmeans(model, pairwise ~ condition | covariate)

I wanted to check which factors (i.e., covariate and condition) affected my dependent variable (i.e., dep_variable). The dependent variable and the covariate were numeric variables, while condition was a factor variable with 3 levels.

After performing the model and checking the estimated marginal means, I realized that the estimated marginal means were the same both when I looked at the main effect condition and when I checked the interaction between covariate and condition.

Moreover, I realized that the contrasts of the interaction were centered at the mean value of the covariate (numeric variable).

I have two questions:

Did I make a mistake? If not, can I change the value of my covariate in order to explore the contrasts by "holding" the covariate to another value (not the mean)?

  • $\begingroup$ By default, only one covariate value is used -- its mean. So the two emmeans calls you show are guaranteed to yield the same results. That is, it doesn't matter whether you explicitly condition on it or not because the same value is used either way. If you use an at specification to specify several covariate values, then you will see an assortment of results in that second call. $\endgroup$
    – Russ Lenth
    Jun 16, 2020 at 0:07

1 Answer 1


When you have interactions, things indeed get more complicated. But what you describe seems valid. That is, you select a specific value for the covariate, and make the pairwise comparisons for the different conditions using this particular value. Also, because you have fitted an interaction model, note that the main effect of condition is interpreted for a specific value of covariate, namely for covariate = 0.

With that in mind, I feel that your question mainly relates to the use of the emmeans package, and therefore, I would suggest having a look at the online documentation. More specifically, in the Interaction Analysis vignette. I would speculate that emmeans(model, pairwise ~ condition) produces results for covariate = mean(covariate) because this is often more relevant than covariate = 0. For example, say that the covariate is age. It makes more sense to produce pairwise comparisons for condition for the average age in your data, than for age = 0 (assuming you have a study on subjects with ages far away from zero).

  • $\begingroup$ It does not use covariate = 0 by default in any situation. i don't know why you say that. $\endgroup$
    – Russ Lenth
    Jun 16, 2020 at 0:11
  • $\begingroup$ @RussLenth I think I said that is uses covariate = mean(covariate) because this is more relevant than covariate = 0. Nonetheless, as always, there are exceptions to the rule. In longitudinal data where I work, covariate is time, and there it makes sense to see what happens at baseline, i.e., at time = 0. $\endgroup$ Jun 16, 2020 at 6:26
  • $\begingroup$ I know you said that, but earlier you said that covariate = 0 is the custom when it is an interaction model. And I don't know anywhere where that is recommended as a routine analysis. $\endgroup$
    – Russ Lenth
    Jun 16, 2020 at 13:15
  • $\begingroup$ @RussLenth what I mean is that the coefficients for the main effect of condition are interpreted for covariate = 0. That is, in the model $\beta_0 + \beta_1 cond + \beta_2 cov + \beta_3 \{cond \times cov\}$, the coefficient $\beta_1$, what I called the main effect of cond is interpreted for cov = 0. $\endgroup$ Jun 17, 2020 at 9:43
  • $\begingroup$ Well, it all depends on the parameterization, but under the default contr.treatment coding, ,(beta_0, bata_2) together give the intercept and slope for the reference level of cond, and (beta0 + beta_1, beta_2 + beta_3) give the intercept and slope for the other level of cond. So really it is beta_0 and beta_2 that have a context with the covariate being zero. $\endgroup$
    – Russ Lenth
    Jun 17, 2020 at 18:53

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.