I want to run a regression with an interaction term (continuous x dummy). My traditional way of running this regression is reg logerr_w c.matstr_w##i.yr2013 (results attached).
However, I find that if I manually generate the interaction variables (I would only do this so that I can control the order in which the results are displayed), the sign flips on the coefficient of the interaction. Why does this happen? Note that I understand that I should just run the model the correct way - but I'm very curious about WHY the sign would flip.
Here is the code for my manual interaction variable construction:
gen matstr_yr2013_1=0
replace matstr_yr2013_1=matstr_w if yr2013==1
gen matstr_yr2013_0=0
replace matstr_yr2013_0=matstr_w if yr2013==0


However, I find that if I manually generate the interaction variables (I would only do this so that I can control the order in which the results are displayed), the sign flips on the coefficient of the interaction. Why does this happen? Note that I understand that I should just run the model the correct way - but I'm very curious about WHY the sign would flip.
Here is the code for my manual interaction variable construction:
gen matstr_yr2013_1=0
replace matstr_yr2013_1=matstr_w if yr2013==1
gen matstr_yr2013_0=0
replace matstr_yr2013_0=matstr_w if yr2013==0
Comment