Statistical test to check if data come from two different lines or just one I have a very basic problem, can you give me some insights on how to solve it, or just some keywords to search online?
I have two sets of points in $\mathbb{R}^2$, let say $S_1 = \{(x_i, y_i)\}_{i=1}^{N}$ and $S_2 = \{(x_i, y_i)\}_{i=1}^{M}$, the points of both sets seem to have a linear relation:
$$
y_i = mx_i + q
$$
But my hypotesis is that they "come" from two different lines, so for example the line with parameters $(m_1, q_1)$ for $S_1$ and parameters $(m_2, q_2)$ for $S_2$.
How can I test if they actually come from two different lines (and there is statistical significance) or from the same one?
 A: This is a standard application of an interaction term in a model.
With x as continuous-valued predictors and y as your outcomes, let S represent which set a data point belongs to, with S1 specified as the reference value. In a standard symbolic representation of a linear model, you would write:
y ~ x + S + x:S

That model returns 4 coefficients:* an Intercept (your q for S1), a coefficient for x that represents the change in y per unit change in x for S1, a coefficient for S that represents the difference for set S2 from the Intercept when x = 0, and an interaction coefficient that is the extra difference for S2 (again, beyond what you predict for S1) for non-zero values of x.
Standard tests then indicate whether there is evidence that distinguishing S1 from S2 matters. This might be done by also fitting the simple model without considering set:
y ~ x

and comparing the two models with analysis of variance.

*This assumes that S1 is represented numerically as 0 in your model and S2 as 1. That's a typical coding of set, often done silently for you by statistical software.
