Let's imagine that we have three variables - $Y, X_1$ and $X_2$, where $Y$ is dependent continuous variable, $X_1$ is continuous variable and $X_2$ is discrete variable with two factors - $0$ and $1$. I'm interested in linear model $Y \sim X_1$, however I want to think of statistical test which will determine whether its necessary to divide $X_1$ into two categories with respect to $X_2$.
My idea
My idea was to create first model $Y \sim X_1 + X_1 \cdot 1_{\{X_2 = 0\}} $ and second model $Y \sim X_1$.
Since those two models are nested, I can compare them using F - test to check whether reduction is rational i.e. if sum of squares error ($\sum_{i = 1}^n (Y_i - \hat{Y}_i)^2$) is significantly different.
Is this make any sense to you? Is there any more popular way how it can be done?