standarddeviationcalculator.net SD Calculator

Polynomial regression calculator

Share this page

Favorites

    No favorites yet. Press Favorite on any page to keep it here.

    Methodology

    Fit a polynomial curve of your chosen degree to paired data. The calculator gives the equation, R² and adjusted R², draws the curve, and fits every other degree too so you can pick the right one.

    Paired data
    xyRemove

    Regression equation ŷ = 0.096232x³ − 1.5371x² + 6.697x + 2.3933
    Predicted ŷ at x = 5.58.74125
    R²0.97809
    Adjusted R²0.96714
    Residual std. error0.33658
    F (3, 6)89.286
    p-value of F< 0.0001
    Data points (n)10
    12345678910789101112 x = 5.5 x y

    ━ Data   ━ ŷ = 0.096232x³ − 1.5371x² + 6.697x + 2.3933

    Least-squares coefficients
    TermCoefficient
    a (x³)0.096231546
    b (x²)−1.5370629
    c (x)6.6970085
    d (Constant)2.3933333
    Fitted values and residuals
    xyŷResidual y − ŷ
    17.87.649510.15049
    21010.409−0.40895
    311.511.2490.25096
    410.910.74720.15282
    59.29.48075−0.28075
    68.48.027130.37287
    76.76.96373−0.26373
    86.76.86793−0.16793
    98.68.317110.28289
    1011.811.8887−0.088671
    Every degree the data allows. The highest adjusted R² is at degree 3
    DegreeR²Adjusted R²Residual std. error
    10.012252-0.111221.9572
    20.056099-0.213592.0453
    30.978090.967140.33658
    40.978250.960860.36733
    50.98440.964910.34779
    60.984450.953360.40097
    Show the working, step by step
    1. Set up the model ŷ = ax³ + bx² + cx + d and the design matrix with columns 1, x, x², x³ for the 10 points.

    2. Solve the least-squares problem (minimise Σ(y − ŷ)²). The calculator centres and scales x first and uses a QR decomposition, which gives the same answer as the normal equations with far less rounding error.

      ŷ = 0.096232x³ − 1.5371x² + 6.697x + 2.3933

    3. Split the variation in y.

      SST = Σ(y − ȳ)² = 31.024 SSE = Σ(y − ŷ)² = 0.679711 SSR = SST − SSE = 30.3443

    4. Coefficient of determination and its adjusted form.

      R² = 1 − SSE ÷ SST = 1 − 0.679711 ÷ 31.024 = 0.978091 adjusted R² = 1 − (1 − R²)(n − 1) ÷ (n − 3 − 1) = 1 − 0.0219092 × 9 ÷ 6 = 0.967136

    5. Overall F-test of H₀. Every non-constant coefficient is zero.

      F = (SSR ÷ 3) ÷ (SSE ÷ 6) = 89.286, p < 0.0001

    6. Prediction at x = 5.5: substitute into the equation.

      ŷ(5.5) = 8.74125

    A very close fit: the curve explains 97.81% of the variation in y. Adding degrees always raises R². Compare adjusted R² when choosing the degree.

    Polynomial regression: the model

    ŷ = b₀ + b₁x + b₂x² + … + b_d x^d R² = 1 − SSE ÷ SST, adjusted R² = 1 − (1 − R²)(n − 1) ÷ (n − d − 1)

    The d + 1 coefficients minimise the sum of squared residuals Σ(y − ŷ)². A degree-d fit needs at least d + 2 points and d + 1 distinct x values. The calculator centres and scales x, solves by QR decomposition, and converts the result back to powers of the original x. That keeps the answer accurate at degree 6, where the textbook normal equations lose most of their digits.

    Polynomial regression: a worked example

    The default data are ten readings at x = 1 to 10. y = 7.8, 10, 11.5, 10.9, 9.2, 8.4, 6.7, 6.7, 8.6, 11.8. The values rise, fall and rise again. Fitting each degree gives:

    DegreeR²Adjusted R²Residual SE
    10.0123−0.11121.957
    20.0561−0.21362.045
    30.97810.96710.337
    40.97830.96090.367
    50.98440.96490.348
    60.98450.95340.401

    R² climbs at every step, but adjusted R² peaks at degree 3 and the residual standard error is smallest there. The degrees above 3 buy almost nothing and pay for it in degrees of freedom. The cubic is

    ŷ = 0.096232x³ − 1.5371x² + 6.697x + 2.3933

    with R² = 0.97809, adjusted R² = 0.96714 and F(3, 6) = 89.29 (p below 0.0001). The default prediction at x = 5.5 is ŷ = 8.74.

    How to interpret the output

    The overall F-test asks whether the polynomial explains more than a flat line at ȳ. It does not say the degree is right. Use the comparison table for that. The coefficients of a high-degree polynomial are hard to interpret one at a time, because x, x², x³ and so on are strongly correlated. Treat the curve as a whole and use it for fitted values and predictions inside the data range. The residual table shows where the curve misses. A run of residuals with the same sign means the degree is too low.

    Entering your data

    Type or paste one (x, y) pair per row. Use Add row for more rows. Rows with a blank or non-numeric cell are skipped, and the calculator tells you how many. Repeated x values are fine and common in experiments, but you need at least d + 1 different x values for a degree-d fit. Change the degree with the menu and the equation, chart and statistics update, while the comparison table stays the same.

    Common mistakes

    • Choosing the degree with the highest R². That is always the highest degree. Use adjusted R², a hold-out set or the residuals.
    • Extrapolating a high-degree fit. Beyond the data, a degree-5 or 6 polynomial can shoot off in any direction.
    • Fitting as many coefficients as points. With n points and degree n − 1 the curve is exact and tells you nothing about the pattern.
    • Rounding coefficients. Small high-power coefficients multiply large numbers. Round only the final predictions.
    Polynomial regression calculator: the worked example on this page, with its result and chart
    Polynomial regression calculator: the worked example above, at a glance.

    Common questions

    How do I choose the degree?

    Start low and go up only while adjusted R² improves clearly and the residual plot loses its pattern. The table under the result fits every degree the data allow, so you can see where the gain stops. In the default data, adjusted R² jumps from −0.21 at degree 2 to 0.967 at degree 3, then drifts down. Degree 3 is the choice.

    Why does R² keep going up with the degree?

    Each extra term gives the curve one more way to bend towards the points, and least squares will never make the fit worse by using it. With n points a polynomial of degree n − 1 passes through all of them and R² = 1, even for pure noise. That is overfitting, and adjusted R² is there to catch it.

    Can adjusted R² be negative?

    Yes. It is negative when the model explains less than it costs in degrees of freedom. Here the straight line gives R² = 0.012 and adjusted R² = −0.111, which says a line tells you nothing about these data.

    Is polynomial regression linear or non-linear regression?

    Linear. The curve is non-linear in x, but the model is linear in its coefficients, so ordinary least squares solves it exactly with no iteration. Non-linear regression means models like y = a·e^(bx), where a coefficient sits inside a non-linear function.

    Why stop at degree 6?

    Above degree 5 or 6 polynomials swing wildly between and beyond the data points (Runge's phenomenon), and the coefficients become very sensitive to small changes in the data. For more flexible shapes a spline or a transformation of x is usually a better tool.