Fitting multiple line
Not knowing the data in detail, this look like a linear model with &quot;dummys&quot;.
A standard linear model looks like ($\beta_0$ is the intercept, $\beta_1$ is the slope):
$$ y = \beta_0 + \beta_1 x + u.$$
Now, when you have two distinct &quot;groups&quot; for which there is a &quot;flag&quot; in the data, you can assign a indicator variable or &quot;dummy&quot; (say $d$, a vector with =1 &quot;true&quot; or =0 otherwise). You can add this to your linear model:
$$ y = \beta_0 + \beta_1 x + \beta_2 d + u. $$
$d$ introduces a separate intercept for the assigned group ($d=1$).
You can also add &quot;interaction terms&quot; to allow for a separate slope for group $d$ by simply multiplying $x$ and $d$.
$$ y = \beta_0 + \beta_1 x + \beta_2 d + \beta_3 x d + u. $$
Note that since there already is one intercept in the model (the $\beta_0$), you can only add &quot;contrasts&quot; to the intercept. So when you have $i$ groups for which you want to have an individual intercept, you would add $i-1$ indicators/dummys to the model. For the &quot;reference group&quot;, the intercept will be $\beta_0$ and for the group which is identified by the &quot;dummy&quot; ($d$ above), the intercept would be $\beta_0 + d$.