Polynomial and Spline Regression
How to fit a curved relationship using ordinary linear regression tools, either by adding squared and cubed terms of a predictor (polynomial regression) or by stitching together several gently-bending pieces (spline regression) that flex locally without the wild swings a single high-degree polynomial produces.
Prerequisites: The Classical Linear Regression Assumptions, The Bias-Variance Decomposition
Plenty of real relationships in trading aren't straight lines: implied volatility curves and smiles by strike, the yield curve's shape across maturities, or a signal whose predictive power fades in a curved, not linear, way as it moves to extremes. A straight-line regression forces a single, constant slope onto data that genuinely bends, producing systematic errors exactly where you'd most like the model to be accurate (see Residual Diagnostics and Diagnostic Plots for how this shows up as a U-shaped residual pattern). Polynomial and spline regression let you fit a curve instead of a line, while still using the same linear regression machinery under the hood — you're not changing how the model is fit, only what variables you hand it.
An analogy: bending a ruler versus a jointed ruler
A single high-degree polynomial is like bending one long, stiff ruler to try to pass through a series of points — it can be coaxed into a curve, but pushing one end to fit a distant point can make the whole ruler bow and whip unpredictably elsewhere, especially near the ends. A spline is more like a jointed ruler made of several short, flexible segments hinged together: each segment only has to bend to fit the points near it, and a wiggle demanded by one segment doesn't force the whole ruler to distort somewhere else. Splines trade a single global curve for several well-behaved local ones, stitched together smoothly at the joints.
The mechanics, one symbol at a time
Polynomial regression adds powers of a predictor as extra columns in an otherwise ordinary linear regression:
where is the degree — still linear in the coefficients , which is why ordinary least squares fits it exactly like any other regression, even though the resulting curve in is bent, not straight. In plain English: you're not fitting a fundamentally different kind of model, you're just giving linear regression more shapes (, , …) to combine, and it finds the best-weighted blend of those shapes. Spline regression instead divides the range of into segments at chosen points called knots, and fits a separate low-degree polynomial (often cubic) within each segment, constrained to join up smoothly (matching value and slope) at each knot — so the curve bends locally near each knot rather than needing one global high-degree polynomial to do all the bending at once.
Worked example 1: fitting a volatility smile with a quadratic
A trader has three data points of implied vol by strike: at strike 90, vol is 22%; at strike 100 (at-the-money), vol is 18%; at strike 110, vol is 21%. A straight line can't capture this dip-then-rise shape at all — it can only go up, down, or stay flat throughout. Fitting a quadratic (with the strike, rescaled for convenience) to these three points exactly reproduces the smile: the model uses the term to bend the fit downward toward the middle and back up at the wings, something impossible for a plain line to do. This is exactly what the U-shaped residual pattern from a linear fit (see Residual Diagnostics and Diagnostic Plots) is telling you to add.
Worked example 2: why a high-degree polynomial misbehaves
Suppose instead of a quadratic, an analyst fits a degree-8 polynomial through 9 data points on the yield curve, forcing the curve to pass through every single point exactly. Between two closely-spaced maturities the interpolated yields might swing to unrealistic values — say, briefly implying a 15% yield between two maturities that both actually sit around 4% — purely because a high-degree polynomial has to whip wildly to satisfy every constraint simultaneously (a well-known problem called Runge's phenomenon, most visible near the ends of the range). Switching to a cubic spline with knots at, say, every third maturity fixes this: each local cubic segment only needs to fit the handful of nearby points, so no single segment is forced into a wild oscillation to satisfy a far-away constraint, and the curve stays close to the data everywhere, including between the knots.
Adjust the curve's parameters and notice how a single quadratic term is enough to produce a smile-like dip-and-rise shape — this is the mechanism behind Worked Example 1's volatility smile fit.
What this means in practice
Polynomial terms are a quick, simple fix when you know a relationship has one gentle bend and don't want to leave the familiar linear-regression framework — a quadratic term for a volatility smile, for instance. Splines are the better tool once the shape is more complex or spans a wider range, such as fitting an entire yield curve or a volatility surface across many strikes and maturities, because they avoid the instability that a single high-degree polynomial introduces. Both are ultimately still "linear regression in disguise" — the nonlinearity lives entirely in which columns you feed the model, not in how the fitting itself works.
Polynomial regression fits a curve by adding powers of as extra predictors to an ordinary linear regression; spline regression instead stitches together several local low-degree curves at chosen knots. Polynomials are simple but a high degree can oscillate wildly between data points; splines bend locally and stay well-behaved across the full range.
The classic mistake is reaching for a high-degree polynomial to fit a curve more "tightly," without realizing the extra wiggle room mostly buys overfitting, not accuracy — the fitted curve can swing through unrealistic values between data points (Runge's phenomenon) even while passing exactly through every observed point. If a curve needs to flex significantly across its range, a spline with a modest number of knots almost always generalizes better than pushing a single polynomial to a higher and higher degree.
Related concepts
Practice in interviews
Further reading
- James, Witten, Hastie & Tibshirani, An Introduction to Statistical Learning, ch. 7
- Hastie & Tibshirani, Generalized Additive Models, ch. 2