# How should I implement this interaction between a continuous and categorical predictor?

I have a continuous outcome variable. I understand that if I have a binary predictor, and a continuous predictor, and an interaction, then the model looks like this:

$y_{i} = \beta_{0} + \beta_{1}x_{1} + \beta_{2}x_{2} + \beta_{3}x_{1}x_{2} + \varepsilon_{i}$

However, I'm thinking of making the binary predictor a categorical one instead, with three categories.

1. What will the model equation look like once I make that change? I understand that I'll need to have two dummy variables, but I can't conceptualize what the interaction will look like under that circumstance.

2. Does it make any difference whether I use 0,1 to code the binary predictor, or some other values like 1,2? This question also applies to the model with the categorical predictor, since in that case I'll have to decide how to code the dummy variables.

3. Prior to the interaction term being in my model I was encouraged to center the continuous predictor. Is centering (still) a good idea now that I have this interaction term?

• (1) Write down the dummy coding scheme for each of the three levels. (2) As well as including terms for each of the two dummies, include terms where each is multiplied by the continuous variable. (3) Understand what's going on by re-writing the regression equation for each level of the categorical variable. (4) Investigate changing coding schemes/centring, paying attention to how the interpretation of coefficients changes, & whether the model as a whole changes (makes different predictions). May 4, 2015 at 11:00

1. Assuming your continuous variable is $x_1$ and we expand the binary $x_2$ to include $x_3$ then I suggest using:
$$y_{i} = \beta_0 + \beta_1x_1 + \beta_2x_2 + \beta_3 x_3 + \beta_4x_1x_2 + \beta_5x_1x_3 + \varepsilon_i$$
So if the continous variable interacts with the reference category, it will be included in the model by default. If there is an interaction with the second or third category then $\beta_4$ or $\beta_5$ will contain the difference from the reference category. Also, as you're suggesting, it wouldn't make any sense to put an interaction effect between $x_2$ and $x_3$.
1. The indicator variables should be coded with 0,1. In this case, if the indicator is not not true, the variable is zero and the corresponding $\beta$ drops out of the equation. This makes for much easier interpretation of the coefficients.
For example, if your category is the second category ($x_2=1$). Then for a given $x_1$, the interpretation of the category effect is $\beta_0 + \beta_2$. And given $x_2=1$, for every unit increase in $x_1$ there is a $\beta_1 + \beta_4$ increase in your response variable.
• (+1) Concise & clear explanation. @user1205901: It might help you to rewrite the equation explicitly for each allowable combination of dummies to see the intercept & slopes for each level of the categorical variable. (Note that e.g. the second category is defined in full by $x_2=1$, $x_3=0$.) May 4, 2015 at 11:20