Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

📐 Spline Regression

In the case of highly non-linear associations one might use local (non-parametric) regression models. These include stepwise functions, regression splines, and local regression models. The general idea of these non-linear models is to break the observed range of XX into a series of shorter bins and fit different equations across these spans/bins.

Stepwise functions

Stepwise functions cut the range of XX into bins, and fit a different constant within each bin. This is equivalent to converting a continuous variable XX into an ordered categorical variable.

By creating KK cut points c1,c2,...,ckc_1, c_2, ..., c_k in the range of XX, we construct k+1k+1 new variables (C)(C). An example: For K=2K=2, we will have cut points c1c_1 and c2c_2, dividing the range of XX into three bins: from lowest value of x up to . In each bin, x will be transformed C0(X),C1(X),C2(X)C_0(X), C_1(X), C_2(X).

Don’t be confused here, altough the function index runs until kk, k+1k+1 functions are constructed since the index starts at 0 (instead of 1).

C0(X)=I(X<c1)C1(X)=I(c1Xc2)C2(X)=I(c2Xc3)C3(X)=I(c3Xc4)...Ck1(X)=I(ck1XcK)Ck(X)=I(ckX)C_0(X) = I(X < c_1) \\ C_1(X) = I(c_1 \leq X \leq c_2) \\ C_2(X) = I(c_2 \leq X \leq c_3) \\ C_3(X) = I(c_3 \leq X \leq c_4) \\ ...\\ C_{k-1}(X) = I(c_{k-1} \leq X \leq c_K) \\ C_k(X) = I(c_k \leq X)

Here, I()I() is an indicator function that returns a 1 if the condition is true, and returns a 0 otherwise.

The following table provides an example of how each input value of XX, is transformed into C(X)C(X):

The following is the regression equation in this example:

y^=b0+b1C1(X)+b2C2(X)\hat{y} = b_0 + b_1 \cdot C_1(X) + b_2 \cdot C_2(X)

The generalised regression equation then looks like this:

y^=b0+b1C1(X)+b2C2(X)+...+bkCk(X)\hat{y} = b_0 + b_1 \cdot C_1(X) + b_2 \cdot C_2(X) + ... + b_k \cdot C_k(X)

Regression Splines

Regression splines are more flexible than polynomials and stepwise functions, and in fact they are an extension of the two. The idea behind regression splines is to break up the observed span of XX into two or more pieces and fit a different constrained polynomial function to each piece (piecewise polynomials).

Instead of fitting a high-degree polynomial to the entire range of XX, we fit separate low-degree polynomials of different regions of XX. Imagine this example with a third-degree polynomial and 1 cut point (i.e. 2 regions).

y^={b01+b11x+b21x2+b31x3,if xc;b02+b12x+b22x2+b32x3,if x>c\hat{y}= \begin{cases} b_{01} + b_{11} \cdot x + b_{21} \cdot x^2 + b_{31} \cdot x^3, \text{if } x \leq c;\\ b_{02} + b_{12} \cdot x + b_{22} \cdot x^2 + b_{32} \cdot x^3, \text{if } x > c \end{cases}

If xcx \leq c, the upper polynomial is fitted, otherwise the lower one is fitted. Note the some parameters of the second polynomial (b02,b12,b22b_{02}, b_{12}, b_{22}) have to be constrained to make the function continous and smooth. Please refer to Lecture 11 of Multivariate statistics for details.