Tutorials › Regression Analysis (Undergraduate) › Deriving the Hinge-Function Basis

Piecewise Regression and Splines · Tutorial 445 of 991

Deriving the Hinge-Function Basis

Learn to express a continuous piecewise-linear mean with a hinge term and interpret its coefficient as the change in slope at the knot.

Advanced 10 min read

What You'll Learn

  • Define the hinge function and calculate its value on either side of a knot.
  • Derive the hinge-basis form of a continuous piecewise-linear mean.
  • Show why the hinge coefficient is the change in slope, not the slope above the knot itself.
  • Convert between segment slopes and hinge-basis coefficients.
  • Construct and interpret hinge values in a regression design.

Why a Hinge Term Is Useful

A straight-line regression has one slope across its range. Some relationships are better described by a line that changes slope at a particular predictor value while keeping the fitted mean continuous there. The hinge-function basis represents that change with one added predictor column. Its construction makes the interpretation of the added coefficient especially direct: it is the amount by which the slope changes after the knot.

The knot \(k\) is a specified predictor value where the slope is allowed to change. The key is to add a term that is zero on one side of \(k\), then grows with \(x\) on the other side. That term can affect the slope above the knot without altering the line below it.

Definition: For a fixed knot \(k\), the hinge function is \((x-k)_+=\max(0,x-k)\). Thus \((x-k)_+=0\) when \(x\leq k\), and \((x-k)_+=x-k\) when \(x>k\). It is also called a positive-part function or a truncated linear term.

From Segment Slopes to the Hinge Basis

Suppose the conditional mean is linear below and above \(k\), is continuous at \(k\), and has slope \(\beta_1\) below the knot and slope \(\beta_1+\delta\) above it. Here \(\delta\) denotes the change in slope. A continuous representation can be written as

$$ m(x)= \begin{cases} \beta_0+\beta_1x, & x\leq k,\\ \beta_0+\beta_1k+(\beta_1+\delta)(x-k), & x>k. \end{cases} $$

The second segment begins at the value \(\beta_0+\beta_1k\), which is the value of the first segment at the knot. This makes the two pieces meet at \(x=k\). For \(x>k\), expand the second expression:

$$ \begin{aligned} \beta_0+\beta_1k+(\beta_1+\delta)(x-k) &=\beta_0+\beta_1k+\beta_1x-\beta_1k+\delta x-\delta k\\ &=\beta_0+\beta_1x+\delta(x-k). \end{aligned} $$

Below or at the knot, \((x-k)_+=0\), so the same expression \(\beta_0+\beta_1x+\delta(x-k)_+\) reduces to the first segment. Above the knot, \((x-k)_+=x-k\), so it reduces to the expanded second segment. The two-part description is therefore equivalent to one expression using a hinge basis term.

Key result: A continuous piecewise-linear conditional mean with one slope change at fixed knot \(k\) can be written as \(m(x)=\beta_0+\beta_1x+\delta(x-k)_+\). The slope below \(k\) is \(\beta_1\); the slope above \(k\) is \(\beta_1+\delta\). Therefore, \(\delta\) is the change in slope at the knot.

Why the Slope Changes Only Above the Knot

The slope interpretation follows directly from the expression on each side. Below \(k\), the hinge term is identically zero, so changing \(\delta\) cannot change the fitted mean there. Above \(k\), the hinge term increases one unit for every one-unit increase in \(x\), adding \(\delta\) to the line’s rate of change.

$$ m(x)= \begin{cases} \beta_0+\beta_1x, & x\leq k,\\ (\beta_0-\delta k)+(\beta_1+\delta)x, & x>k. \end{cases} $$

This expanded form shows both segment slopes explicitly. The intercept in the second line changes to keep the line joined to the first at \(k\); the hinge representation enforces this continuity without requiring a separate continuity equation when writing the model.

At the knot, the added term is exactly zero: \((k-k)_+=0\). Consequently, the fitted mean at the knot is \(\beta_0+\beta_1k\), whether evaluated from the lower segment or as the value approached from above. The slope can change there even though the mean does not jump.

The Regression Model and Its Assumptions

For observations \((x_i,y_i)\), a regression model using this basis is

$$ Y_i=\beta_0+\beta_1x_i+\delta(x_i-k)_+ + \varepsilon_i. $$

The corresponding conditional mean model is \(E(Y_i\mid x_i)=\beta_0+\beta_1x_i+\delta(x_i-k)_+\). To interpret this as a regression model with random errors, assume the conditional errors have mean zero, are independent across observations, and have constant variance \(\sigma^2\). These assumptions concern the statistical errors; the algebra showing how the hinge changes the slope does not depend on them. Normal errors are not needed for the algebra or slope interpretation.

The knot \(k\) is fixed for this representation. For each observation, the hinge predictor is calculated from its \(x_i\) value. In a regression design, the added column is therefore \(0\) for \(x_i\leq k\), and \(x_i-k\) for \(x_i>k\). The coefficient multiplying that column is \(\delta\), the slope change.

Worked Example: Interpreting a Positive Slope Change

Suppose a hypothetical relationship is represented by \(m(x)=12+0.8x+0.5(x-20)_+\), where \(x\) is measured in hours and the conditional mean response is measured in units. Identify the knot and both segment slopes, then calculate the fitted means at \(x=15\), \(x=20\), and \(x=24\).

The knot is \(k=20\) hours. Below the knot, the hinge is zero, so the slope is \(0.8\) response units per hour. Above the knot, the slope is \(0.8+0.5=1.3\) response units per hour. The coefficient \(0.5\) is the increase in slope, not the whole slope above the knot.

At \(x=15\), \((15-20)_+=0\), so \(m(15)=12+0.8(15)+0.5(0)=12+12=24\) response units.

At \(x=20\), \((20-20)_+=0\), so \(m(20)=12+0.8(20)+0.5(0)=12+16=28\) response units.

At \(x=24\), \((24-20)_+=4\), so \(m(24)=12+0.8(24)+0.5(4)=12+19.2+2=33.2\) response units. From the knot to 24 hours, the increase is \(33.2-28=5.2\) response units; the upper-segment slope gives the same result, \(1.3(24-20)=5.2\).

Converting Segment Slopes into Hinge Coefficients

The hinge representation is also useful when the two segment slopes are described directly. If the slope below the knot is \(b_L\) and the slope above it is \(b_R\), then set \(\beta_1=b_L\) and \(\delta=b_R-b_L\). The upper slope becomes \(\beta_1+\delta=b_L+(b_R-b_L)=b_R\). A positive \(\delta\) means the slope increases; a negative \(\delta\) means it decreases.

Worked Example: A Slope That Decreases at the Knot

A hypothetical continuous relationship has a lower-segment slope of \(2.4\) units per kilometer and an upper-segment slope of \(0.9\) units per kilometer, with a knot at \(x=8\) kilometers. The lower segment is \(m(x)=5+2.4x\). Write the hinge form and verify the upper slope.

The hinge coefficient is the upper slope minus the lower slope: \( \delta=0.9-2.4=-1.5\) units per kilometer. Therefore the hinge form is \(m(x)=5+2.4x-1.5(x-8)_+\).

For \(x>8\), expand the expression: \(5+2.4x-1.5(x-8)=5+2.4x-1.5x+12=17+0.9x\). Its slope is \(0.9\) units per kilometer, as required. At \(x=8\), the hinge is zero and the mean is \(5+2.4(8)=24.2\) units. The expanded upper line also gives \(17+0.9(8)=24.2\) units, confirming that the two pieces meet.

The negative hinge coefficient does not mean that the fitted response must decrease above the knot. It means the slope is 1.5 units per kilometer smaller than before. In this example, the upper slope remains positive at \(0.9\).

Building and Checking the Hinge Column

A practical way to understand the basis is to calculate its values before considering any fitted coefficient. For every observed predictor value, subtract the knot and replace negative results with zero. These values show precisely which observations can receive an added contribution from the hinge term.

Worked Example: Constructing a Hinge Predictor

Consider hypothetical predictor values \(x=6,10,13\), with a knot at \(k=10\). Suppose the illustrative mean model is \(m(x)=4+0.5x+1.2(x-10)_+\). The displayed coefficients are stipulated for illustration, not estimated from these three observations. Calculate the hinge column and the fitted means; then compare hypothetical observed responses \(y=7.4,8.8,14.5\) with those means.

\(x_i\) (units)\((x_i-10)_+\) (units)Calculation of \(m(x_i)\)Fitted mean (response units)Observed \(y_i\) (response units)
60\(4+0.5(6)+1.2(0)=7\)7.07.4
100\(4+0.5(10)+1.2(0)=9\)9.08.8
133\(4+0.5(13)+1.2(3)=14.1\)14.114.5

For \(x=6\), the difference from the knot is \(-4\), so its positive part is zero. At the knot the positive part is also zero. For \(x=13\), it is \(13-10=3\). Thus the hinge changes neither of the first two fitted means, while it adds \(1.2(3)=3.6\) response units to the base line at \(x=13\).

The differences between the observed responses and the displayed means are \(7.4-7.0=0.4\), \(8.8-9.0=-0.2\), and \(14.5-14.1=0.4\) response units. These are illustrative residuals relative to the stipulated model. The table demonstrates how to form and use the hinge column; it does not claim to estimate the coefficients from this small set.

A Short Algebraic Check

The hinge basis works because it has two simple behaviors: it vanishes on the lower side, and it has slope one on the upper side. Substituting these behaviors into the mean expression gives the segment slopes directly. Continuity can be checked by evaluating both pieces at \(k\):

$$ \begin{aligned} m(k\text{ from below})&=\beta_0+\beta_1k,\\ m(k\text{ from above})&=(\beta_0-\delta k)+(\beta_1+\delta)k\\ &=\beta_0-\delta k+\beta_1k+\delta k\\ &=\beta_0+\beta_1k. \end{aligned} $$

The values agree, while the slopes are \(\beta_1\) and \(\beta_1+\delta\). This establishes both properties: the hinge term introduces a slope change of \(\delta\), and it does not introduce a discontinuity in the mean.

Common Mistakes and Why the Basis Matters

  • Calling \(\delta\) the upper slope. The upper slope is \(\beta_1+\delta\); \(\delta\) is the difference between upper and lower slopes.
  • Using \(x-k\) without taking its positive part. That term is nonzero below the knot too, so it would alter the lower segment. The hinge \((x-k)_+\) is zero there.
  • Thinking a slope change implies a jump in the fitted mean. The hinge equals zero at the knot, and both segment expressions give the same value there.
  • Ignoring units. Since the hinge has the units of \(x\), its coefficient has units of response per unit of \(x\), just like a slope.

The basis is useful because a continuous slope change can be represented by adding one derived predictor column to the straight-line expression. Its algebra also makes interpretation transparent: the original linear term sets the slope below the knot, and the hinge coefficient adds to that slope only above the knot.

Check Your Understanding

Use the hinge definition and slope relationships to answer these questions.

  1. For \(k=5\), calculate \((x-k)_+\) when \(x=3\), \(x=5\), and \(x=8\).
  2. In \(m(x)=7+1.1x-0.4(x-12)_+\), what are the slopes below and above the knot? Give units if \(x\) is measured in minutes and \(m(x)\) in points.
  3. A continuous relationship has slopes \(3.2\) below a knot and \(4.0\) above it. What hinge coefficient represents this change? Explain its sign.
  4. Explain algebraically why adding \(\delta(x-k)_+\) does not change the fitted mean for \(x<k\).
  5. At the knot, why do the lower and upper segment expressions give the same fitted mean?