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
.
- 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):
- Do not standardize the interaction:
reg Y B C_S BC
- 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
- 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