Why Use a Spline Basis?
A continuous rating variable can have a nonlinear relationship with expected cost. A single straight-line term may be too restrictive, while separate rating bands can impose abrupt changes at band boundaries. A spline represents a smooth, flexible effect by combining basis functions: known functions of the rating variable multiplied by estimated coefficients.
The fitted effect is the combination of all the relevant basis contributions, not the effect of any one basis column in isolation. This matters particularly in a generalized linear model (GLM) with a log link, where the combined effect is on the log scale and rate factors are obtained by exponentiating differences in that effect.
A Cubic Spline in Truncated-Power Form
One useful cubic spline basis is the truncated-power basis. Let \(x\) be a continuous rating variable and let \(\kappa_1,\ldots,\kappa_K\) be distinct interior knots. Define the positive-part cube by \((x-\kappa)_+^3=\max(x-\kappa,0)^3\). A cubic spline effect can be written as
The corresponding design-matrix columns are \(1,x,x^2,x^3\), followed by one column \((x-\kappa_j)_+^3\) for each knot. Thus, with \(K\) interior knots, this representation has \(K+4\) columns for the spline effect. The intercept column may be incorporated into the model’s overall intercept rather than duplicated.
For example, under a log link, a model for expected cost per exposure unit could have linear predictor \(\eta(x)=\alpha+f(x)\), with \(\alpha\) as the model intercept. If \(e\) is exposure and the response is a total expected cost, an exposure offset can instead be included as \(\log(e)\): \(\log E[Y]=\log(e)+\alpha+f(x)\). The offset accounts for exposure; it is not an estimated spline column.
Worked Example: Constructing a Cubic Spline Design Matrix
A hypothetical rating model uses \(x\), a centered and scaled measure of equipment age, with knots at 1 and 3. Construct the spline design-matrix rows for \(x=0,1,2,3,4\), using columns \(1,x,x^2,x^3,(x-1)_+^3,(x-3)_+^3\).
Method. Evaluate each column at each observed \(x\). For each truncated-power column, first subtract its knot and then take the positive part before cubing.
At \(x=0\), both knot differences are negative, so both truncated-power values are zero. The row is \((1,0,0,0,0,0)\).
At \(x=1\), the polynomial columns are \(1,1,1,1\), and both truncated-power values are zero. The row is \((1,1,1,1,0,0)\).
At \(x=2\), the polynomial columns are \(1,2,4,8\). The knot contributions are \((2-1)^3=1\) and \((2-3)_+^3=0\). The row is \((1,2,4,8,1,0)\).
At \(x=3\), the polynomial columns are \(1,3,9,27\). The knot contributions are \((3-1)^3=8\) and \((3-3)_+^3=0\). The row is \((1,3,9,27,8,0)\).
At \(x=4\), the polynomial columns are \(1,4,16,64\). The knot contributions are \((4-1)^3=27\) and \((4-3)^3=1\). The row is \((1,4,16,64,27,1)\).
The complete design matrix is therefore
Check. The last column is zero at and below the knot \(x=3\), and is positive only for \(x>3\). The common mistake is to use \((x-\kappa)^3\) even when \(x<\kappa\); that would incorrectly give nonzero contributions below the knot.
Why the Basis Produces a Smooth Join
The truncated-power representation works because each added knot term changes the cubic polynomial to the right of its knot without introducing a jump in the function, its first derivative, or its second derivative. For one knot \(\kappa\), consider the contribution \(h(x)=\gamma(x-\kappa)_+^3\). To the left of the knot, \(h(x)=0\). To the right, \(h(x)=\gamma(x-\kappa)^3\).
For \(x>\kappa\), its first and second derivatives are \(3\gamma(x-\kappa)^2\) and \(6\gamma(x-\kappa)\). As \(x\) approaches \(\kappa\) from the right, the function and both derivatives approach zero. From the left they are already zero. Therefore the function, first derivative, and second derivative match at the knot. The third derivative may change, which allows the curve’s cubic piece to change there.
The first four terms in \(f(x)\) provide a global cubic polynomial. Each truncated-power term adds a cubic contribution only to the right of its knot. Their sum is therefore piecewise cubic, with the required continuity at each knot. This explains why the basis can represent a smooth curve without fitting a separate unrelated polynomial on each interval.
Other bases, including B-spline bases, can represent the same spline spaces using different columns. The numerical coefficient values depend on the chosen basis, but the fitted function can be the same. In any basis, construct the model matrix by evaluating every basis function at each observation’s predictor value.
Worked Example: Combining Basis Columns Into a Relativity
A hypothetical insurer models expected cost per exposure unit with a log link. For one continuous predictor \(x\), suppose the fitted linear predictor is
where the spline knots are 1 and 3. Calculate the predicted cost at \(x=2\) and its relativity to the predicted cost at \(x=1\).
Method. Evaluate all basis columns at both predictor values, sum their coefficient-weighted contributions to obtain the log-scale effects, and exponentiate for predicted costs and the relativity.
At \(x=2\), the basis values are \(1,2,4,8,1,0\). The part of the predictor excluding \(\log(120)\) is
The predicted cost is \(120e^{0.124}\), approximately \(\$135.84\) per exposure unit.
At \(x=1\), the basis values are \(1,1,1,1,0,0\). The log-scale effect excluding the intercept is
The predicted cost is \(120e^{0.071}\), approximately \(\$128.83\) per exposure unit. The log difference between \(x=2\) and \(x=1\) is \(0.124-0.071=0.053\), so the relativity is \(e^{0.053}\approx1.0544\). Thus the modeled cost at \(x=2\) is about 1.0544 times that at \(x=1\).
Check. Dividing the rounded predictions gives \(135.84/128.83\approx1.0544\). The common mistake is to interpret the coefficient \(-0.004\) as the relativity for \(x=2\); that coefficient applies only to one basis column, and the rating effect comes from the full sum.
Adding an Exposure Offset to a Spline Model
Spline columns describe how the predictor changes the modeled rate. When the response is a total over differing amounts of exposure, an offset can account for that exposure while leaving the spline effect unchanged. For example, if \(e\) is exposure and the model has a log link, the expected total is \(e\) times the modeled rate per exposure unit. The offset is \(\log(e)\), since exponentiating it returns \(e\).
Worked Example: A Spline Prediction With an Exposure Offset
A hypothetical portfolio model uses knots at 2 and 4 and the log-link model
For a policy with \(x=2.5\) and exposure \(e=0.5\), construct its spline row, calculate the expected total, and calculate its rate relativity to \(x=1\).
Method. At \(x=2.5\), the spline row is \((1,2.5,6.25,15.625,0.125,0)\), because \((2.5-2)^3=0.125\) and \(2.5<4\). The fitted spline effect excluding the intercept is
Thus, the rate per exposure unit is \(80e^{0.1070625}\approx \$89.04\). The expected total for exposure \(0.5\) is \(0.5(89.04)=\$44.52\), to the nearest cent.
For comparison, at \(x=1\), the spline contribution is \(0.06-0.008+0.0005=0.0525\). The log difference is \(0.1070625-0.0525=0.0545625\), so the rate relativity is \(e^{0.0545625}\approx1.0561\). Exposure does not enter this relativity because the comparison is between rates per exposure unit; it would affect a comparison of expected totals if the exposures differed.
Check. Multiplying the fitted rate by exposure gives \(0.5(80e^{0.1070625})\), consistent with using \(\log(0.5)\) as an offset in the log expected total. A common error is to add \(0.5\) to the linear predictor; the offset is \(\log(0.5)\), not the exposure itself.
Interpreting and Using the Fitted Effect
For a log-link model, write the predictor as \(\eta(x)=\alpha+f(x)\), where \(f(x)\) is the combined spline effect. The predicted rate is proportional to \(e^{f(x)}\). Comparing two values \(x_a\) and \(x_b\) cancels the intercept, giving the rate relativity
This formula follows directly from the log link: the two predicted rates are \(e^{\alpha+f(x_b)}\) and \(e^{\alpha+f(x_a)}\). Their ratio is \(e^{\alpha+f(x_b)}/e^{\alpha+f(x_a)}=e^{f(x_b)-f(x_a)}\). If other rating variables are held fixed, their contributions also cancel in the comparison.
A spline coefficient is tied to its particular basis column. For example, changing \(x\) can alter several columns at once: \(x\), \(x^2\), \(x^3\), and one or more truncated-power columns. Therefore, a single coefficient is generally not a per-unit rate change. To interpret or compare fitted rates, evaluate the complete design rows and use their combined linear predictors.
Check Your Understanding
For each problem, use the stated basis-column order and retain full precision until the final result.
- With knots at 1 and 3, what is the truncated-power design row at \(x=3.5\) for columns \(1,x,x^2,x^3,(x-1)_+^3,(x-3)_+^3\)? (Answer: \((1,3.5,12.25,42.875,15.625,0.125)\))
- A log-link spline effect is \(f(x)=0.05x-0.01x^2+0.002(x-2)_+^3\). Calculate the rate relativity at \(x=3\) compared with \(x=1\). (Answer: \(e^{0.022}\approx1.0222\))
- For knots at 1 and 3, calculate the design row at \(x=2\) using columns \(1,x,x^2,x^3,(x-1)_+^3,(x-3)_+^3\). (Answer: \((1,2,4,8,1,0)\))
- A model has \(\log E[Y]=\log(e)+\log(0.20)+0.03x-0.002x^2\). For \(x=4\) and exposure \(e=2\), calculate the predicted expected total. (Answer: \(2(0.20)e^{0.03(4)-0.002(16)}\approx0.4368\))
- At two predictor values, the combined spline effects are \(0.18\) and \(0.11\), respectively, with all other rating variables held fixed. What is the rate relativity for the first value compared with the second? (Answer: \(e^{0.18-0.11}=e^{0.07}\approx1.0725\))