Nonlinear regression with polynomials
We will now consider the use of a polynomial to model a nonlinear relationship between a single explanatory variable, X, and the response, Y.
For models of this type, we are interested in using the lowest possible degree of polynomial, but it makes no sense to have any power of x without all lower powers.
The only meaningful order of adding variables is by increasing powers of x.
It is possible to decide on the lowest order polynomial that fits the data from the resulting single anova table — the best degree of polynomial corresponds to the highest-order term that is significantly different from zero. (A p-value less than 0.05 is often used.)
Warning
A polynomial of degree 4 or higher might be found to fit the data best, but you will often find that it behaves in unreasonable ways outside the range of data that were collected. High-degree polynomials should never be used for extrapolation.
Some other form of nonlinear function should always be considered before using high-order polynomials.
For example, consider a nonlinear transformation of either X or Y.
Onion yield
The data below arose from an experiment in Purnong Landing, South Australia involving production of white Spanish onions. The explanatory variable is the areal density of planting (plants per square metre) and the response is onion yield (grams per plant).
A polynomial of degree 6 has been fitted to the data and is shown on the scatterplot in dark blue.
The terms of degree 6, 5 and 4 have high p-values, so we would conclude that a cubic polynomial (of degree 3) is adequate to model the data. Drag the red arrow up to display the cubic curve.
The display also shows the model with a polynomial whose degree is one lower. The distances between these two curves at the data points is the difference between the fitted values and are shown in red. (They are only clearly visible when the power is low.) The sum of squares of these red distances is the sequential sum of squares for the highest-order term.
Observe that when the power of the polynomial is increased to 5 or 6, the curve remains fairly smooth over the range of densities used in the experiment, but fluctuates wildly at extreme densities and should not be used for extrapolation.
Traffic fatal crashes in New Zealand
The next data set gives the number of fatal vehicle crashes in New Zealand per 100,000 population between 1970 and 2005.
In this example, the term with power 6 is highly significant (p-value is approx 0). Polynomials of such high degree should be avoided and different methods should be used for such time series data.