Local Polynomial Regression and LOESS
A fix for kernel regression's weakness at the edges of the data — instead of a flat weighted average in a local window, fit a small weighted line or parabola in that window, sliding it across the whole range of x.
Prerequisites: Kernel Regression and the Nadaraya-Watson Estimator, The Classical Linear Regression Assumptions
Kernel regression estimates a curve by taking a local weighted average at every point — but a flat average is a bad local approximation whenever the true curve is actually sloping, and it gets systematically worse right at the edges of the data, where the local window only has points on one side to average. Local polynomial regression, and its popular implementation LOESS, fix this by fitting a small weighted straight line (or parabola) in each local window instead of a flat average, and sliding that window across the full range of the data.
An analogy: a tailor's local measurements
Fitting one single formula to describe a person's whole body shape from head to toe would be absurd — instead a tailor takes local measurements, and near any specific point (the waist, the shoulder), a straight taper line fit just to that region works far better than any single global curve, and works especially well right at the very top or bottom of the body where a flat local average would clearly be wrong (an average of "just below the shoulder" measurements doesn't describe the shoulder's actual slope). LOESS does this systematically for a whole dataset: at every point along , it fits a small local line (or curve) using only nearby, weighted data, and the local line adapts to the true slope of the data right up to the boundary.
The idea, one symbol at a time
At a query point , local linear regression solves a weighted least squares problem using only data near :
and the fitted value at is . In plain English: fit a straight line through the data, but weight each point's contribution to the fit by how close it is to (using kernel and bandwidth , exactly as in Nadaraya-Watson), then read off the line's height at itself as your estimate — and repeat this whole fitting procedure fresh at every point along the x-axis you want a fitted value for. Unlike Nadaraya-Watson's flat local average, a locally linear fit can capture and extrapolate a local slope, which is precisely what removes the systematic pull-toward-the-middle bias at the boundary — the local line can tilt to match the true trend even when data only exists on one side.
Worked example 1: comparing flat average vs local line at a boundary
Suppose near the left boundary of the data, you have points , evenly weighted, and you want the estimate at (right at the edge — no data exists below it). Nadaraya-Watson's flat weighted average of the three 's is , even though the true local trend is clearly rising by 2 per unit , meaning the honest value at should be closer to 10, not 12. A local linear fit through the same three points gives slope , intercept such that the line passes through , giving at — matching the actual boundary value far better than the flat average's inflated 12.
Worked example 2: fitting a small yield curve segment
Suppose four nearby maturities and yields: , and you want a smoothed yield at maturity 2.5 using a local linear fit with roughly equal weight on all four (wide bandwidth). A least-squares line through these four points has slope per year and passes near ; extrapolating to : . This locally linear smoothing gives a yield curve value at 2.5 years that respects the visible upward slope in the surrounding data, rather than just averaging the four yields flatly (which would give , close here but diverging more sharply whenever the local slope is steeper).
What this means in practice
LOESS is the default "just show me the trend" smoother in most plotting software for a reason: it handles curved trends and boundary regions gracefully with minimal tuning beyond the bandwidth. In finance it's used for smoothing noisy scatter — realized vol against implied vol, factor exposure against forward return — without committing to a specific parametric shape, and it's often preferred over Nadaraya-Watson specifically because trading data frequently needs a reliable estimate right at the edge of the observed range (e.g., the shortest or longest maturity available).
Local polynomial regression (LOESS) fits a small weighted line or curve in a sliding local window around each point, rather than a flat local average — this lets it follow local slope and removes the boundary bias that plain kernel (Nadaraya-Watson) regression suffers from at the edges of the data.
Local polynomial fits with a higher-degree local polynomial (say local quadratic instead of local linear) reduce bias further but increase variance, and with limited data per local window a local quadratic fit can become unstable — wiggling wildly to match noise rather than trend. Going up in local polynomial degree is not a free upgrade; it trades one kind of error for another exactly as increasing model complexity always does.
Related concepts
Practice in interviews
Further reading
- Cleveland, 'Robust Locally Weighted Regression and Smoothing Scatterplots', JASA
- Hastie, Tibshirani & Friedman, The Elements of Statistical Learning, ch. 6