Polynomial Regression With Matrices
Fitting polynomial models of arbitrary degree to data using the matrix form of the normal equation. Students learn to construct the polynomial design matrix, solve for the coefficient vector via least squares, and produce predictions from the fitted polynomial.
Tutorial
Polynomial Regression and the Design Matrix
In polynomial regression, we model the response as a polynomial of degree in the predictor
Although this model is nonlinear in it is linear in the coefficients So we can write it in the same matrix form as ordinary linear regression, by stacking the powers of each into a design matrix:
The least-squares coefficient vector is then given by the same normal equation:
The only thing that changes when we move from linear to polynomial regression is the design matrix.
Quick illustration. To fit a quadratic to the data the design matrix and response are