STATISTICAL METHODS · BEGINNER GUIDE
Polynomial Regression and Overfitting: A Small Example
Learn why a high-degree polynomial can follow training data closely but predict poorly, and how validation helps.
Quick answer: Polynomial regression adds powers of a predictor, such as x² or x³, while remaining linear in its fitted coefficients. A high-degree curve can fit training noise, so compare models using validation that resembles future use.
What this method answers
More flexibility can capture real curvature but can also make the fitted curve unstable between observed points and at the edges. Training error tends to fall as terms are added; that alone is not evidence of better generalization.
Consider polynomial terms when a plot and subject knowledge suggest smooth curvature. Scale or center x when appropriate, inspect the fitted shape and use held-out or cross-validation error to choose complexity.
Before running a calculation, write down the population and the exact quantity you want to estimate. A method name alone does not define the question, the comparison or the assumptions.
Steps to follow
- Plot the observed x-y relationship before choosing polynomial degree.
- Fit a small set of plausible degrees and scale x if numerical conditioning needs it.
- Use a held-out or cross-validation design; fit preprocessing and degree selection inside training data.
- Compare validation error, coefficient stability and the curve at the range boundaries.
Keep a record of exclusions, recoding decisions and software settings. That makes the analysis easier to check and repeat.
Worked example
A small invented dataset has observed y values at x=0,1,2,3. Compare training mean squared error for two fitted models only as a teaching illustration.
| Model | Training MSE |
|---|---|
| Straight line | 8 |
| Degree-5 polynomial | 0.2 |
The degree-5 model’s training MSE is smaller (0.2 vs 8), but four x locations cannot support a stable degree-5 curve. The extra fit may be following noise; an independent validation set is needed to estimate future prediction error.
Interpret the result carefully
A more complex model can look impressive on the data used to fit it while behaving erratically on new inputs. Inspect both training and validation performance and keep the prediction range visible.
Limit to keep in mind: Cross-validation is not a cure for poor sampling or leakage. All preprocessing and model selection must happen within the training folds to avoid optimistic estimates.
When reporting an analysis, include the sample size, estimate, units and uncertainty. Explain why the method fits the sampling and measurement design. Separate planned tests from exploratory checks, and avoid saying that association proves a cause.
Frequently asked questions
Is polynomial regression nonlinear in its coefficients?
No. It is nonlinear in x but linear in coefficients, so it can be fit with linear-model methods.
Why can a high-degree curve overfit?
It has enough flexibility to follow sample noise and can swing sharply between or beyond observed points.
Does a lower training error mean a better model?
Not necessarily. Evaluate on data not used to select the model.
Can I extrapolate a polynomial far outside my data?
Usually this is risky because polynomial curves can grow rapidly beyond the observed range.