Tutorials › Regression Analysis (Undergraduate) › Predictor-Specific Residual Smooths for Curvature

Specification Checks and Residual Patterns · Tutorial 570 of 991

Predictor-Specific Residual Smooths for Curvature

Use predictor-specific residual smooths to look for curvature that a model’s current contribution for a quantitative predictor may not capture.

Advanced 9 min read

What You'll Learn

  • Define a predictor-specific residual smooth and explain what it summarizes.
  • Calculate simple local-average smooth values from residuals.
  • Recognize persistent bends that may indicate an overly simple predictor contribution.
  • Distinguish a broad pattern from one unusual residual or random variation.
  • Explain why a residual smooth is a diagnostic clue, not a formal test or proof of causation.

Why Look at Residuals Against a Predictor?

A residual-versus-fitted plot can reveal that a regression model misses broad structure, but it does not always show which predictor may be involved. When a predictor is quantitative, plotting residuals against that predictor gives a more targeted view: it asks whether the model’s remaining errors vary systematically across the predictor’s values. A smooth curve can make a gradual pattern easier to see than the individual residuals alone.

The diagnostic is evidence to investigate, not a verdict. A bend may suggest that the predictor’s modeled contribution is too simple, but other features of the model or data can also produce a bend. The plot does not establish that adding a particular term will improve the model, and it does not establish a causal relationship.

Definition: A predictor-specific residual smooth is a curve drawn through residuals plotted against one quantitative predictor. It summarizes the local direction and level of residuals as the predictor changes. A smooth that stays roughly level near zero suggests little visible systematic pattern in that direction. A persistent bend above and below zero suggests that the model may not capture all of the mean pattern associated with the predictor.

Set Up and Read the Plot

Suppose a fitted regression model gives fitted values \(\hat{Y}_i\) and residuals \(e_i=Y_i-\hat{Y}_i\). For a quantitative predictor \(x\), put the observed \(x_i\) values on the horizontal axis and the corresponding residuals \(e_i\) on the vertical axis. The horizontal reference line at zero marks observations for which the fitted value equals the observed response. Positive residuals mean the model underpredicted the response; negative residuals mean it overpredicted it.

A smooth curve is computed from nearby points, so it can reveal a gradual trend amid scatter. One simple illustration is a local average: at a selected predictor value, average the residuals in a stated neighborhood around that value. Common software uses more flexible smoothers, such as locally weighted polynomial fits, rather than one fixed averaging rule. The exact curve therefore depends partly on the smoothing method and how much of the data it uses at a time. A very flexible curve can follow random fluctuations; an overly smooth curve can hide real local structure.

For interpretation, look for a broad, sustained shape, not merely one point above or below zero. A U-shaped or inverted-U-shaped smooth is a familiar sign that a straight-line contribution may be too restrictive. A steadily rising or falling smooth can also indicate remaining structure, although in ordinary least squares with an intercept and that predictor entered linearly, the residuals have zero sample linear association with that predictor. The smooth can still bend because a curved pattern is different from a straight-line association.

Why the Smooth Can Bend When the Linear Association Is Zero

In ordinary least squares, the fitted coefficients minimize the sum of squared residuals. When the fitted model contains an intercept and a linear term in \(x\), the residuals are orthogonal to both the constant column and the \(x\) column. This means their sum and their sample cross-product with \(x\) are zero. These facts constrain the residuals, but they do not require the residuals to average to zero at every part of the \(x\)-axis.

$$ \sum_{i=1}^{n} e_i=0 \qquad\text{and}\qquad \sum_{i=1}^{n} x_i e_i=0 $$

To see why, write the sum of squared residuals as \(S=\sum_i(Y_i-\hat{\beta}_0-\hat{\beta}_1x_i)^2\). At the least-squares minimum, its derivatives with respect to the two coefficients are zero:

$$ \frac{\partial S}{\partial\hat{\beta}_0} =-2\sum_{i=1}^{n}e_i=0, \qquad \frac{\partial S}{\partial\hat{\beta}_1} =-2\sum_{i=1}^{n}x_i e_i=0. $$

These two constraints prevent a residual pattern from having an overall offset or a simple linear tilt in this setting. They do not prevent, for example, positive residuals at both ends of the predictor range and negative residuals in the middle. That pattern has zero overall average and can have zero linear cross-product while still showing curvature.

Worked Example: A Smooth That Reveals a U-Shape

Consider hypothetical data with predictor values \(x=-2,-1,0,1,2\), and responses \(Y=4,1,0,1,4\). Fit a straight-line model with an intercept and \(x\).

The mean response is \(\bar{Y}=(4+1+0+1+4)/5=2\). By symmetry, the fitted slope is zero, so the fitted line is \(\hat{Y}=2\). The residuals are therefore \(e_i=Y_i-\hat{Y}_i\), giving \(2,-1,-2,-1,2\) in order of increasing \(x\).

For a simple local-average illustration, average the two residuals at the left end, the single middle residual, and the two residuals at the right end:

$$ \text{left average}=\frac{2+(-1)}{2}=0.5,\qquad \text{middle average}=-2,\qquad \text{right average}=\frac{-1+2}{2}=0.5. $$

The resulting pattern is positive, negative, positive across the predictor range: a U-shape. The residuals sum to zero, and their cross-product with \(x\) is \((-2)(2)+(-1)(-1)+(0)(-2)+(1)(-1)+(2)(2)=0\). Thus the linear least-squares constraints hold even though the residual pattern bends. In context, the straight-line fit underpredicts at the ends and overpredicts near the middle, which is evidence to investigate whether a straight-line contribution for \(x\) is adequate.

Worked Examples: Reading Different Shapes

Worked Example: A Persistent Bend Across the Range

Suppose a hypothetical study models response \(Y\) using the straight-line fit \(\hat{Y}=10+2x\), with observed predictor values \(x=-3,-2,-1,1,2,3\). The observed responses are \(16,5,7,11,13,18\). The fitted values are \(4,6,8,12,14,16\), so subtracting fitted values from responses gives residuals \(12,-1,-1,-1,-1,2\).

The first residual of \(12\) is unusually large and would dominate a simple average, so do not infer curvature from the listed values as written. Instead, consider a separate, fully specified hypothetical response set \(Y=6,5,7,11,13,20\) at the same \(x\) values. Its residuals from the same fitted line are \(2,-1,-1,-1,-1,4\), which likewise are not centered and so are not the least-squares residuals for that fit. This illustrates why residuals must come from the actual fitted model; a claimed smooth pattern should not be assessed from numbers inconsistent with the fit.

For a consistent example, use responses \(Y=6,5,7,11,13,18\). The fitted values remain \(4,6,8,12,14,16\), and the residuals are \(2,-1,-1,-1,-1,2\). Their sum is \(2-1-1-1-1+2=0\), and their cross-product with \(x\) is \((-3)(2)+(-2)(-1)+(-1)(-1)+(1)(-1)+(2)(-1)+(3)(2)=0\).

A local-average smooth across the left, central, and right neighborhoods gives \((2-1)/2=0.5\), \((-1-1)/2=-1\), and \((-1+2)/2=0.5\). This sustained positive-negative-positive pattern is not a single isolated departure. It suggests that the straight-line contribution may be too simple, while leaving open other possible explanations that should be checked before changing the model.

Worked Example: Residual Scatter Without a Clear Smooth Pattern

For a second hypothetical data set, use the same predictor values and fitted line \(\hat{Y}=10+2x\), but let the responses be \(7,5,8,12,13,21\). The fitted values are \(4,6,8,12,14,16\), giving residuals \(3,-1,0,0,-1,5\). These are not consistent with the stated fitted line’s least-squares constraints, so they cannot be used as residuals from that fit. Instead, take the residual pattern \(1,-1,0,0,-1,1\), which does satisfy the constraints, and define responses as fitted value plus residual: \(5,5,8,12,13,17\).

The residuals sum to \(1-1+0+0-1+1=0\), and their cross-product with \(x\) is \((-3)(1)+(-2)(-1)+(-1)(0)+(1)(0)+(2)(-1)+(3)(1)=0\). The local averages for the left pair, middle pair, and right pair are \((1-1)/2=0\), \((0+0)/2=0\), and \((-1+1)/2=0\).

The individual residuals vary, but these neighborhood averages do not trace a bend. A smooth close to zero would provide little visual evidence of a systematic mean pattern over these regions. That is not proof that the model is correct: the sample may be small, the smoother may obscure a subtle pattern, or other diagnostics may reveal a problem.

Worked Example: A Single Point Can Mislead

Consider hypothetical predictor values \(x=-2,-1,0,1,2\), a fitted line \(\hat{Y}=5+0.8x\), and residuals \(0,1.5,-3,1.5,0\). The responses, obtained by adding each residual to its fitted value, are \(3.4,5.7,2,7.3,6.6\). The residuals sum to zero, and their cross-product with \(x\) is \((-2)(0)+(-1)(1.5)+(0)(-3)+(1)(1.5)+(2)(0)=0\), as required for this least-squares fit.

A local-average summary of the left pair, center, and right pair is \((0+1.5)/2=0.75\), \(-3\), and \((1.5+0)/2=0.75\). That could look like a sharp bend. However, the pattern is driven by one central residual of \(-3\); the other four residuals are small and positive or zero. It would be a mistake to call this persistent curvature based only on the smooth. Check the individual points and the influence of the unusual observation before drawing a structural conclusion.

Limits, Interpretation, and Common Mistakes

In a model with several predictors, a plot of residuals against one predictor is not a clean experiment that isolates that predictor’s contribution. Predictors can be related to each other, and residual patterns can reflect omitted variables, interactions, group differences, or other misspecification. Even when a bend is visible, the plot alone does not identify its cause. Treat it as a prompt for further model checking rather than as a formal test of a particular added term.

The vertical units remain the units of the response, because residuals are observed responses minus fitted responses. A curve above zero indicates average underprediction in that region; one below zero indicates average overprediction. Describe the shape and where it occurs, but do not interpret its height as a change in the predictor’s effect or as a causal effect.

  • Mistake: “The smooth bends, so the quadratic term is definitely required.” A bend is evidence of remaining structure, not proof of its source or of the best remedy. Check the raw residuals, other predictors, and the model context before deciding what to change.
  • Mistake: “The smoother crosses zero, so the model fits.” Crossing zero is not enough. Look for a sustained pattern above and below zero, not merely whether the curve intersects the reference line.
  • Mistake: “One extreme residual makes a curved pattern.” A local smoother can be pulled by an unusual point. Compare its curve with the individual residuals and assess whether the pattern persists across multiple observations.
  • Mistake: “A flat-looking curve proves there is no problem.” Smoothing choices, limited data, and other forms of misspecification can conceal structure. A residual smooth is one diagnostic view, not a guarantee.
Key takeaway: Plot residuals against a quantitative predictor and use a smooth curve to summarize whether residuals bend systematically across its range. A persistent bend is a clue that the modeled contribution may be too simple, but it is not by itself a formal test, a unique explanation, or proof of causation.

Check Your Understanding

Use the ideas in this tutorial to answer the following questions.

  1. In a residual-versus-predictor plot, what does a residual above zero mean for the corresponding fitted value?
  2. Why can residuals from a least-squares line have zero linear association with \(x\) and still show a U-shaped smooth?
  3. A smooth bends mainly because of one extreme residual. What should you inspect before concluding that the predictor’s contribution is too simple?
  4. Why does a bend in a residual plot against one predictor not prove that the predictor alone caused the remaining pattern?
  5. What does it mean, in context, if a residual smooth stays below zero over part of the predictor range?