Shared Concepts and Topics

Splines and Spline Bases

This section provides details about the construction of spline bases with the EFFECT statement. A spline function is a piecewise polynomial function in which the individual polynomials have the same degree and connect smoothly at join points whose abscissa values, referred to as knots, are prespecified. You can use spline functions to fit curves to a wide variety of data.

A spline of degree 0 is a step function with steps located at the knots. A spline of degree 1 is a piecewise linear function where the lines connect at the knots. A spline of degree 2 is a piecewise quadratic curve whose values and slopes coincide at the knots. A spline of degree 3 is a piecewise cubic curve whose values, slopes, and curvature coincide at the knots. Visually, a cubic spline is a smooth curve, and it is the most commonly used spline when a smooth fit is desired. Note that when no knots are used, splines of degree d are simply polynomials of degree d.

More formally, suppose you specify knots k 1 less-than k 2 less-than k 3 less-than midline-horizontal-ellipsis less-than k Subscript n. Then a spline of degree d greater-than-or-equal-to 0 is a function upper S left-parenthesis x right-parenthesis with d – 1 continuous derivatives such that

upper S left-parenthesis x right-parenthesis equals StartLayout Enlarged left-brace 1st Row 1st Column upper P 0 left-parenthesis x right-parenthesis 2nd Column x less-than k 1 2nd Row 1st Column upper P Subscript i Baseline left-parenthesis x right-parenthesis 2nd Column k Subscript i Baseline less-than-or-equal-to x less-than k Subscript i plus 1 Baseline semicolon i equals 1 comma 2 comma ellipsis comma n minus 1 3rd Row 1st Column upper P Subscript n Baseline left-parenthesis x right-parenthesis 2nd Column x greater-than-or-equal-to k Subscript n EndLayout

where each upper P Subscript i Baseline left-parenthesis x right-parenthesis is a polynomial of degree d. The requirement that upper S left-parenthesis x right-parenthesis has d – 1continuous derivatives is satisfied by requiring that the function values and all derivatives up to order d – 1 of the adjacent polynomials at each knot match.

A counting argument yields the number of parameters that define a spline with n knots. There are n + 1 polynomials of degree d, giving left-parenthesis n plus 1 right-parenthesis left-parenthesis d plus 1 right-parenthesis coefficients. However, there are d restrictions at each of the n knots, so the number of free parameters is left-parenthesis n plus 1 right-parenthesis left-parenthesis d plus 1 right-parenthesis minus n d = n + d + 1. In mathematical terminology this says that the dimension of the vector space of splines of degree d on n distinct knots is n + d + 1. If you have n + d + 1 basis vectors, then you can fit a curve to your data by regressing your dependent variable by using this basis for the corresponding design matrix columns. In this context, such a spline is known as a regression spline. The EFFECT statement provides a simple mechanism for obtaining such a basis.

If you remove the restriction that the knots of a spline must be distinct and allow repeated knots, then you can obtain functions with less smoothness and even discontinuities at the repeated knot location. For a spline of degree d and a repeated knot with multiplicity m less-than-or-equal-to d, the piecewise polynomials that join such a knot are required to have only dm matching derivatives. Note that this increases the number of free parameters by m – 1 but also decreases the number of distinct knots by m – 1. Hence the dimension of the vector space of splines of degree d with n knots is still n + d + 1, provided that any repeated knot has a multiplicity less than or equal to d.

The EFFECT statement provides support for the commonly used truncated power function basis and B-spline basis. With exact arithmetic and by using the complete basis, you obtain the same fit with either of these bases. The following sections provide details about constructing spline bases for the space of splines of degree d with n knots that satisfies k 1 less-than-or-equal-to k 2 less-than-or-equal-to k 3 less-than midline-horizontal-ellipsis less-than-or-equal-to k Subscript n.

Last updated: December 09, 2022