Statistics - (Linear spline|Piecewise linear function)

1 - About

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 <math>\xi_k</math> with <math>k = 1, \dots, K</math> is a piecewise linear polynomial continuous at each knot.

This model can be represented as:

<MATH> 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 </MATH>

where the <math>b_k</math> are basis functions and are:

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

<MATH> \begin{array}{rll} b_1(x_i) & = & x_i \\ \end{array} </MATH>

  • 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.

<MATH> \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} </MATH>

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.

data_mining/linear_spline.txt · Last modified: 2017/09/13 16:04 by gerardnico