Polynomial least squares

Intermediate

What you need first. Nothing else on this path comes first. This page is part of Statistical inference.

In regression, polynomial least squares are estimates of a polynomial mean obtained by minimising squared residuals. Polynomial least squares estimates the coefficients of a polynomial mean by minimising the sum of squared residuals. The mean is a curve in the predictor and a straight line in the coefficients. The fit is therefore ordinary linear least squares on the powers of the predictor, not a nonlinear search.[1][2]

Polynomial least squares

Polynomial least squares
Fact Value
Topic Statistical inference
Listed on Statistical inference
Worked example 1

Motivating example

Wage plotted against age rises and then flattens. A straight line in age cannot follow that bend. A polynomial in age can: each extra power is another column, and least squares estimates the columns together. A degree-4 polynomial is the curve James, Witten, Hastie, and Tibshirani fit to the Wage data, and it is still linear in its five coefficients. The bend is in age. The estimation is the linear one.[1]

Definition

For a single predictor xx and a chosen degree dd, the mean is

yi=β0+β1xi+β2xi2+⋯+βdxid+εi.y_i=\beta_0+\beta_1 x_i+\beta_2 x_i^2+\cdots+\beta_d x_i^d+\varepsilon_i.

The coefficients minimise

∑i=1n(yi−β0−β1xi−⋯−βdxid)2.\sum_{i=1}^n\bigl(y_i-\beta_0-\beta_1 x_i-\cdots-\beta_d x_i^d\bigr)^2.

The powers 1,x,x2,…,xd1, x, x^2, \ldots, x^d are known once xx is known, so the normal equations are linear in β0,…,βd\beta_0,\ldots,\beta_d. A function is statistically linear when the unknown coefficients sit outside known functions of the predictors. A quadratic in xx meets that test. A mean such as β0exp⁡(−β1x)\beta_0\exp(-\beta_1 x) does not, because β1\beta_1 sits inside the function.[1][2][3]

Properties

The fitted polynomial f^(x)\hat f(x) is a linear combination of the estimated coefficients. Under an additive error model with fixed xx and uncorrelated errors of variance σ2\sigma^2, the variance of f^(x0)\hat f(x_0) at a chosen x0x_0 is σ2\sigma^2 times a quadratic form in the powers of x0x_0. That variance is a pointwise scale. A band drawn at each x0x_0 from the pointwise standard error does not, by that construction, cover the whole curve at once.[1]

Adding a power cannot raise the residual sum of squares on the data used to fit the curve. The degree-dd polynomial includes the degree-(d−1)(d-1) polynomial as the case βd=0\beta_d=0, so the minimiser is at least as close, in squared error, as the lower degree. The drop is the price of one more free coefficient. It is evidence of curvature only together with the plot.[1]

On four points the algebra is small enough to see. For (x,y)=(0,1)(x,y)=(0,1), (1,2)(1,2), (2,2)(2,2), and (3,5)(3,5), the power sums are n=4n=4, ∑x=6\sum x=6, ∑x2=14\sum x^2=14, ∑x3=36\sum x^3=36, ∑x4=98\sum x^4=98, ∑y=10\sum y=10, ∑xy=21\sum xy=21, and ∑x2y=55\sum x^2 y=55. The normal equations have the unique solution β^0=1.2\hat\beta_0=1.2, β^1=−0.3\hat\beta_1=-0.3, β^2=0.5\hat\beta_2=0.5. The fitted values are 1.21.2, 1.41.4, 2.62.6, and 4.84.8. The residuals are −0.2-0.2, 0.60.6, −0.6-0.6, and 0.20.2, and the residual sum of squares is 0.80.8. The straight line on the same points has intercept 0.70.7 and slope 1.21.2, and its residual sum of squares is 1.81.8. The quadratic spends one extra coefficient and removes 1.01.0 from that sum.[2]

Statistical use

Choose a small degree, fit the powers by ordinary least squares, and plot f^(x)\hat f(x) on the range of xx that was observed. James and coauthors warn against a degree above 3 or 4: for large dd the polynomial can take strange shapes, especially near the boundary of the observed xx. Compare the residual sum of squares with that of the straight line on the same points. A smaller sum is expected once extra coefficients are free. It becomes a reason to keep the bend when the plot shows the bend inside the range, not only at the two ends.[1]

The coefficients themselves are a poor summary of a high-degree fit. The fitted value at one age depends on all of them at once. Report f^(x)\hat f(x) at ages inside the sample, not a list of powers as if each were a separate slope.[1]

Worked example

The four-point quadratic above has coefficients 1.21.2, −0.3-0.3, and 0.50.5, and residual sum of squares 0.80.8. The straight line on the same points has residual sum of squares 1.81.8. The fitted curve falls slightly from x=0x=0 to x=1x=1, because the linear coefficient is negative, and then rises, because the square coefficient is positive. Both statements are readings of one fitted function. Neither coefficient is the change in yy per unit xx.[1][2]

Your turn. Fit y=β0+β1x+β2x2y=\beta_0+\beta_1 x+\beta_2 x^2 to (0,1)(0,1), (1,0)(1,0), and (2,1)(2,1). Give the three coefficients and the residual sum of squares.

The three points lie on (x−1)2=1−2x+x2(x-1)^2=1-2x+x^2, so the coefficients are 11, −2-2, and 11. Every residual is 00, and the residual sum of squares is 00.

Common misconceptions

Polynomial least squares is not nonlinear regression. The mean is nonlinear as a function of xx and linear as a function of β\beta. The test is whether the coefficients can be moved outside known functions of the data. If they can, the fit is the linear one, extra columns and all. Dodge’s nonlinear example, a mean in which two coefficients sit inside exponentials, fails that test and is solved iteratively. A quadratic does not.[2][3]

A large degree is not a closer look at the same curve. It is a more flexible function, and near the ends of the age range the extra flexibility is where a polynomial is least trustworthy. The pointwise band at twice the standard error is not a statement that the whole curve lies inside the band with the same coverage. Each x0x_0 has its own interval.[1]

Connections

The one-predictor case of ordinary least squares is the degree-1 polynomial. Multiple linear regression is the same algebra with columns that need not be powers of a single xx. Nonlinear regression begins when a coefficient moves inside the function and the normal equations stop being linear. A degree so high that the curve follows the sample is the overfitting problem for this particular linear model.[1][3]

Check yourself

Try these questions before opening an answer.

Curved in x, linear in the coefficients

The mean β0 + β1 x + β2 x^2 bends in x. Why is the least-squares fit still the linear one?

Each coefficient multiplies a column that is known once x is known. The normal equations stay linear in the coefficients. A coefficient sitting inside the function, as in an exponential rate, is the nonlinear case.

An extra free coefficient

A quadratic is fitted to the same points as a straight line and the residual sum of squares falls. Why is that drop expected even before anyone looks at the plot?

The straight line is the quadratic with the square coefficient set to zero. The minimiser over a larger set of coefficients cannot have a larger residual sum of squares. The drop becomes evidence of curvature only together with the plot.

The edge of the range

Why is a high-degree polynomial least trustworthy near the ends of the observed range of x?

The extra powers can swing sharply there even when the curve is calm in the middle, and a polynomial has no horizontal asymptote to level off.

History

Least squares, as a way to combine inconsistent observations, was published by Legendre in 1805, and Gauss and Adrain were working with the same squared-error criterion in the same period. The extension from a straight line to a polynomial keeps that criterion and adds powers as further predictors. The modern warning about high degree is the same warning as for any flexible linear model: the fit can follow the sample near the edge of the observed range.[2][1]

See also

Line chart · Apriori algorithm · Asymptotic analysis · Average treatment effect · Base rate · Bayesian inference · Bayesian model · Bayesian probability

Glossary and index

References

  1. ^ a b c d e f g h i j k a. (pp. 266–267, §7.1) b. (p. 267, §7.1) c. (p. 266, §7.1) d. (pp. 267–268, §7.1) e. (pp. 266–267, §7.1) f. (pp. 266–268, §7.1) g. (p. 266, §7.1) h. (p. 266, §7.1) i. (pp. 266–268, §7.1) j. (pp. 266–267, §7.1) k. (p. 266, §7.1) James, G., Witten, D., Hastie, T. & Tibshirani, R. (2013). An Introduction to Statistical Learning: with Applications in R (1st ed.). Springer, New York. https://doi.org/10.1007/978-1-4614-7138-7
  2. ^ a b c d e f a. (§4.1.4.1) b. (§4.1.4.1) c. (§4.1.4.1) d. (§4.1.4.1) e. (§4.1.4.1) f. (§4.1.4.1) NIST/SEMATECH (2002). NIST/SEMATECH e-Handbook of Statistical Methods, §4.1.4.1: Linear Least Squares Regression. National Institute of Standards and Technology. https://www.itl.nist.gov/div898/handbook/pmd/section1/pmd141.htm
  3. ^ a b c a. (p. 373) b. (p. 373) c. (p. 304) Dodge, Yadolah (2008). The Concise Encyclopedia of Statistics. Springer. https://doi.org/10.1007/978-0-387-32833-1
Cite this page
Plain text
StatWiki (2026). "Polynomial least squares." StatWiki. Last updated 2 December 2026. https://www.statwiki.io/articles/polynomial-least-squares.html
BibTeX
@misc{statwiki_polynomial_least_squares,
  author = {{StatWiki}},
  title = {{Polynomial least squares}},
  year = {2026},
  url = {https://www.statwiki.io/articles/polynomial-least-squares.html},
  urldate = {2026-12-02},
  note = {StatWiki, last updated 2 December 2026}
}