Tutorials › Regression Analysis (Undergraduate) › Reading Segment Slopes and Fitted Values

Piecewise Regression and Splines · Tutorial 447 of 991

Reading Segment Slopes and Fitted Values

Translate the coefficients of a fixed-knot model into segment-specific slopes and use the fitted equation to calculate and compare predicted outcomes.

Advanced 9 min read

What You'll Learn

  • Identify the role of the intercept, baseline slope, jump coefficient, and hinge coefficient in a fixed-knot model.
  • Calculate the slopes to the left and right of a knot.
  • Evaluate fitted values on either side of the knot, including at the knot itself.
  • Find and explain changes in predicted outcomes within a segment or across the knot.
  • Recognize when the intercept is an extrapolation and avoid treating a coefficient as a causal effect.

Reading a Fixed-Knot Model

A piecewise linear regression model uses a straight line on each side of a specified predictor value, called the knot. Its coefficients do not each describe a separate segment slope directly. Instead, the baseline slope describes the left segment, while a hinge coefficient modifies that slope to give the right segment. A separate indicator coefficient can represent a jump in the fitted mean at the knot.

To interpret predictions and changes correctly, first identify the exact model parameterization. This tutorial uses a model with a baseline line in \(x\), a positive-part hinge at the knot \(c\), and an indicator for being at or to the right of the knot. The indicator convention matters: the fitted value at \(x=c\) is assigned to the right-hand segment.

Definition: Let \(c\) be a fixed knot and define the positive-part hinge \( (x-c)_+ = \max(0,x-c) \). The fixed-knot model is $$ Y_i = \beta_0+\beta_1 x_i+\beta_2(x_i-c)_+ +\beta_3 I(x_i\ge c)+\varepsilon_i. $$ Here \(I(x_i\ge c)\) equals 1 when \(x_i\ge c\) and 0 otherwise. The conditional mean is modeled as \(E(Y_i\mid x_i)\) equal to the non-error part of this expression. The error satisfies \(E(\varepsilon_i\mid x_i)=0\). For the usual regression interpretation, observations are treated as independent; constant error variance is an additional familiar assumption for standard regression procedures, but is not needed for the algebraic coefficient interpretations below.

The model is linear in its coefficients, although its fitted mean is piecewise linear in \(x\). When fitted coefficients are used, write them as \(\hat\beta_0,\hat\beta_1,\hat\beta_2,\hat\beta_3\); the fitted value at a predictor value \(x\) is \(\hat y(x)\). The formulas below apply either to the model coefficients or, by substitution, to their estimates.

Segment Slopes and the Knot

For a value below the knot, \(x<c\), both the hinge and indicator are zero. For a value at or above the knot, the hinge is \(x-c\) and the indicator is one. Consequently, the two segment equations are:

$$ E(Y\mid x)= \begin{cases} \beta_0+\beta_1x, & x<c,\\ \beta_0+\beta_1x+\beta_2(x-c)+\beta_3, & x\ge c. \end{cases} $$

On the left, the slope is \(\beta_1\). On the right, collect the terms involving \(x\): the coefficient of \(x\) is \(\beta_1+\beta_2\), so that is the right-segment slope. The hinge coefficient \(\beta_2\) is therefore the change in slope, not the right-segment slope itself. The indicator coefficient \(\beta_3\) is the modeled jump at the knot.

Key result: The left-segment slope is \(\beta_1\); the right-segment slope is \(\beta_1+\beta_2\). The left-hand limit at the knot is \(\beta_0+\beta_1c\), whereas the model’s fitted mean at \(x=c\) is \(\beta_0+\beta_1c+\beta_3\). Thus the right-hand value minus the left-hand limit is \(\beta_3\). When \(\beta_3=0\), the fitted mean is continuous at the knot.

The intercept \(\beta_0\) is the modeled mean at \(x=0\) when zero is on the left side of the knot. If zero is outside the observed predictor range, or is not a meaningful predictor value, this intercept may be an algebraic reference rather than a useful in-range prediction. It is not automatically the fitted mean at the knot; that value also depends on \(\beta_1c\) and \(\beta_3\).

Worked Example: Interpreting the Coefficients and Segment Slopes

Suppose a hypothetical fitted model predicts a symptom score, in points, from dose \(x\), measured in milligrams. The fixed knot is \(c=10\) mg and the fitted equation is

$$ \hat y(x)=12+1.5x-0.4(x-10)_+ +3I(x\ge10). $$

For doses below 10 mg, the hinge and indicator terms are zero. The fitted left-segment equation is \(\hat y(x)=12+1.5x\), with slope \(1.5\) points per mg. For doses at or above 10 mg, the right-segment equation is

$$ \hat y(x)=12+1.5x-0.4(x-10)+3=11+1.1x. $$

The right-segment slope is \(1.5+(-0.4)=1.1\) points per mg. Thus the fitted rate of change is 0.4 points per mg smaller to the right of the knot than to the left. This describes the model’s change in slope; it does not say that the outcome itself drops by 0.4 points at the knot.

Just below the knot, the fitted mean approaches \(12+1.5(10)=27\) points. At \(x=10\), the indicator is 1 and the hinge is 0, so the model predicts \(12+1.5(10)+3=30\) points. The fitted jump is therefore \(30-27=3\) points. These predictions describe the fitted mean, not a guaranteed score for an individual.

Calculating Fitted Values and Changes

To calculate a fitted value, substitute the predictor value into the full equation, including both the hinge and indicator terms. For values below the knot, both added terms are zero. At or above the knot, include the jump coefficient, and calculate the hinge distance \(x-c\). Keeping these steps explicit helps prevent using the right slope without also accounting for the jump.

The change in fitted outcome between two predictor values can be derived by subtracting their fitted equations. For \(x_1<x_2\), the baseline linear term changes by \(\beta_1(x_2-x_1)\); the hinge and indicator terms change by their respective differences:

$$ E(Y\mid x_2)-E(Y\mid x_1) =\beta_1(x_2-x_1) +\beta_2\big[(x_2-c)_+-(x_1-c)_+\big] +\beta_3\big[I(x_2\ge c)-I(x_1\ge c)\big]. $$

This identity gives a useful check on a direct subtraction of two fitted values. If both values are below the knot, only the baseline slope contributes. If both are at or above the knot, the indicator terms cancel and the change follows the right slope. If the values straddle the knot, the hinge and jump contributions must both be included.

Worked Example: Predicting on Either Side and Comparing Values

Use the fitted dose model from the previous example to compare a dose of 6 mg with a dose of 14 mg. Both values use the same hypothetical equation, with knot \(c=10\) mg.

At 6 mg, the hinge and indicator are zero:

$$ \hat y(6)=12+1.5(6)-0.4(0)+3(0)=12+9=21\text{ points}. $$

At 14 mg, the hinge is \(14-10=4\) mg and the indicator is 1:

$$ \hat y(14)=12+1.5(14)-0.4(4)+3(1) =12+21-1.6+3=34.4\text{ points}. $$

The fitted difference is \(34.4-21=13.4\) points. The subtraction formula gives the same result:

$$ 1.5(14-6)-0.4(4-0)+3(1-0) =12-1.6+3=13.4\text{ points}. $$

The comparison includes an 8 mg increase along the baseline slope, a hinge adjustment after the knot, and the modeled jump. It is a difference between fitted means at two doses, not a claim that changing an individual’s dose would cause that difference.

Using the Right Formula for the Comparison

A comparison within one segment is simpler because the jump term does not change. If both predictor values are at or above the knot, the slope governing their fitted difference is \(\beta_1+\beta_2\), even though each fitted value still includes the jump coefficient. Below the knot, the slope is \(\beta_1\). Across the knot, use either the full equation at both points or the general difference formula.

Worked Example: Comparing Values That Straddle a Knot

Consider a second hypothetical fitted model for a measured score \(Y\), in points, as a function of elapsed time \(x\), in hours. Its fixed knot is \(c=4\) hours:

$$ \hat y(x)=50+2x+1(x-4)_+-5I(x\ge4). $$

Compare the fitted scores at 2 and 6 hours. At 2 hours, both added terms are zero:

$$ \hat y(2)=50+2(2)+1(0)-5(0)=54\text{ points}. $$

At 6 hours, the hinge is \(6-4=2\) hours and the indicator is 1:

$$ \hat y(6)=50+2(6)+1(2)-5(1)=50+12+2-5=59\text{ points}. $$

The fitted difference is \(59-54=5\) points. From the difference formula it is

$$ 2(6-2)+1(2-0)-5(1-0)=8+2-5=5\text{ points}. $$

The left slope is 2 points per hour and the right slope is \(2+1=3\) points per hour. The two-hour distance above the knot adds a hinge contribution of 2 points, while crossing the knot contributes a jump of \(-5\) points. Their combined contribution explains why the net fitted increase is 5 points rather than simply four hours times either segment slope.

Why the Interpretation Matters

Segment-specific slope interpretations make a model’s fitted shape easier to explain. They also help distinguish three different features: the baseline level, the rate of change within a segment, and the change in that rate after the knot. If the jump coefficient is included, there is a fourth feature: a discontinuity in the fitted mean at the knot. The estimated coefficients should be interpreted according to their roles in the chosen equation, rather than by reading each coefficient as an outcome change on its own.

The fitted equation describes an association represented by the model. A slope or predicted difference alone does not establish that changing \(x\) causes \(Y\) to change. A causal interpretation requires an appropriate study design and additional justification beyond this piecewise equation.

  • Mistake: treating the hinge coefficient as the right slope. If \(\beta_1=2\) and \(\beta_2=1\), the right slope is \(2+1=3\), not 1.
  • Mistake: treating the jump coefficient as a slope change. The jump coefficient shifts the fitted mean at the knot; the hinge coefficient changes the slope.
  • Mistake: omitting the jump when comparing values across the knot. If one value is below \(c\) and the other is at or above \(c\), the indicator changes, so its coefficient contributes to the difference.
  • Mistake: using the left-hand limit as the model’s value at the knot. With \(I(x\ge c)\), the knot itself is assigned to the right segment. Evaluate the equation at \(x=c\) using that convention.
  • Mistake: interpreting an intercept as a typical observed outcome. The intercept refers to \(x=0\); if zero is outside the relevant range, that value may be an extrapolation.
Key takeaway: For the fixed-knot model \( \beta_0+\beta_1x+\beta_2(x-c)_++\beta_3I(x\ge c) \), the segment slopes are \(\beta_1\) and \(\beta_1+\beta_2\), and the modeled jump is \(\beta_3\). To compare fitted outcomes, substitute both predictor values or subtract the full equations, including every hinge and indicator term that changes.

Check Your Understanding

Use the model \( \hat y(x)=8+0.6x-0.2(x-5)_++2I(x\ge5) \) for questions 1–3. The outcome is measured in points and \(x\) in hours.

  1. What are the left- and right-segment slopes, with units?
  2. What fitted value does the model assign at \(x=5\)? What is the left-hand limit there, and what is the modeled jump?
  3. Calculate \(\hat y(3)\) and \(\hat y(7)\), then find the fitted difference \(\hat y(7)-\hat y(3)\).
  4. In a fixed-knot model, explain why the hinge coefficient is not generally the right-segment slope.
  5. Why might the intercept be an unhelpful practical prediction even when the equation is correctly calculated at \(x=0\)?