# Statistics - (Linear spline|Piecewise linear function)

A linear spline, or piecewise linear function has a degree zero continuity and is:

• linear in the left and the right.
• forced to be continuous at the knot.

## 3 - Definition / Representation

Just like the global polynomials and the piecewise constant functions, we can represent this as a linear expansion in basis functions that are transformations of the variables.

A linear spline with knots at $\xi_k$ with $k = 1, \dots, K$ is a piecewise linear polynomial continuous at each knot.

This model can be represented as:

$$y_i = \beta_0 + \beta_1.b_1(x_i) + \beta_2.b_2(x_i) + \dots + \beta_{K+3}b_{K+3}(x_i) + \epsilon_i$$

where the $b_k$ are basis functions and are:

• the variable itself. One of these basis functions is just the variable itself

$$\begin{array}{rll} b_1(x_i) & = & x_i \\ \end{array}$$

• and additional variables that are a collection of truncated basis transformation functions at each of the knots. They are called truncated power functions, but this one is to power 1.

$$\begin{array}{rll} b_{k+1}(xi) & = & (xi - \xi_k)_+ \text{ where } k = 1, \dots, K \\ \text{where the ()+ means positive part. i.e. } (xi - \xi_k) & = & \left\{ \begin{matrix} xi - \xi_k & \text{ if } x_i > \xi_k & \\ 0 & \text{Otherwise} & \text{It's not allowed to go negative.} \end{matrix} \right. \end{array}$$

## 4 - Plot

There is one knot in these pictures, but we can put down multiple knots.

When we fit a linear model with a global linear function plus one of the basis function and their respective coefficient, we get a function that's allowed to change its slope at the knot.