advanced37 min studyLesson 713 in Mathematics

Local polynomial regression

Fit weighted local Taylor models, derive reproduction identities, and understand boundary correction without assuming positive prediction weights.

On this page

What you’ll understand

  • Construct local-linear normal equations at a target point.
  • Use polynomial reproduction to explain boundary behavior.
  • Calculate local prediction weights and their conditional variance.

Nonparametric regression estimates the conditional mean of a response rather than the density of the predictors. A local polynomial fits a small Taylor-like model around each target location using nearby observations. The coefficients change with that location, so the global fitted curve need not be one polynomial. Local-linear fitting is especially useful near a boundary: it reproduces a line even when observations lie mostly on one side. That benefit is paid for by potentially negative prediction weights and by the need for a well-conditioned local design.

Fit around the point where a prediction is needed

Write Yi=m(Xi)+εiY_i=m(X_i)+\varepsilon_i with conditional mean-zero errors. At a target x, form polynomial coordinates in Xi−xX_i-x and minimize weighted squared residuals using nonnegative kernel weights. The fitted intercept estimates m(x); the fitted slope in a degree-one model estimates its local derivative only under additional smoothness and shrinking-bandwidth conditions. Scaling polynomial coordinates by h can improve numerical conditioning, but changes the interpretation of the slope coefficient by the corresponding factor.

Condition on the observed predictors when calculating a finite-sample fit. The weighted Gram matrix must be invertible on the polynomial columns used; a local-linear fit needs at least two distinct predictor values with positive weights. A zero denominator or nearly singular matrix is a local-data problem, not proof that the underlying mean is undefined. Random-design asymptotics typically require a positive design density near the target and enough observations inside the shrinking window, in addition to assumptions on the errors and regression function.

(β^0,β^1)=arg⁡min⁡b0,b1∑iK ⁣(Xi−xh)[Yi−b0−b1(Xi−x)]2,m^h(x)=β^0(\widehat\beta_0,\widehat\beta_1)=\arg\min_{b_0,b_1}\sum_iK\!\left(\frac{X_i-x}{h}\right)[Y_i-b_0-b_1(X_i-x)]^2,\qquad \widehat m_h(x)=\widehat\beta_0
The common 1/h factor in all weights can be omitted without changing this regression minimizer.↔ Scroll wide equations horizontally.

Reproduction identities remove the linear bias

For an invertible local-linear design, the estimate is a weighted sum ∑iℓi(x)Yi\sum_i\ell_i(x)Y_i, where the prediction weights sum to one and their first centered moment is zero. Therefore constant and linear mean functions are reproduced exactly conditional on the predictors. These identities hold even near a boundary. In contrast, a local-constant kernel average generally has a nonzero first moment in a one-sided window and can inherit a first-order boundary bias from a sloping mean.

The original least-squares weights are nonnegative, but the derived prediction weights need not be. Negative prediction weights are how a boundary fit can extrapolate a line back to the target. Thus a local-linear prediction need not lie between the observed responses. With independent homoskedastic errors conditional on the predictors, its variance is sigma squared times the sum of squared prediction weights. Large positive and negative weights can increase that variance substantially; polynomial reproduction does not by itself guarantee a stable estimate.

∑iℓi(x)=1,∑iℓi(x)(Xi−x)=0,Var⁡(m^h(x)∣X)=σ2∑iℓi(x)2\sum_i\ell_i(x)=1,\qquad\sum_i\ell_i(x)(X_i-x)=0,\qquad\operatorname{Var}(\widehat m_h(x)\mid X)=\sigma^2\sum_i\ell_i(x)^2
The variance formula assumes conditionally independent errors of common variance sigma². Heteroskedasticity requires the weighted sum of the individual variances instead.↔ Scroll wide equations horizontally.

Local approximation and sampling error are separate

A Taylor expansion explains why reproducing a line helps when the true regression curve has a continuous second derivative. With standard regular kernels, a positive regular design density and a nonsingular limiting local moment matrix, local-linear bias is of order h squared, including at an ordinary one-sided support boundary; variance has order one over nh in one dimension. At a boundary the constants differ from the interior constants. These are local asymptotic statements, not guarantees for an empty window or a discontinuous mean.

Higher-degree fits reproduce more polynomial terms but require more information and can be unstable if the local geometry is poor. Choosing degree and bandwidth by visual flexibility alone can turn a sparse neighborhood into an extrapolation problem. The target is the conditional mean, so residual prediction error also includes irreducible response noise. A confidence interval for the mean is consequently narrower than a prediction interval for a new individual response, and both must account for any smoothing bias that remains relevant at the selected bandwidth.

A boundary fit with a negative prediction weight

At target x=0 use predictor values 0,1,2, responses 1,2,2, and equal positive kernel weights. Find the local-linear intercept and compare it with the local-constant estimate.

  1. The normal-equation matrix is [[3,3],[3,5]], and the right side is [5,6]. Its determinant is six, so the local-linear design is invertible.

  2. Solving gives intercept (25−18)/6=7/6 and slope (18−15)/6=1/2. The intercept weights are 5/6,1/3,−1/6; they sum to one and their predictor-weighted sum is zero.

  3. Applying the weights gives 5/6+2/3−1/3=7/6. The local-constant average is 5/3. The negative last weight is compatible with nonnegative kernel fitting weights and implements linear reproduction at the boundary.

The result

The local-linear estimate is 7/6. Under conditional independent variance sigma², its variance is (5/6)sigma², compared with sigma²/3 for the equal average.

Explore the model

Interactive lab

Interactive lab · function

Inspect curvature left after a tangent fit

Pause and Reset, then set both controls to coefficient a=1 and position x=0.5; predict value 0.25 and slope 1. Reset and set a=2 and x=0.5; predict value 0.5 and slope 2. For this quadratic, a tangent misses nearby values by exactly a times the squared displacement. The instrument exposes that deterministic Taylor remainder; it does not fit data or calculate kernel weights.

Inspect curvature left after a tangent fitThis lab uses only y = ax². Playback traces the curve within the fixed integration interval from 0 to x; it does not estimate numerical error or change the chosen point. Current readings: y at chosen x: 0.608; Tangent slope · 2ax: 1.35; Signed area · ax³/3: 0.182. All parameters are adjustable with the labeled controls below.−2.4−1.201.22.4−9−4.504.59xy(x, ax²)
y = ax²TangentSigned integral
y at chosen x
0.608
Tangent slope · 2ax
1.35
Signed area · ax³/3
0.182
t = 0 s

This lab uses only y = ax². Playback traces the curve within the fixed integration interval from 0 to x; it does not estimate numerical error or change the chosen point. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forReproducing a tangent removes constant and linear error, leaving curvature to control the leading local approximation.

Check your understanding

Why can a local-linear estimate have negative prediction weights despite nonnegative kernel weights?

Try it yourself

Keep predictor values 0,1,2 and equal local weights at target zero, but use responses 2,5,8. Find the local-linear and local-constant predictions and explain the difference.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

The responses lie on one line. Use reproduction or apply the intercept weights from the example.

Compare with the solution

The responses satisfy Y=2+3X exactly, so the local-linear intercept is two and the slope is three. Direct weighting gives (5/6)2+(1/3)5−(1/6)8=2. The local-constant estimate is five, the response average, which is centered at the average predictor one rather than at the target zero. This deterministic reproduction comparison does not mean that local-linear fitting always has smaller mean squared error once random noise is included.

Take it with you

  • Local polynomials fit a new weighted model at each target.
  • Local-linear moment identities reproduce lines even in one-sided windows.
  • Negative prediction weights can remove bias while increasing conditional variance.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.