9
$\begingroup$

In R, if I call the lm() function in the following way:

lm.1 = lm(response ~ var1 + var2 + var1 * var2)
summary(lm.1)

This gives me a linear model of the response variable with var1, var2 and the interaction between them. However, how exactly do we numerically interpret the interaction term?

The documentation says this is the "cross" between var1 and var2, but it didn't give an explanation of what exactly the "cross" is.

It would be helpful for me to know what exact numbers R is calculating to incorporate the interaction between the two variables.

$\endgroup$
  • $\begingroup$ Would you like to specifically know how R creates the design matrix for this formula, or are you more broadly interested in how to interpret such a multiplicative ("interaction") term in terms of the fitted model? $\endgroup$ – Momo Apr 21 '13 at 20:35
  • $\begingroup$ I'm more interested in how to interpret this multiplicative term. For example, if I want to write out a linear formula (a mathematical one, not a R one...), what should I put in for the multiplicative term? $\endgroup$ – Enzo Apr 21 '13 at 20:36
  • $\begingroup$ To explain what cross means, have a look at calculating var3 <- var 1 * var2 then building lm.2 <- lm(response ~ var1 + var2 + var3) $\endgroup$ – James Stanley Apr 21 '13 at 21:50
  • 1
    $\begingroup$ so it's simply entry-wise multiplication? $\endgroup$ – Enzo Apr 21 '13 at 22:07
  • 1
    $\begingroup$ @Enzo, yes, the cross is literally the two terms multiplied -- interpretation will largely depend on whether var1 and var2 are both continuous (quite hard to interpret, in my opinion) or whether one of these is e.g. binary categorical (easier to consider.) See this answer for some interpretation examples by Peter Flom: stats.stackexchange.com/a/45512/16974 $\endgroup$ – James Stanley Apr 21 '13 at 22:37
8
$\begingroup$

The standard way to write the prediction equation for your model is:

$\hat y = b_0 + b_1*x_1 + b_2*x_2 + b_{12} * x_1 *x_2$

But understanding the interaction is a little easier if we factor this differently:

$\hat y = (b_0 + b_2*x_2) + (b_1 + b_{12}*x_2) * x_1$

With this factoring we can see that for a given value of $x_2$ the y-intercept for $x_1$ is $b_0 + b_2*x_2$ and the slope on $x_1$ is $(b_1 + b_{12}*x_2)$. So the relationship between $y$ and $x_1$ depends on $x_2$.

Another way to understand this is by plotting the predicted lines between $y$ and $x_1$ for different values of $x_2$ (or the other way around). The Predict.Plot and TkPredict functions in the TeachingDemos package for R were designed to help with these types of plots.

$\endgroup$
3
$\begingroup$

Suppose you get point estimates of 4 for $x_1$, 2 for $x_2$ and 1.5 for the interaction. Then, the equation is saying that the lm fit is

$y = 4x_1 + 2x_2 + 1.5x_1x_2$

Is that what you wanted?

$\endgroup$
3
$\begingroup$

It is easiest to think about interactions in terms of discrete variables. Perhaps you might have studied two-way ANOVAs, where we have two grouping variables (e.g. gender and age category, with three levels for age) and are looking at how they pertain to some continuous measure (our dependent variable, e.g. IQ).

The x1 * x2 term, if significant, can be understood (in this trivial, made-up example) as IQ behaving differently across the levels of age for the different genders. For example, maybe IQ is stable for males across the three age groups, but young females start below young males and have an upward trajectory (with the old age group having a higher mean than the old age group for males). In a means plot, this would imply a horizontal line for males in the middle of the graph, and perhaps a 45 degree line for females that starts below males but ends above males.

The gist is that as you move along the levels of one variable (or "holding X1 constant"), what is going on in the other variable changes. This interpretation also works with continuous predictor variables, but is not so easy to illustrate concretely. In that case, you might want to take particular values of X1 and X2 and see what happens to Y.

$\endgroup$

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.