# Interaction with indicator function instead of dummy

I am running a regression of Y on X (both are continuous variables). I'd like to measure how the effect differs between two groups of individuals, coded by a dummy variable Z. The traditional way of doing it is, I believe, to run:

 Y ~ X*Z + X + Z


However, I get much different results when I use an indicator function, meaning, I run:

Y ~ X*1(Z==0) + X*1(Z==1) + Z


Where 1(Z==0) is 1 if Z=0, and 0 otherwise. But I've never seen any regression like that. What is wrong with that approach?

• Welcome to Cross Validated! It seems like you are just switching which group is coded as $0$ and which is coded as $1$. Does that make your results make more sense?
– Dave
Jan 22 at 20:31

Typically, the indicator variable, $$Z$$ in your terminology, is an indicator for $$Z=1$$. By using an indicator for $$Z=0$$, you are effectively switching which group is coded as $$0$$ and which is coded as $$1$$.
This is a strange way of coding your group labels and is likely to cause confusion. If you have a reason to consider group $$1$$ to be a “baseline” and group $$0$$ to be a group of interest (e.g., control and treatment groups, respectively), it might make more sense to stick with the convention where you code the baseline as $$0$$, though the math makes sense either way.