I'm using R to fit the following linear regression models with the popular "mtcars" dataset:
data(mtcars)
fit1 <- lm(mpg ~ factor(am) + factor(cyl), mtcars)
fit2 <- lm(mpg ~ factor(am) * factor(cyl), mtcars)
When I take the summary of each model, I get:
For the model without interaction:
Call:
lm(formula = mpg ~ factor(am) + factor(cyl), data = mtcars)
Residuals:
Min 1Q Median 3Q Max
-5.9618 -1.4971 -0.2057 1.8907 6.5382
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 24.802 1.323 18.752 < 2e-16 ***
factor(am)1 2.560 1.298 1.973 0.058457 .
factor(cyl)6 -6.156 1.536 -4.009 0.000411 ***
factor(cyl)8 -10.068 1.452 -6.933 1.55e-07 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 3.073 on 28 degrees of freedom
Multiple R-squared: 0.7651, Adjusted R-squared: 0.7399
F-statistic: 30.4 on 3 and 28 DF, p-value: 5.959e-09
For the model with interaction:
Call:
lm(formula = mpg ~ factor(am) * factor(cyl), data = mtcars)
Residuals:
Min 1Q Median 3Q Max
-6.6750 -1.1000 0.1125 1.6875 5.8250
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 22.900 1.751 13.081 6.06e-13 ***
factor(am)1 5.175 2.053 2.521 0.018176 *
factor(cyl)6 -3.775 2.316 -1.630 0.115155
factor(cyl)8 -7.850 1.957 -4.011 0.000455 ***
factor(am)1:factor(cyl)6 -3.733 3.095 -1.206 0.238553
factor(am)1:factor(cyl)8 -4.825 3.095 -1.559 0.131069
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 3.032 on 26 degrees of freedom
Multiple R-squared: 0.7877, Adjusted R-squared: 0.7469
F-statistic: 19.29 on 5 and 26 DF, p-value: 5.179e-08
Using these models as examples, I would like to know:
How do you interpret the coefficient of the reference group in each case? (I know how to interpret these and the coefficients of each variable in the case when I fit mpg with just one dummy variable. But I can't find information on how to interpret these with two different dummy variables). Additionally, how do you interpret the other coefficients? As difference in the means with respect to what?
How do you interpret the coefficients in the interaction terms?
I'm not interested in performing a two-way ANOVA in this case, I would like to perform this with linear regression.
Thanks.