1
$\begingroup$

Say that I want to run a regression of Y on 1) a binary main effect (B); 2) a continuous main effect (C); and 3) an interaction of 1 and 2 (BC): gen BC=B*C.

  1. If I do not standardize them, there is no problem: reg Y B C BC.

However, I think that the interpretation of variable C is a lot harder than if I were to standardize this variable (mean 0 and standard deviation 1). So standardize C to create C_S (egen C_S=std(C)). I do not think that it makes sense to standardize the discrete variable B.

The tricky thing is what to do with BC given that C is now standardized to be C_S. There seem to be three possibilities (all of which include the standardized C_S):

  1. Do not standardize the interaction: reg Y B C_S BC
  2. Re-create the interaction using the discrete B and the continuous C_S: gen BC_2=B*C_S Then re-run the regression using this new variable: reg Y B C_S BC_2
  3. Instead, standardize the interaction term (that was created using B and C): egen BC_3=std(BC).

Intuitively, option 2 seems to be the correct thing to do. However, I get weird results when I put it in a regression. This will use Stata. If necessary, I might do an R version too.

sysuse auto2, clear

*create outcome variable 
gen Y=price

*create dummy variable
gen B=foreign==1

gen C=weight

*create interaction term
gen BC = B*C

*create standardized weight
egen C_S = std(C)

*create standardized interaction 2 (use C_S)
gen BC_2 = B*C_S

*create standardized interaction 3 (standardize after)
egen BC_3 = std(BC)

*0. Baseline (nothing standardized)
reg Y B C BC

*1. interaction not standardized
reg Y B C_S BC

*2. using BC_2
reg Y B C_S BC_2

*3. using BC_3
reg Y B C_S BC_3

Here is the regression output:

Model 0 (baseline):

. reg Y B C BC

------------------------------------------------------------------------------
           Y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
           B |  -2171.597   2829.409    -0.77   0.445    -7814.676    3471.482
           C |   2.994814   .4163132     7.19   0.000     2.164503    3.825124
          BC |   2.367227   1.121973     2.11   0.038      .129522    4.604931
       _cons |  -3861.719   1410.404    -2.74   0.008    -6674.681   -1048.757
------------------------------------------------------------------------------

Model 1 (do not standardize interaction):

reg Y B C_S BC

------------------------------------------------------------------------------
           Y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
           B |  -2171.597   2829.409    -0.77   0.445    -7814.676    3471.483
         C_S |    2327.55   323.5559     7.19   0.000     1682.238    2972.862
          BC |   2.367227   1.121973     2.11   0.038     .1295219    4.604931
       _cons |   5180.999   312.3268    16.59   0.000     4558.083    5803.915
------------------------------------------------------------------------------

*Note that the coefficients on B and BC are the same as in the baseline model.

Model 2 (use BC_2, the one that multiples B with C_S):

. reg Y B C_S BC_2

------------------------------------------------------------------------------
           Y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
           B |   4976.148   910.5648     5.46   0.000     3160.084    6792.212
         C_S |    2327.55   323.5559     7.19   0.000     1682.238    2972.862
        BC_2 |   1839.793   871.9902     2.11   0.038     100.6635    3578.923
       _cons |   5180.999   312.3268    16.59   0.000     4558.083    5803.915
------------------------------------------------------------------------------

*In this model, which is the one I think makes most sense, we have very different numbers for B and the interaction, but the same for C_S. B completely flipped signs, which is confusing.

*Model 3 (where we standardize BC):

reg Y B C_S BC_3

------------------------------------------------------------------------------
           Y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
           B |  -2171.597   2829.409    -0.77   0.445    -7814.676    3471.482
         C_S |    2327.55   323.5559     7.19   0.000     1682.238    2972.862
        BC_3 |   2582.089   1223.809     2.11   0.038      141.278    5022.899
       _cons |   6810.867   874.8334     7.79   0.000     5066.066    8555.667
------------------------------------------------------------------------------

*B is the same as in models 0 and 1. C_S is the same as in models 1, 2, and 3. The interaction term is different than all other models.

Again, Model 2 seems ex ante most correct, but the flipped sign on B is unintuitive to me and I would have expected B to be the same as in the baseline model 0. My goal is to find a model that uses a standardized C. I thought the interpretation of BC_2 is: for people for whom B==1, then a one standard deviation increase in C is associated with an increase of Y of ... - Is this correct?

What is going on? Which model is correct?

Note that my question is related to Standardize binary variable to create interaction term in regression?, but I didn't feel like this really answered my questions.

Correlations (where B2 and C2 are squared):

             |        Y        B        C      C_S       BC       B2       C2
-------------+---------------------------------------------------------------
           Y |   1.0000
           B |   0.0487   1.0000
           C |   0.5386  -0.5928   1.0000
         C_S |   0.5386  -0.5928   1.0000   1.0000
          BC |   0.1375   0.9771  -0.5156  -0.5156   1.0000
          B2 |   0.0487   1.0000  -0.5928  -0.5928   0.9771   1.0000
          C2 |   0.5760  -0.5663   0.9915   0.9915  -0.5012  -0.5663   1.0000
$\endgroup$
6
  • $\begingroup$ In model 2, have you tried to standardize B? The flip of sign and the new significance is intriguing. $\endgroup$ – POC Feb 20 at 0:47
  • $\begingroup$ If I re-run model 2 but with a standardized B, all coefficients are positive (note that I am keeping BC_2 as defined above). If I define, say, BC_4 to be B_S*C_S (which makes more sense), all coefficients are also positive. $\endgroup$ – bill999 Feb 20 at 1:41
  • $\begingroup$ I'm not familair with STata, but does the fact that BC_2 used « gen » instead of « egen » changes something. $\endgroup$ – POC Feb 20 at 18:20
  • $\begingroup$ No, that difference is just an unintuitive way in which you make variables in different ways in Stata. It is correct. $\endgroup$ – bill999 Feb 20 at 18:23
  • $\begingroup$ Then, the only explanation i see is that model 2 alters high-order correlations. Can you check the correlation matrices between model 0 and model 2 for Y, B, C, BC, B^2, C^2. $\endgroup$ – POC Feb 20 at 18:40
2
$\begingroup$

You are correct that your Model 2 makes the most sense if you wish to standardize your continuous predictor C. The confusion comes from what the intercept and the coefficient for the binary predictor B mean in Model 0 versus Model 2.

I assume that Stata is using treatment coding of the predictors, and that by standardizing C you mean subtracting its mean and dividing by its standard deviation.

Then in Model 0 the intercept (_cons) is the estimated outcome when C = 0 and B = 0. The coefficient for B in Model 0 is the difference from that outcome when B = 1 and C is still at 0.

In Model 2, the intercept is the estimated outcome when B = 0 and C_S = 0; equivalently, when C is at its original mean value. If C is associated with outcome and didn't have an original mean value of 0, that should be a good deal different from the intercept in Model 0 even if there is no interaction with B, representing the outcome difference between C at 0 and C at its mean. So the change in intercept between models is expected.

Furthermore in Model 2, the coefficient for B represents the difference from the Model 2 intercept outcome value when B = 1 and C_S is still at 0 (or C is at its original mean value). If there is an interaction between B and C, then the magnitude of the association of B with outcome would differ depending on whether C is at 0 as in Model 0 or at its mean value as in Model 2. That's exactly what you're finding, and expected if there is an interaction.

You can find equations illustrating how simply centering a continuous predictor affects the intercept and the coefficients of other predictors interacting with it in this answer. If all you did was center the continuous predictor, those equations show that the associated interaction coefficients don't change. For example, the interaction coefficient in Model 0 between the continuous predictor C and the binary predictor B is the outcome difference following a unit change in C, between B = 0 and B = 1. In a linear model, the effect of a unit change in C is the same regardless of whether you are starting from C = 0 or from C at its mean value.

But in forming the C_S predictor for Model 2 you didn't just center; you also scaled by the original standard deviation of C. So the coefficients for C_S and for the C_S:B interaction represent the effects of unit changes in the C_S scale, not in the original C scale. The coefficients associated with C in Model 0 thus differ from those associated with C_S in Model 2, in a ratio determined by the standard deviation of C used in scaling to get C_S.

$\endgroup$
4
  • $\begingroup$ This helps a ton. Thanks! $\endgroup$ – bill999 Feb 21 at 4:06
  • $\begingroup$ Would you also mind including the interpretations of the interaction terms for Model 0 vs. Model 2? This will help me determine which of the two models makes most sense in my application. No worries if not as you have already answered the original question. $\endgroup$ – bill999 Feb 21 at 4:46
  • 1
    $\begingroup$ @bill999 added a bit to the end to address that. Remember that in forming C_S you didn't just center C but you also scaled by the standard deviation. So the coefficients associated with C (both on its own and in the interaction) differ from those associated with C_S, just like coefficients for a distance measured in miles would differ from those for the same distance measured in millimeters. $\endgroup$ – EdM Feb 21 at 16:58
  • $\begingroup$ I appreciate it. $\endgroup$ – bill999 Feb 22 at 1:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.