This section is optional; it shows some of the mathematical details of polynomial-spline models. As shown previously, the following is a cubic-polynomial regression model:
If you add knots, it becomes a polynomial-spline regression model:
Polynomial splines are easy to understand and describe. A curve has an overall intercept, linear portion, quadratic portion, and cubic portion. Then the cubic portion changes at each knot. Output 24.6.5 illustrates a spline that has knots at –2, 0, and 2. The blue function, , extends from –5 to 5. The blue and red function,
, extends from –5 to almost 2 as it heads toward
. The red component first contributes to the overall function when
is positive. The blue, red, and green function,
, extends from –5 to just beyond 3 as it heads toward
. The green component first contributes to the overall function when
is positive. The blue, red, green, and orange function,
, extends from –5 to almost 5 as it heads toward
. The orange component first contributes to the overall function when
is positive. Thus,
, which is highlighted in yellow, is the spline function, and it is composed of four component functions. The coefficients
,
, and
are the change in the cubic portion of the spline. The intercept does not change; this makes the spline continuous. The linear and quadratic terms do not change; this makes the spline smooth.
Output 24.6.5: Polynomial-Spline Components

Mathematically, the cubic-polynomial spline is continuous, as are its first and second derivatives. Computationally, cubic-polynomial splines might be problematic, particularly for large data sets or when there are many knots. This is because some terms might be highly correlated, resulting in an unstable model. In practice, B-splines are preferred over cubic-polynomial splines, although the two types of splines are equivalent. If is a full-rank polynomial-spline basis and
is the corresponding full-rank B-spline basis, then there exists a matrix
such that
and
. For an illustration, see the section B-Spline Basis. The overall fit and R-square are the same, but because the basis columns of the
matrices are different, the regression coefficients are different. Regression coefficients for B-spline models are usually not interpretable.