I hope my question is not too basic for this community. I can*t figure out how to interpret the output of my linear mixed model, especially the interaction effects.

I do my analysis in R using lme from the nlme package. My model consists of 3 factorial IVs (exp.type [2 levels - field vs. lab], org.type [3 levles - autotroph, heterotroph, mixed], system [2 levels - marine vs. freshwater]) and 2 numeric IVs (even, duration).

lme1 = lme(reist ~ even + exp.type + even:exp.type + org.type + even:org.type + system + duration, random =~1|authors.year, data = data)

output of the linear model

My question is: How do I interpret the interaction effects? How do I get the slopes of the linear regressions for each level of the IVs that have significant interactions

  • $\begingroup$ You could take a look at this online tool to probe interactions in multilevel models: quantpsy.org/interact/hlm2.htm. Among other things, it does provide you with simple slopes. $\endgroup$ Sep 19, 2013 at 17:22

2 Answers 2


When there is an interaction, there is no unique slope for any of the main effects; those change based on other variables in the interaction.

I have found that the simplest method of interpreting interactions is visually: make graphs of your DV at different levels of your IVs. Since you have two numeric IVs and 3 categorical ones, you could make 6 graphs. For each, plot one numeric IV on the x axis and the predicted value of the DV on the Y axis, with a line for each level of one of the categorical DVs (you will have to make some assumptions about the value of the other IVs - the mean for the continuous and the mode for the categorical may be sensible).

Alternatively, you could make a lattice plot (using the lattice package) or use faceting (with the ggplot2 package).

Another way to go is to make a table of the predicted values of the DV for various common combinations of the IVs. (E.g. the quartiles of the two continuous IVs and all the values of the DVs - which would give a table with 3*3*3*2*2 = 108 rows.

As to what the interactions mean - an interaction means that the relationship between one IV and the DV is different at different levels of the other IV.

  • $\begingroup$ Hello, thanks a lot for your detailed answer. I understand why one should ignore main effects in the face of significant interactions. I already plotted predicted values for each level but I'm not sure if I understood the part where you wrote: "with a line for each level of one of the categorical DVs". $\endgroup$
    – Frize
    Sep 16, 2013 at 10:03
  • $\begingroup$ The categorical IVs (that was a typo, it should be IV) each have a fixed number of levels (2 or 3 in your case, depending on which IV) so you can make one line for each of them. $\endgroup$
    – Peter Flom
    Sep 16, 2013 at 10:23
  • $\begingroup$ ok, thanks :) Thats basically what I did to find the slopes of each level. Comparing these to the data above I then found that "Evenness" in the table above is in fact only the slope of the regression between evenness and resistance BUT! only for exp.type field and autotrophic organisms (so first levels of both IVs). The slope of exp.type lab (still autotrophic) is then the -2.59 + the interaction term for exp.type lab (2.66 = 0.65 or so). So thats for autorophic organisms only... $\endgroup$
    – Frize
    Sep 16, 2013 at 11:50
  • $\begingroup$ If I then add the interaction of evennessorg.type heterotroph (4.01) to the slope of autotrophic field studies (-2.59) I get exactly the slope that I calculated for heterotrophic field studies (calculated via slope of predicted values). If I add the 4.01 from the heterotropic interaction to the 0.65 from above (instead of -2.59) I get exactly the slope of heterotrophic lab studies that i calculated from the predicted values. The same holds true for the 3.Interaction (evennessorganism type mixed = 6.01). This might seem a little confusing but this way I can extract the slopes from the table $\endgroup$
    – Frize
    Sep 16, 2013 at 11:59
  • $\begingroup$ Even though the slopes that I calculated from the predicted values fit nicely to that table, im not shore if this is the right interpretation of the table above, as it is not very intuitive. I hope I didnt confuse you too much. Don't know how to put it more precisely :/ $\endgroup$
    – Frize
    Sep 16, 2013 at 12:02

Short update: I was wrong in my interpretation, allthough it fits nicely. I did the same analysis using a simple artificial data set w/o mixed effects (allowing me to fit individual lm for each level of both factors:

a = c(rep(1:10, 4))
b = c(10,20,30,40,50,60,70,80,90,100, 5,8,10,14,17,22,27,35,42,50, 90,82,73,64,56,48,40,33,25,18, 5,6,8,10,12,14,17,20,23,26)
c = c(rep("male", 10), rep("female", 10), rep("male", 10), rep("female", 10))
d = c(rep("low", 20), rep("high", 20))
e = data.frame(yval = b, xval = a, sex = c, education = d)

scatterplot(yval~xval | education, smooth = F, grid = T, spread = F, reg.line = T, data = e, xlab = "x", ylab = "y") 

lm2 = lm(yval~xval+sex+xval:sex+education+xval:education, data = e)

It turns out that the interaction for the levels of factor A are calculated while ignoring the interaction between the levels of factor B (seeing that I remember that I learned something like that long ago for simple ANOVAs... :).

Strangely, the way I calculated the slopes above in my first post still works, giving the exact numbers from the table output, but completely wrong slopes :)


new_data_lm = expand.grid(xval = c(1:10), sex = c("female", "male"), education = c("high", "low"))
new_data_lm$pred = predict(lm2, new_data_lm, level = 0)

gives a table with predicted y values for given x values.

When calculating the slopes of these predicted values for each level ob the interactions:

lm_f_h = lm(pred~xval, data = subset(new_data_lm, sex == "female"& education == "high"))
lm_f_l = lm(pred~xval, data = subset(new_data_lm, sex == "female"& education == "low"))

gives us the slope -1.503 (for female_high) and 8.794 (for female_low). Both slopes are completely wrong but when added together, they give the exact number for the interaction "xval:educationlow" (10.297) from the output of:


The same holds true when calculating the difference in slopes between male_high and female_high giving us -2.667, which is exactly what summary(lm2) gives us for the interaction xval:sex_male.

So all in all I managed to find out how to read the table but I don't understand what I did wrong and why it still fits. Have to think about that very thoroughly. When predicting the y values from the model by predict(lme2) (so without the additional "new_data" argument), the values of the slopes are correct, but when adding a "new_data" argument with x-values to predict from, the slopes dont match, the interaction terms howver, do?! So whats the difference between these two approaches? What did I miss?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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