# Continuous vs. categorical variables in interaction terms

My analysis includes, among others, three independent variables: X (interest rate), Y (type of rate; it is a dummy), and Z (likelihood of bankruptcy). I have transformed the latter into a categorical variable ZZ. To do so, I have used deciles (i.e., ZZ is 1 if the value of Z is lower than the 10th percentile of Z, etc). In some specifications of the model, I use the interaction term X·ZZ, and in others, Y·ZZ and X·Y·ZZ.

However, I have now the following doubt. Leaving aside other considerations, is there a statistical reason to use ZZ instead of Z (i.e., the categorical version of a continuous variable instead of the variable itself) in interaction terms? Does it make any difference the fact that the other variable in the relevant interaction terms is a dummy (Y) or a continuous variable (X)?

(I assume you are fitting a linear model with variables X and Z or ZZ).

There is a difference in using a categorical variable (ZZ) or a continuous one (Z):

• In case of using the continuos variable Z, you are assuming that the effect of X will depend on the value Z, and that this effect is linear. A possible result for example might be that the effect of X is two units higher for an extra unit of Z.

• When you use the categorical feature, you assume that the effect of X is different for each possible value of ZZ. You allow the effect of X to be different for each discrete value of ZZ but don't imply linearity. An possible for example might be if ZZ=1, the effect of X=2. If ZZ=2, the effect of X=4. If ZZ=3, the effect of X=5.

The last model is actually the same as splitting your dataset up for each level of ZZ and fitting a liner of model with only X. You have separate linear models.

To really understand this, I suggest to transform the data Z into ZZ, and model first a continuous model and afterwards a categorical model and compare the outcomes. In R, this would be:

lm(Y ~ X*ZZ, data = data)
lm(Y ~ X * as.factor(ZZ), data = data)