2
$\begingroup$

This is the output from a linear regression model that is trying to predict math scores based on the student's gender and whether or not they took a test preparation course. It is just a toy example for me to understand how to interpret the coefficients.

> str(StudentsPerformance)
'data.frame':   1000 obs. of  8 variables:
 $ gender                     : chr  "female" "female" "female" "male" ...
 $ test.preparation.course    : chr  "none" "completed" "none" "none" ...
 $ math.score                 : int  72 69 90 47 76 71 88 40 64 38 ...

The model includes an interaction term between gender and test preparation course.

lm(formula = math.score ~ 1 + gender * test.preparation.course, data = StudentsPerformance)

Residuals:
    Min      1Q  Median      3Q     Max 
-61.671  -9.671   0.329   9.804  38.329 

Coefficients:
                                       Estimate Std. Error t value Pr(>|t|)    
(Intercept)                             67.1957     1.0857  61.889  < 2e-16 ***
gendermale                               5.1434     1.5574   3.303 0.000992 ***
test.preparation.coursenone             -5.5250     1.3521  -4.086 4.74e-05 ***
gendermale:test.preparation.coursenone   3.1258     1.9440  -0.065 0.050426 . 

I made the following statements :

  • the intercept is the average math score for female students who completed the test preparation course
  • males have a math score that is 5.1434 points higher than females between those who completed the course
  • females who didn't take a test preparation course have a math score that is 5.5250 points lower than females who took the course
  • the effect of a test preparation course is different for male and females. Male students who did not take the test preparation course have a math score 3.1258 points higher than female students who took the test preparation course

is that a correct interpretation?

$\endgroup$

1 Answer 1

1
$\begingroup$

Personally, I like to draw a table for these kinds of situations (see this post). Your model is:

$$ \operatorname{E}(\mathrm{mathscore}|\mathrm{gender}, \mathrm{course}) = \beta_{0} + \beta_{1}\mathrm{gender_{m}} + \beta_{2}\mathrm{course_{none}} + \beta_{3}\underbrace{\mathrm{gender_{m}}\times\mathrm{course_{none}}}_{\text{= interaction term}} $$

Tabulating all possible combinations with their corresponding coefficients, we have:

$$ \begin{array}{l|l|l} & \text{Gender = m} & \text{Gender= f} & \text{Difference} \\ \hline \text{Course = completed} & \beta_{0} + \beta_{1} & \beta_{0} & \beta_{1} \\ \text{Course = none} & \beta_{0} + \beta_{1} + \beta_{2} + \beta_{3} & \beta_{0} + \beta_{2} & \beta_{1} + \beta_{3} \\ \hline \text{Difference} & \beta_{2} + \beta_{3} & \beta_{2} & \beta_{3} \end{array} $$

Let's summarize the interpretation:

  • $\beta_{0}$ is the estimated average math score for a female with a completed course.
  • $\beta_{1}$ is the difference between males and females that completed the course.
  • $\beta_{2}$ is the difference between females who completed the course and those who didn't.
  • $\beta_{3}$ is the additional difference between the average math scores between males and females when we change from course completed to none. To make it specific: The difference between males and females who did complete the course is $\beta_{1} = 5.14$ but the difference between males and females who did not complete the course is $\beta_{1} + \beta_{3} = 5.14 + 3.13 = 8.27$.

Here is a schematic plot that hopefully aids the interpretation (note that the depicted effects do not correspond to the values of your coefficient):

Interactionplot

$\endgroup$
2
  • $\begingroup$ How can I generalize these results, say that I wanted to know if males have a math score higher than females between those who completed the course and those who not completed? $\endgroup$
    – Ed9012
    Commented Jan 28, 2023 at 14:01
  • 1
    $\begingroup$ I'm unsure what you mean by generalize? The difference between males and females among the completers is $\beta_{1}$ whereas it is $\beta_{1} + \beta_{3}$ among non-completers. Therefore, the difference of the differences (m vs f) is $\beta_{3}$. $\endgroup$ Commented Jan 28, 2023 at 14:23

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.