Fit a polynomial curve of your chosen degree. Higher degrees always fit the sample better but often predict worse, so pick the lowest degree that captures the pattern.
Choosing the degree
- Start with a straight line, then a quadratic, and so on.
- Keep a higher-degree term only if its coefficient is significant and the residual plot improves.
- Prefer adjusted R² over R² when comparing degrees, because R² always rises when you add terms.
- Never use a high-degree polynomial to predict outside the range of your data: the curve can shoot off in either direction.
ŷ = b₀ + b₁x + b₂x² + … + bₖxᵏ
Very high powers of large x values can cause numerical problems. If you get an error, try centring x (subtracting its mean) first.