2.3 Linear Interaction Effects

“Interaction effects exist when the effect of one independent variable is contingent on the level of another independent variable. For example, does the effect of obtaining more education depend on whether someone is white or black? Does the effect of aging depend on whether someone is a man or a woman?” (Mize 2019 p.81)

Interaction effect example and interpretation

use "https://tdmize.github.io/data/data/cda_gss", clear
(cda_gss.dta |  GSS 1972-2021 CDA - Categorical Data Analysis | date created 202
> 3)
regress occprest c.age##i.woman i.college
      Source |       SS           df       MS      Number of obs   =    58,304
-------------+----------------------------------   F(4, 58299)     =   4703.09
       Model |  2777942.63         4  694485.657   Prob > F        =    0.0000
    Residual |  8608766.27    58,299  147.665762   R-squared       =    0.2440
-------------+----------------------------------   Adj R-squared   =    0.2439
       Total |  11386708.9    58,303  195.302281   Root MSE        =    12.152

-------------------------------------------------------------------------------
     occprest | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
--------------+----------------------------------------------------------------
          age |      0.072      0.004   16.316   0.000        0.063       0.081
              |
        woman |
       Women  |      2.365      0.290    8.146   0.000        1.796       2.934
              |
  woman#c.age |
       Women  |     -0.055      0.006   -9.343   0.000       -0.067      -0.044
              |
      college |
College De..  |     16.392      0.121  135.948   0.000       16.156      16.628
        _cons |     35.226      0.216  162.811   0.000       34.802      35.650
-------------------------------------------------------------------------------
est store opintmod
est table opintmod, ///
    title("[2.3.a] Occupational prestige linear regression model" ///
          "Interaction between age & gender") ///
    b(%5.3f) star(.05 .01 .001)
[2.3.a] Occupational prestige linear regression model Interaction between age &
gender

---------------------------
    Variable |  opintmod   
-------------+-------------
         age |   0.072***  
             |
       woman |
      Women  |   2.365***  
             |
 woman#c.age |
      Women  |  -0.055***  
             |
     college |
College D..  |  16.392***  
       _cons |  35.226***  
---------------------------
Legend: * p<.05; ** p<.01; *** p<.001

For linear additive effects, the coefficient on the product term tests whether there is an interactive relationship between the two IVs (i.e., whether the effect of one variable depends on the level of another variable). This is only the case for linear additive effects

The effect of age on occupational prestige is different for men and women (interaction term p < 0.001)

What is the effect of age for men? For women? Because “woman” is coded as 1, βage tells us the effect of age for men (when woman = 0). The effect of age for women = βage + βwoman X age which is 0.072 – 0.055 = 0.017. Again, this is only the case for linear additive effects. I generally go straight to plotting predictions with interactions

qui margins, at(age=(20(5)80) woman=(0 1))
marginsplot, ///
    title("[2.3.b] Predicted Occupational Prestige Based on Person's Age and G
ender", size(medium)) ///
    subtitle("Interaction Term: Gender X Age") ///
    ytitle("Occupational Prestige") ///
    recastci(rline) ciopts(lpat(dash) col(gs14)) ylab(38(2)46)
Variables that uniquely identify margins: age woman

Predicted occupational prestige by age for men and women: two straight lines that cross, with a steeper slope for men.

Marginal effects by levels of another variable

  • With linear effects, we can calculate the slope for each level of the nominal variable (here, woman) by adding the coefficients
    • But, the coefficients don’t provide a significance test for the effect of age for woman=1
  • Marginal effects straightforwardly provide this, without the need for mental math
est restore opintmod
(results opintmod are active now)
mecompare age, by(woman)
Predicting: Linear prediction
Marginal effects (N_m1=58304)

                                 |  ME #   Estimate         SE      P>|z|
---------------------------------+---------------------------------------
age + 1 (centered)               |                                       
                             Men |     1      0.072      0.004      0.000
                           Women |     2      0.017      0.004      0.000
  • Easy to test the equality of the marginal effects; in the case of linear effects, will provide equivalent answer to interaction coefficients (but only in this case!)
metest 2 - 1
                                 |  estimate         se     pvalue 
---------------------------------+--------------------------------
       age_woman_1 - age_woman_0 |    -0.055      0.006      0.000 

R: Use hypothesis option of avg_comparisons

Back to top