How to write a piecewise regression model as a linear model? Let's write the following piecewise regression model
$$y=  \alpha_0 + \alpha_1 x +\epsilon ;\ \ x\le x_0 $$
$$ y=\beta_0 +\beta_1 x + \epsilon;\ \ x\gt x_0$$
When the value $x_0$ is known, this regression model is a linear model.  How to write this model in the form $Y= X\beta +\epsilon $ where $X$ is a matrix and $\beta$ is a parameter vector?
 A: For a known discontinuous break point $x_0$, the following piecewise regression model:
$$y=  \alpha_0 + \alpha_1 x +\epsilon ;\ \ x\le x_0 $$
$$y=\beta_0 +\beta_1 x + \epsilon;\ \ x\gt x_0$$
can instead be expressed using an indicator function of $x$ and $x_0$ for the change in intercept, and a hinge function of $x_i$ and $x_0$ for the change in slope:
$$y_{i} = \beta_{0} + \beta_{x}x_{i} + \beta_{0\text{c}}I(x_{i} \ge x_0) + \beta_{x\text{c}} \max(x_i - x_0,0) + \varepsilon_{i}$$
Explanation
Change in intercept: If $x_i < x_0$, then $I(x_i \ge x_0) = 0$, so the $\beta_{0\text{c}}I(x_{i} \ge x_0)$ term also equals $0$. However, if $x_i \ge x_0$, then $I(x_i \ge x_0) = 1$, and the $\beta_{0\text{c}}I(x_{i} \ge x_0)$ term equals $\beta_{0\text{c}}$… which is just a constant, so the intercept for values at $x_0$ and higher equals $\beta_0 + \beta_{0\text{c}}$.
Change in slope: If $x_i < x_0$, then $\max(x_i - x_0,0) = 0$, so the $\beta_{x\text{c}} \max(x_i - x_0,0)$ term also equals $0$. However, if $x_i \ge x_0$, then the $\max(x_i - x_0,0)$ term increases at exactly the same rate as $x_i$: a one-unit increase in $x_i$ corresponds to a one-unit increase in $\max(x_i-x_0,0)$. For example, if $x_i = x_0 + 2$, then $\max(x_i - x_0,0)=2$. The effect of $x$ on $y$ when $x_i < x_0$ is just $\beta_x$, but the effect of $x$ on $y$ changes from $\beta_{x}$ to $\beta_x + \beta_{x\text{c}}$ for values of $x_i \ge x_0$.
A single linear model
You can thus create a single linear model with two new variables, where $x_{1i} = x_i$ and, say, $x_{2i} = I(x_{1i} \ge x_0)$, and $x_{3i} = \max(x_{1i}-x_0,0)$ and estimate (e.g., using OLS):
$$\boldsymbol{y_i = \beta_0 + \beta_x x_{1i} + \beta_{0\text{c}}x_{2i} + \beta_{x\text{c}}x_{3i} + \varepsilon_{i}} = BX_{i} + \varepsilon_{i}$$
