# How to interpret results of interaction regression in R

Suppose I have the regression in R

lm(formula = income ~ ageQuartile * (numYearsWorking + numHoursPerWeekWorking))


and in R, I get results like:

                                        Estimate
(Intercept)                             12.94520
ageqtile2                                6.63428
ageqtile3                               12.64004
numYearsWorking                          4.25382
numHoursPerWeekWorking                  17.98021
ageqtile2:numYearsWorking                9.98316
ageqtile3:numYearsWorking               12.81078
ageqtile2:numHoursPerWeekWorking        15.35733
ageqtile3:numHoursPerWeekWorking        20.34312


(these numbers are made up and probably dont make sense).

How do I interpret this? Say I wanted to predict the income of someone in the first age quartile; is that just

$12.94520+4.2538*numYearsWorking+17.98021*numHoursPerWeekWorking$

And how does this change as I want to examine different quartiles?

Yes, that's what you need to do. And for an observation from the second age quartile : $$12.94520+4.2538∗numYearsWorking+17.98021∗numHoursPerWeekWorking+9.98316*numYearsWorking+15.35733*numHoursPerWeekWorking$$

For interpretation, for example if you want the marginal effect of numHoursPerWeekWorking given age quartile==2, you just have to derivate and it gives : $17.98021 + 15.35733$

• But then where is the information "ageqtile2= 6.63428 " used? – Khan Aug 10 '15 at 15:32
• Yes, I'm sorry, I missed it for the first expression ! It is : 12.94520+ 6.63428 + 4.2538∗numYearsWorking+17.98021∗numHoursPerWeekWorking+9.98316∗numYearsWorking+15.35733∗numHoursPerWeekWorking – Martin Aug 11 '15 at 6:43

Assuming the results are the default dummy contrasts R uses, then the intercept is the effect of the reference (first) level of ageqtile. Subsequent levels are coded as the additional offset in DV moving from the reference level to that level. So the "ageqtile2= 6.63428" is used in the prediction by adding 6.6 to the prediction for rows where (ageqtile==2).

You can get these coefficients with coef(). You can get the predicted y values with predict(model) and use these to check your work.

It helps to have a running example:

df = mtcars
m1 =lm(mpg ~ factor(am) * disp, data = mtcars)
coef(m1)
# (Intercept)      factor(am)1             disp factor(am)1:disp
# 25.15706407       7.70907298      -0.02758360      -0.03145482


We can generate our own pred column, to check understanding of the coefficients:

b = coef(m1)

df = within(df, {

pred = (b["(Intercept)"]

+ ((am=="1") * b["factor(am)1"])

+ (disp      * b["disp"])

+ ((am=="1") * disp * b["factor(am)1:disp"]))

})

any(predict(m1)!=df\$pred)
#  FALSE