0
$\begingroup$

Good day, XValidators. This is my 1st question in the community.

I'm at my wit's end here. Nowhere in the interwebz nor in youtoubeland can I find an answer to the following:

Assume you have this model on the well-known mtcars R dataset:

lm(mpg ~ factor(am) * wt + qsec, data=mtcars) where:

  1. mpg = fuel efficiency
  2. am = automatic (0) or manual (1)
  3. wt = weight (1000lbs)
  4. qsec = quarter-mile second (secs)

With the following coeffs:

               Estimate Std. Error t value Pr(>|t|)    
(Intercept)       9.723      5.899   1.648 0.110893    
factor(am)1      14.079      3.435   4.099 0.000341 ***
wt               -2.937      0.666  -4.409 0.000149 ***
qsec              1.017      0.252   4.035 0.000403 ***
factor(am)1:wt   -4.141      1.197  -3.460 0.001809 **  

Are the following interpretations correct?

  1. All coeffs will be given with respect to am=0 (meaning cars with automatic transmission), right?
  2. If so, then factor(am)1 is the mpg difference from an automatic car, right?
  3. And the coeff for wt will be the change in mpg for each 1000lb weight added FOR AUTOMATIC cars, right?
  4. And if we want to know the same but for MANUAL cars we just look at the coeff for the interaction term factor(am)1:wt, right?
  5. And if we want to obtain just the wt coeff regardless of type of car, we just add wt + factor(am)1:wt, right?
  6. Now, what about qsec? Is it also given with respect to am=0 (AUTOMATIC cars)? If so, how can we know the qsec for MANUAL cars? Or since it doesn't have an interaction, is it given for all types of car?

Could someone shed some light here, plz?

Thank you all in advance.

J.

$\endgroup$

1 Answer 1

0
$\begingroup$

for me when dealing with categorical data and interactions in linear models it is easier if I look at it as a piecewise model. Meaning that for every possible label of your categorical regressor you will generate a linear model. To see this let's rename your variables to: \begin{eqnarray*} mpg = y\\ am = x_1\\ wt = x_2\\ qsec = x_3\\ \end{eqnarray*} So the model you built in R would be $ y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \beta_3 x_3 + \beta_4 x_1 x_2 $. Given that you only have to possible values for $x_1$ you would have two linear models: \begin{eqnarray*} y = \left\lbrace \begin{array}{ccccccr} (\beta_0 + \beta_1) &+& (\beta_2 + \beta_4 )x_2 &+& \beta_3 x_3 & \text{, if } x_1 =1 \\ \beta_0 &+& \beta_2 x_2 &+& \beta_3 x_3 & \text{, if } x_1 =0. \end{array} \right. \end{eqnarray*} You can see that you have two different linear models for the response $y$, depending on the value of $x_1$ (the transmission of the car). So, concerning your questions here are some insights:

  1. From the piecewise model above and given that cars with automatic transmission are the control group, we can interpret the coefficients as follows:

    a. $\beta_0$ is the average $mpg$ for automatics, while $\beta_0 + \beta_1$ is the average $mpg$ for manuals.

    b. $\beta_2$ is the change in $mpg$ for every unit of change in weight for automatic cars, while $\beta_2 + \beta_4$ is the change in $mpg$ given a unitary change in weight for cars with a stick.

    c. However, in both models we have that for every unitary change in $qsec$ the $mpg$ changes $\beta_3$ units. This is for any given car, not considering if it is automatic or not.

Hope this answers your question!

A.

$\endgroup$
2
  • $\begingroup$ Spot on! Finally a clear explanation for a model with interacting and non-interacting variables! Just 2 more questions: 1) this rationale applies regardless of the type of variables you have, right? Meaning, it doesn't matter if your variables are numeric or categorical. 2) how would we go about calculating the change in Y per each unitary increment in B_3 exclusively for x_1 = 1? $\endgroup$ Commented Mar 8, 2016 at 18:01
  • $\begingroup$ My guess is that this is not possible because I'm not including an interacting term between qsec and am, right? $\endgroup$ Commented Mar 8, 2016 at 18:02

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.