# How to create the interaction term when one of the variables is transformed?

In my study, I am hypothesizing an interaction effect of variables $$x_1$$ and $$x_2$$ on $$y$$.
Because the univariate distribution of $$x_2$$ is not normal, I have log-transformed the $$x_2$$ variable.

I was wondering how to create the interaction term. Should the fitted model include a multiplicative term of $$x_1$$ and untransformed $$x_2$$, or $$x_1$$ and transformed $$x_2$$?

Similarly, for plotting the interaction, should I include the transformed or untransformed $$x_2$$?

• Why do you need the marginal distribution of $x_2$ to be normal? Apr 13, 2018 at 0:27
• @MatthewDrury, In my case, when I included the untransformed x2, the residual diagnostics indicated violations. This got rectified when I used the log-transformed x2. That is the reason I was wanting to keep the transformed x2. Apr 13, 2018 at 0:30
• Ok, but that is very different from needing the marginal distribution of $x_2$ to be normal. Apr 13, 2018 at 0:31
• @MatthewDrury, I am not sure if I technically understand what you noted. Would you please help me get an intuitive sense of it? Thanks so much. Apr 13, 2018 at 4:01

If you have the model $$y=b_0 + b_1 x + b_2 a + b_3 xa$$ and if we assume $x$ is a dummy variable (say 0 for male and 1 for female), and $a$ is a scalar variable (say age), then we can think of the interaction term as a change in slope parameter for one of the "groups." The most straightforward example with this scenario is to compare the male group ($x=0$) with the female group ($x=1$). Respectively, we have would have \begin{align}\text{Males: } & y = b_0 + b_2·a \\ \text{Females: } & y = (b_0 + b_1) + (b_2 + b_3)·a\end{align} The interaction term changed the slope of $a$ from males to females.
Now, it is a little stranger to conceptualize this when working with an actual grouping variable (like $x$ for gender) vs. a scalar variable (like $a$ for age)....but, let's say we want to ask what the difference is for groups #1 and #2, where the 2nd group is one year older. The equations for these groups are \begin{align}\text{Younger: } & y = (b_0 + b_2a_0) + (b_1 +b_3a_0)· x \\ \text{Older: } & y = (b_0 + b_2a_0 + b_2) + (b_1 + b_3a_0 + b_3)·x\end{align} where group #1 is age $a=a_0$, and group #2 is age $a=a_0+1$. Now, $x$ is a dummy variable, so its "slope" would be interpreted as the difference in the groups, and in this case, the one year difference in age between the groups causes a difference in the gender.
So, ¿how does this apply to your query? Well, if you want to interpret the interaction term from the perspective of how it changes the slope for your transformed variable, then you would need to have the transformed variable in the interaction: $$y = b_0 + b_1 t + b_2 a + b_3 ta$$ where $t$ is the transformed variable and $a$ is the other variable. When $a$ is some fixed value, $a_0$, then this equation can be written as $$y = (b_0 + b_2 a_0) + (b_1 + b_3 a_0)· t$$ Again, the interaction term is just changing the slope for the transformed variable. If you have the untransformed variable, say $u$, in the interaction term, this "change of slope" picture becomes much more complicated (if even possible to calculate in terms of change of $t$).
If, on the other hand, you care more about the change in slope for the other variable, $a$, then it really doesn't matter if the interaction is transformed or not: \begin{align}y = (b_0 + b_1 t_0) + (b_2 + b_3 t_0)·a \\ y = (b_0 + b_1 t_0) + (b_2 + b_3 u_0)·a\end{align} whether you use the transformed value ($t_0$) or the untransformed value ($u_0$), the change in slope for $a$ is quantifiable.