Why Use a Truncated Power Basis?
A single cubic polynomial can bend smoothly, but its curvature is governed by one polynomial over the entire predictor range. A cubic spline allows the curve’s cubic behavior to change at chosen locations called knots, while keeping the fitted curve smooth where the pieces meet. The truncated power basis expresses that curve as a sum of familiar predictor powers and terms that become active only after their knots.
This representation is useful because it turns a piecewise curve into a regression model that is linear in its coefficients. Once the knots are fixed, each basis function can be calculated for every observation and entered as a predictor in a regression.
The Basis and Its Regression Model
Suppose there are \(K\) fixed interior knots, ordered as \(\xi_1<\xi_2<\cdots<\xi_K\). The truncated power basis for a cubic spline consists of the constant function, \(x\), \(x^2\), \(x^3\), and one truncated cubic function for each knot. The resulting mean curve is
Here, \(\beta_0,\beta_1,\beta_2,\beta_3\), and \(\gamma_1,\ldots,\gamma_K\) are coefficients. In a regression setting, the model for observation \(i\) is \(Y_i=f(x_i)+\varepsilon_i\). The conditional mean assumption is \(E(\varepsilon_i\mid x_i)=0\). For ordinary least squares, the coefficients are chosen to minimize the sum of squared differences between the observed responses and the fitted values. A unique least-squares coefficient estimate also requires the basis columns in the data to be linearly independent. Usual standard-error calculations require additional error assumptions; they are not needed just to define or evaluate the basis.
The first four terms describe a cubic polynomial that applies everywhere. Each truncated term adds a cubic adjustment only to the right of its knot. With \(K\) interior knots, the expression has \(K+4\) coefficients, including the intercept.
Worked Example: Constructing Basis Values at Two Knots
Suppose the predictor \(x\) is time in months, with fixed knots at 2 and 4 months. The basis columns are \(1\), \(x\), \(x^2\), \(x^3\), \((x-2)_+^3\), and \((x-4)_+^3\). Calculate the basis values at \(x=1\), \(x=3\), and \(x=5\).
At \(x=1\), both knots are to the right, so both truncated terms are zero: \((1-2)_+^3=0\) and \((1-4)_+^3=0\). The complete basis row is \((1,1,1,1,0,0)\).
At \(x=3\), the predictor is one month past the first knot and still below the second. Thus \((3-2)_+^3=1^3=1\) and \((3-4)_+^3=0\). The basis row is \((1,3,9,27,1,0)\).
At \(x=5\), the predictor is past both knots. The truncated values are \((5-2)^3=27\) and \((5-4)^3=1\). The basis row is \((1,5,25,125,27,1)\).
These rows form part of a regression design matrix: each observation gets one row of calculated basis values. Notice that the truncated columns are zero at and before their own knots, not merely before the first knot.
Why the Curve Is Smooth at a Knot
A cubic spline in this setting is a piecewise cubic curve whose value, first derivative, and second derivative agree on both sides of each interior knot. The truncated power form enforces these continuity conditions by construction. To see why, consider the contribution from one knot:
For \(x<\xi\), \(g(x)=0\). For \(x>\xi\), \(g(x)=\gamma(x-\xi)^3\). On the right side, its first and second derivatives are \(3\gamma(x-\xi)^2\) and \(6\gamma(x-\xi)\). At \(x=\xi\), the function and both derivatives approach zero from either side. Thus this term changes the cubic behavior after the knot without introducing a jump in the curve, slope, or second derivative.
A short derivation also explains why these terms represent the general cubic spline with these continuity conditions. Start with a cubic polynomial on the interval before the first knot. At a knot \(\xi_j\), the difference between the cubic polynomial to the right and the one to the left must have value, first derivative, and second derivative equal to zero at \(\xi_j\). A cubic polynomial with these three zeros at the same point must be a constant multiple of \((x-\xi_j)^3\): it has a root of multiplicity at least three, and its degree is at most three. Therefore, crossing each knot adds a term \(\gamma_j(x-\xi_j)^3\) on the right and zero on the left. Applying this reasoning in order at all knots gives the stated truncated power representation.
How the Coefficients Shape the Curve
Before the first knot, all truncated terms are zero, so the curve is the ordinary cubic polynomial \(\beta_0+\beta_1x+\beta_2x^2+\beta_3x^3\). On an interval after some knots, the active truncated terms add to that polynomial. For example, after the first \(m\) knots and before the next one, expanding the active terms gives
Thus the coefficients \(\gamma_j\) are not, in general, the slopes or intercepts of separate segments. They modify the local polynomial after their knots. More specifically, away from the knots the third derivative is \(6\beta_3+6\sum_{j:x>\xi_j}\gamma_j\). Crossing knot \(\xi_j\) changes the third derivative by \(6\gamma_j\). The curve, its slope, and its second derivative remain continuous.
Worked Example: Evaluating a Fitted Truncated Power Curve
Consider the hypothetical fitted curve, with \(x\) measured in months and \(f(x)\) measured in response units:
The knots are at 2 and 4 months. At \(x=1\), both truncated terms are zero, so \(f(1)=1+2(1)-0.5(1)^2+0.1(1)^3=2.6\) response units.
At \(x=3\), only the term for the knot at 2 is active: \(f(3)=1+2(3)-0.5(3)^2+0.1(3)^3-0.08(3-2)^3\). The ordinary polynomial contributes \(1+6-4.5+2.7=5.2\), and the active adjustment is \(-0.08\), giving \(f(3)=5.12\) response units.
At \(x=5\), both terms are active: \(f(5)=1+2(5)-0.5(5)^2+0.1(5)^3-0.08(5-2)^3+0.05(5-4)^3\). The ordinary polynomial contributes \(1+10-12.5+12.5=11\). The knot adjustments are \(-0.08(27)=-2.16\) and \(0.05(1)=0.05\), so \(f(5)=11-2.16+0.05=8.89\) response units.
These are fitted mean responses at the specified predictor values. They are not necessarily observed responses, and a fitted value alone does not indicate the uncertainty around the curve.
Worked Example: Interpreting a Knot Coefficient Through Derivatives
Use the same fitted curve. Determine how the third derivative changes at each knot, and check the first two derivatives at the knot at \(x=2\).
Before the first knot, the third derivative is \(6(0.1)=0.6\) response units per month cubed. After \(x=2\), it is \(6(0.1-0.08)=0.12\). Thus the change at \(x=2\) is \(0.12-0.6=-0.48\), which also equals \(6(-0.08)\). After \(x=4\), it is \(6(0.1-0.08+0.05)=0.42\), a change of \(0.42-0.12=0.30=6(0.05)\).
The first derivative is \(f'(x)=2-x+0.3x^2-0.24(x-2)_+^2+0.15(x-4)_+^2\). At \(x=2\), the truncated derivative term is zero, so the slope there is \(2-2+0.3(4)=1.2\) response units per month on both sides.
The second derivative is \(f''(x)=-1+0.6x-0.48(x-2)_++0.30(x-4)_+\). At \(x=2\), this equals \(-1+0.6(2)=0.2\) response units per month squared from either side. The change in the third derivative is therefore compatible with a continuous curve, slope, and second derivative.
Using the Basis Carefully
Once the knots and basis functions are set, fitting the model amounts to estimating coefficients for the basis columns. The selected knot locations determine where the curve can change its cubic behavior; they do not by themselves determine how much it changes. That depends on the estimated \(\gamma_j\) values along with the polynomial coefficients.
- Keep the predictor units in mind. Powers and truncated powers have units: if \(x\) is measured in months, a cubic term is measured in months cubed. Coefficients therefore depend on the scale used for \(x\).
- Check which terms are active. At \(x=\xi_j\), the \(j\)th truncated term is zero. Only values strictly greater than that knot produce a nonzero contribution.
- Do not treat \(\gamma_j\) as a slope change. A truncated cubic term has zero first derivative at its knot. Its coefficient controls a change in third derivative, not an immediate jump in slope.
- Do not confuse fitted means with predictions for individual responses. The basis defines the fitted mean curve; individual observations can also differ from that curve because of their errors.
The truncated power basis is a global algebraic representation: a coefficient associated with an early knot affects the curve everywhere to the right of that knot. This is useful for deriving and interpreting the curve in terms of polynomial pieces. The practical task is to calculate the basis values consistently and read coefficients in relation to the whole expression, rather than in isolation.
Check Your Understanding
Use the definitions and results in this tutorial to answer the following questions.
- With knots at 1 and 3, calculate the two truncated cubic basis values at \(x=2\) and at \(x=4\).
- Why does adding \(\gamma(x-\xi)_+^3\) preserve the value, first derivative, and second derivative at \(x=\xi\)?
- For a truncated power model with two knots, how many coefficients are present when the intercept is included?
- If a knot coefficient is \(-0.04\), by how much does the third derivative change when crossing that knot?
- Why is it generally incorrect to interpret a truncated cubic coefficient as the slope change at its knot?