Polynomial Regression Calculator

Fit polynomials of any degree (1-8) with R², adjusted R², AIC/BIC, coefficient table, residuals, and automatic degree comparison for model selection.

Polynomial Regression Calculator

Comma-separated
Comma-separated
Equation
Y = 0.9057X^3 − 3.5202X^2 + 2.0993X + 4.0808
Degree 3 polynomial with 4 coefficients
0.999896
99.99% of variance explained
Adjusted R²
0.999834
Penalized for 3 predictors
Std. Error
1.1617
In Y-units
AIC
5.41
Akaike Information Criterion (lower = better)
BIC
6.20
Bayesian IC (stricter penalty, lower = better)
Data points
9
5 residual degrees of freedom
Predicted Y(9)
398.1111
Point prediction

Coefficients

TermCoefficientMagnitude
X^30.90572391
X^2-3.52020202
X2.09932660
constant4.08080808

Residuals

XYPredictedResidual|Residual|
0.005.00004.08080.9192
1.002.00003.5657-1.5657
2.001.00001.4444-0.4444
3.004.00003.15150.8485
4.0015.000014.12120.8788
5.0040.000039.78790.2121
6.0085.000085.5859-0.5859
7.00156.0000156.9495-0.9495
8.00260.0000259.31310.6869

Degree Comparison

DegreeAdj. R²AICSelected
10.7268030.68777572.31
20.9819560.97594149.86
30.9998960.9998345.41
40.9999930.999985-16.35
50.9999990.999997-32.67 ← min
Planning notes, formulas, and examples

About the Polynomial Regression Calculator

Polynomial regression is the most flexible single-equation curve fitting method: choose degree 1 (linear), 2 (quadratic), 3 (cubic), or anything up to 8, and the calculator fits the best polynomial to your data. The degree comparison table with AIC/BIC helps you select the optimal polynomial — the simplest one that captures the data's shape.

Enter your data, select a degree, and get the full equation, coefficients, R², adjusted R², standard error, AIC, and BIC. The coefficient magnitude bars show which terms dominate the equation. Residual analysis with visual bars reveals where the model fits well and where it struggles.

The degree comparison table is the key feature: it shows R², adjusted R², and AIC for degrees 1 through the selected degree + 2, highlighting the AIC-optimal choice. This prevents both underfitting (too few terms) and overfitting (too many terms). Use it to compare how the residual pattern and information criteria change as you move up or down in degree.

When This Page Helps

This is the Swiss Army knife of curve fitting. When you don't know the theoretical form of a relationship, polynomial regression explores degrees 1 through 8 and lets the data tell you the right complexity level.

The AIC/BIC degree comparison is what makes This calculator powerful beyond naive curve fitting. It automates the bias-variance tradeoff: too few parameters underfit (high bias), too many overfit (high variance). The table shows exactly where the sweet spot is.

How to Use the Inputs

  1. Enter X and Y values (comma-separated).
  2. Or select a preset for common polynomial patterns.
  3. Choose the polynomial degree (1-8).
  4. Review the equation, coefficients, and R².
  5. Check the degree comparison table — find the AIC-minimizing degree.
  6. If AIC suggests a different degree, adjust and re-fit.
  7. Enter an X value for prediction.
Formula used
Y = aₙXⁿ + aₙ₋₁Xⁿ⁻¹ + ... + a₁X + a₀ (least squares via normal equations). AIC = n·ln(SSRes/n) + 2(p+1). BIC = n·ln(SSRes/n) + ln(n)(p+1).

Example Calculation

Result: Y = 0.7143X³ − 1.7500X² + 0.0357X + 5.0000, R² = 0.9999, Adj. R² = 0.9999

The cubic polynomial captures the data nearly perfectly (R² = 0.9999). The degree comparison table shows AIC is minimized at degree 3, confirming this is the right model complexity.

Tips & Best Practices

  • Start low (degree 1-2) and increase only if residuals show patterns.
  • AIC-optimal degree is usually the right choice — trust it over raw R².
  • BIC tends to prefer simpler models — use it when parsimony matters (e.g., for extrapolation).
  • Centering X (subtracting mean) improves numerical stability for high degrees.
  • If R² at degree d and d+1 are nearly identical, use degree d (Occam's razor).
  • Degrees above 5-6 rarely add genuine insight — they typically fit noise.

Normal Equations for Polynomial Regression

A degree-d polynomial yields a (d+1)×(d+1) system of normal equations involving power sums S₀ through S₂d. The matrix has Vandermonde structure: entry (i,j) is S_{i+j}. This structure can become ill-conditioned (near-singular) when X values span many orders of magnitude. Solutions: center and scale X, use orthogonal polynomials (Legendre, Chebyshev), or use QR decomposition instead of Cramer's rule.

The Bias-Variance Tradeoff

Degree 1 has high bias (underfits curves) but low variance (stable predictions). Degree n-1 has zero bias (passes through every point) but maximum variance (wildly unstable). AIC/BIC formalize this tradeoff: they add a penalty proportional to the number of parameters, favoring simpler models unless additional parameters significantly reduce error.

Polynomial Alternatives

When polynomials struggle: splines (piecewise polynomials with smooth joins) for irregular shapes, Fourier series for periodic data, logarithmic/exponential for specific growth patterns, and kernel regression for nonparametric flexibility. Polynomials are best for smooth, moderately curved data within a limited X range.

Sources & Methodology

Last updated:

Frequently Asked Questions

  • Use the degree comparison table: pick the degree that minimizes AIC (or BIC for a stricter penalty). If adjusted R² stops improving, you've likely found the right degree. Never use degree ≥ n-1 (interpolation captures noise).