3

I fit a linear mixed effect model to my data with random slopes.

fit = lmer(ouput_measure ~ log(amplitude) * injury + (0 + log(amplitude) | subject), 
           data = df, REML = FALSE)

The output summary of this model contains estimates, confidence intervals, and p values for each of the predictors: (Intercept), amplitude[log], injury[yes], amplitude[log]*injury[yes].

I interpret the estimate for amplitude[log]*injury[yes] as being the difference in slope of the output_measure vs. amplitude[log] line between the two levels of the categorical variable injury (yes, no).

I would like to obtain the estimate for amplitude[log]*injury[yes] and also for amplitude[log]*injury[no] rather than only the difference between these two slopes. Is there a way I can do this?

Ian Malone
  • 33
  • 5

1 Answers1

3

This isn't really a question about mixed models, but rather the interpretation of the intercept in linear models in general.

Suppose I run:

> levels(iris$Species)
[1] "setosa"     "versicolor" "virginica" 

> summary(lm(Sepal.Length ~ Species, iris))

Call:
lm(formula = Sepal.Length ~ Species, data = iris)

Residuals:
    Min      1Q  Median      3Q     Max 
-1.6880 -0.3285 -0.0060  0.3120  1.3120 

Coefficients:
                  Estimate Std. Error t value Pr(>|t|)    
(Intercept)         5.0060     0.0728  68.762  < 2e-16 ***
Speciesversicolor   0.9300     0.1030   9.033 8.77e-16 ***
Speciesvirginica    1.5820     0.1030  15.366  < 2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.5148 on 147 degrees of freedom
Multiple R-squared:  0.6187,    Adjusted R-squared:  0.6135 
F-statistic: 119.3 on 2 and 147 DF,  p-value: < 2.2e-16

Here I have an effect of versicolor and virginica, but not of setosa. This is because the setosa is taken to be the reference group. Its estimate is 5.0060, and shown below are the differences from this group (i.e. versicolor is 5.0060 + 0.9300, virginica is 5.0060 + 1.5820.

The same goes for your model:

  • The intercept is the value of the outcome where log(amplitude) is equal to zero and injury is equal to "no";
  • Adding the estimate for injuryyes to the intercept gives you the value of the outcome where log(amplitude) is equal to zero and injury is equal to "yes";
  • The estimate for log(amplitude) is the slope for injuryno;
  • The estimate for log(amplitude):injuryyes is the difference from the slope for injuryyes.

If you prefer a summary where injuryyes is in the intercept, you can change the reference group by using relevel.

If you really want your model to show a separate estimate for injuryno and injuryyes, you could technically do that by removing the intercept with lmer(ouput_measure ~ 0 + log(amplitude) * injury + ..., but this is rarely a valid approach.

Frans Rodenburg
  • 10,376
  • 2
  • 25
  • 58
  • Thanks so much! I originally plotted the difference estimate, `log(amplitude):injury[yes]`, as a point with error bars indicating the conf int and asterisks indicating p val. However, I think it is more informative if I plot each slope. Is it valid to plot the estimate `log(amplitude)` and plot `log(amplitude):injury[yes] + log(amplitude)` to show the slope for the `injury[no]` group and the `injury[yes]` group, respectively? And the conf int for the `injury[yes]` slope would be the `log(amplitude)` estimate added to the conf int for the `log(amplitude):injury[yes]` estimate? – Ian Malone Jun 08 '21 at 23:08