# Will the main effect of two binary independent variables change when I enter them in a regression with their interaction term?

If I have two dummy independent variables (both binary, with two levels each) in a regression, then how do I construct the the interaction variable? By coding both variables as (1,0) and multiplying them?

Let's say, I put the two dummy coded IVs and their interaction term in a regression, would the p value associated with the resulting main effects and interaction be the same as the p value obtained for the main effects and interaction in an ANOVA? I know that an ANOVA is supposed to be equivalent to a regression, but in an ANOVA, the main effects will be the same regardless of whether I calculate an interaction. Whereas in the regression, if the interaction term is correlated with the two dummy variables, it can affect the estimate (and resulting p values) of the main effect of the two dummy variables (and the interaction term also). Also, in case of interactions, should the dummy variables always be coded as (1,0) or can they also be coded as (1,-1) and then multiplied if I predict a certain type of interaction? Thanks

## 1 Answer

If I have two dummy independent variables (both binary, with two levels each) in a regression, then how do I construct the the interaction variable? By coding both variables as (1,0) and multiplying them?

Yes. When both are 1, then the interaction is 1, else 0.

As for the second part of your post, there is a lot of unpack there.

...the main effects will be the same regardless of whether I calculate an interaction.

Really? This is news to me. ANOVA is a linear model, and so unless the interaction forms an additional orthogonal column to an already orthogonal design matrix, then I don't see a good reason why this would happen.