Tutorials › Regression Analysis (Undergraduate) › Testing Added Segments at Prespecified Knots

Piecewise Regression and Splines · Tutorial 450 of 991

Testing Added Segments at Prespecified Knots

Use a nested-model partial F-test to assess whether fixed-knot hinge terms improve a straight-line fit and what the result says about slope changes.

Advanced 10 min read

What You'll Learn

  • Define the reduced linear model and the full fixed-knot hinge model.
  • State the joint null hypothesis tested by the added hinge terms.
  • Calculate the partial F statistic from the two residual sums of squares.
  • Identify the degrees of freedom and conditions for an exact F test.
  • Interpret a significant result as evidence of slope changes at the specified knots.
  • Recognize why testing several hinge terms jointly differs from testing each one separately.

Why Test Added Segments?

A continuous piecewise linear regression can represent a relationship whose slope changes at specified values of a predictor. Adding hinge terms makes that flexibility possible, but a more flexible model will never have a larger residual sum of squares than its simpler counterpart. The relevant question is therefore not whether the expanded model fits at least as well; it is whether the reduction in residual error is large relative to the additional parameters used.

A nested-model partial F-test answers this question for a set of knots chosen in advance. It compares a straight-line model with a model that adds hinge terms at those fixed locations. The test concerns whether the added terms, taken together, improve the fit beyond what random error would plausibly produce under the simpler model.

The Two Nested Models

Suppose \(n\) observations \((x_i,y_i)\) are available, and \(q\) distinct knots \(k_1,\ldots,k_q\) have been specified. The hinge function at knot \(k_j\) is \((x_i-k_j)_+=\max(0,x_i-k_j)\). The reduced model is an ordinary straight line. The full model adds one hinge term for each knot:

$$ \begin{aligned} \text{Reduced:}\quad & y_i=\beta_0+\beta_1x_i+\varepsilon_i,\\ \text{Full:}\quad & y_i=\beta_0+\beta_1x_i+ \sum_{j=1}^{q}\gamma_j(x_i-k_j)_++\varepsilon_i. \end{aligned} $$

In the full model, the fitted relationship is continuous at each knot. The coefficient \(\gamma_j\) is the change in slope at knot \(k_j\), holding the other terms in the model in place. For example, with two knots, the slope before the first knot is \(\beta_1\), between the knots it is \(\beta_1+\gamma_1\), and after the second knot it is \(\beta_1+\gamma_1+\gamma_2\).

Definition: The reduced model is nested in the full model because setting all hinge coefficients to zero gives the reduced straight-line model. The partial F-test assesses the joint null hypothesis \(H_0:\gamma_1=\cdots=\gamma_q=0\) against \(H_a:\) at least one \(\gamma_j\ne0\). Under the alternative, the fitted slopes change at one or more of the prespecified knots.

The test compares residual sums of squares. Let \(SSE_R\) be the residual sum of squares from the reduced model and \(SSE_F\) the residual sum of squares from the full model. With full column rank, the reduced model has two estimated coefficients and the full model has \(q+2\). Thus the full-model residual degrees of freedom are \(n-q-2\), while the number of added parameters is \(q\).

Theorem: The partial F statistic for adding \(q\) hinge terms is
$$ F=\frac{(SSE_R-SSE_F)/q}{SSE_F/(n-q-2)}. $$

Under \(H_0\) and the usual normal linear-model assumptions, this statistic has an \(F\) distribution with \(q\) numerator degrees of freedom and \(n-q-2\) denominator degrees of freedom. The numerator is the reduction in residual sum of squares per added coefficient; the denominator is the full model’s residual mean square.

Assumptions and Why the Test Works

For the exact reference distribution, treat the predictor values and knots as fixed. Assume the errors are independent, have mean zero and common variance \(\sigma^2\), and are normally distributed. Equivalently, conditional on the predictor values, \(\varepsilon_i\sim N(0,\sigma^2)\). The model must also be correctly specified for the comparison, and the columns of the full model matrix must be linearly independent. In practical terms, the observed predictor values must provide enough variation to distinguish the straight-line terms from the hinge terms.

A short derivation explains the statistic. Under the null, both models describe the conditional mean, but the full model has \(q\) additional independent directions in which it can fit the response. In nested least squares, the reduction \(SSE_R-SSE_F\) is the squared length of the fitted component contributed by those added directions. Under normal errors, divided by \(\sigma^2\), this reduction has a chi-square distribution with \(q\) degrees of freedom. The full-model residual sum of squares, divided by \(\sigma^2\), has a chi-square distribution with \(n-q-2\) degrees of freedom. These quantities are independent because they arise from orthogonal components of the normal error vector. Therefore,

$$ \frac{(SSE_R-SSE_F)/q}{SSE_F/(n-q-2)} \sim F_{q,\,n-q-2} \quad\text{under }H_0. $$

This argument also shows why the test uses the full model’s residual mean square as its estimate of error variance. A large \(F\) value means the added terms reduce error substantially compared with the residual variation that remains in the full model. The p-value is the probability, assuming \(H_0\) and the model assumptions, of obtaining an \(F\) statistic at least as large as the observed value.

Worked Example: Testing Two Prespecified Knots

Suppose hypothetical measurements of an outcome \(y\) and predictor \(x\) are collected for \(n=30\) independent units. Before examining the outcomes, an analyst specifies knots at \(x=20\) and \(x=50\). The reduced straight-line fit has \(SSE_R=500\) outcome-units squared, and the full model with both hinge terms has \(SSE_F=380\) outcome-units squared. Assume the full design matrix has rank four and that residual checks are reasonably consistent with independence, constant variance, and normal errors.

The joint null hypothesis is \(H_0:\gamma_1=\gamma_2=0\). There are \(q=2\) added terms, and the full-model residual degrees of freedom are \(30-(2+2)=26\). Thus,

$$ F=\frac{(500-380)/2}{380/26} =\frac{60}{190/13} =\frac{78}{19} \approx 4.1053. $$

The statistic is compared with an \(F\) distribution with 2 and 26 degrees of freedom. Its upper-tail p-value is approximately \(0.028\). At significance level \(\alpha=0.05\), reject \(H_0\): the data provide evidence that at least one of the two specified knots corresponds to a slope change that improves the fit beyond the straight-line model. This result does not establish that both slopes change, nor does it show that the chosen knots are uniquely correct.

Worked Example: A Small Reduction Is Not Strong Evidence

In a separate hypothetical setting, \(n=24\) independent observations are modeled with one prespecified knot at \(x=12\). The reduced model has \(SSE_R=240\), and the full model has \(SSE_F=220\). Suppose the predictor values span both sides of the knot, the model matrix has rank three, and residual diagnostics give no serious contradiction of the linear-model assumptions.

Here \(q=1\), so the full-model residual degrees of freedom are \(24-3=21\). The statistic is

$$ F=\frac{(240-220)/1}{220/21} =\frac{20}{220/21} =\frac{21}{11} \approx 1.9091. $$

With 1 and 21 degrees of freedom, the upper-tail p-value is about \(0.1816\). At \(\alpha=0.05\), this is not sufficient evidence to reject \(H_0:\gamma_1=0\). The conclusion is not that the slope is known to be unchanged; rather, this comparison does not establish an improvement from adding the hinge term.

Worked Example: Testing Three Added Segments Together

Suppose a hypothetical set of \(n=40\) independent observations is analyzed using three knots fixed in advance. The straight-line model has \(SSE_R=900\), and the full model with three hinge terms has \(SSE_F=600\), both in outcome-units squared. Assume there are adequate predictor values across the resulting segments, the design matrix has rank five, and the residual pattern is reasonably compatible with independent, constant-variance normal errors.

The joint null is \(H_0:\gamma_1=\gamma_2=\gamma_3=0\). The full model has \(40-5=35\) residual degrees of freedom. Therefore,

$$ F=\frac{(900-600)/3}{600/35} =\frac{100}{120/7} =\frac{35}{6} \approx 5.8333. $$

The reference distribution is \(F_{3,35}\); the upper-tail p-value is less than \(0.01\). At the 5% level, the result is evidence against the straight-line model in favor of slope changes at one or more of the three specified locations. The test does not identify which coefficient or coefficients are responsible for the joint result.

Interpreting the Result Carefully

The test’s conclusion is conditional on the knot locations in the model. A significant result supports the claim that the fixed-knot piecewise model improves on a straight line at those locations, under the assumptions. It does not by itself prove that the relationship truly changes slope, establish a causal effect, or show that every added segment is useful. Regression describes association unless the study design and additional assumptions justify causal interpretation.

A nonsignificant result likewise does not prove that the true slope is identical throughout the predictor range. The available sample may have limited information to detect slope changes, particularly if few observations lie near or between knots. It is more accurate to report that the test did not provide sufficient evidence of improvement than to claim that no slope change exists.

The test also depends on how the knots were chosen. Its usual interpretation assumes the knot locations were prespecified independently of the observed outcomes. Selecting locations after inspecting which ones produce the largest reduction in SSE changes the testing problem; the nominal p-value from the fixed-knot comparison no longer accounts for that selection. Keep the distinction clear: this procedure tests added hinge terms at given locations, not an unknown breakpoint search.

Common Mistake: Testing Each Hinge Separately

A tempting approach is to fit the full model and test each \(\gamma_j\) separately, then treat the collection of individual tests as equivalent to the nested-model test. They are not the same question. The partial F-test evaluates the joint null that all \(q\) hinge coefficients are zero, accounting for the reduction in SSE across the added terms as a group. Separate coefficient tests address individual terms conditional on the others and do not replace that joint comparison.

Another error is to interpret a decrease in SSE alone as evidence of an improved model. Adding parameters cannot increase least-squares SSE, even when the extra terms only fit noise. The F statistic scales that decrease by both the number of added parameters and the remaining full-model error. The resulting p-value, together with the model assumptions and context, supports the decision.

Key takeaway: For prespecified knots, compare the straight-line model with the full hinge model using \(F=[(SSE_R-SSE_F)/q]/[SSE_F/(n-q-2)]\). A sufficiently large statistic is evidence that at least one specified knot adds a slope change, subject to the assumptions of the linear model.

Check Your Understanding

Use the model comparison and its assumptions to answer the questions below.

  1. A full model adds four hinge terms to a straight-line model and has \(n=50\). What are the numerator and denominator degrees of freedom for the partial F-test?
  2. In the hinge model, what does \(\gamma_j\) represent at knot \(k_j\)?
  3. Why does a lower \(SSE_F\) than \(SSE_R\), by itself, not demonstrate that the added terms are useful?
  4. A joint test of three hinge terms is significant. What can you conclude, and what can you not conclude about the individual knots?
  5. Why does choosing knot locations after looking for the largest outcome-based improvement complicate the usual fixed-knot p-value interpretation?