Cubic Regression Calculator

Quick answer

The cubic regression calculator fits a third-degree polynomial y = a₃x³ + a₂x² + a₁x + a₀ to paired data by least squares. You get the equation, coefficients with standard errors and p-values, R², adjusted R², residuals, a plot of the curve and a prediction at a chosen x.

Same number of values as x

Optional – leave empty to skip the prediction

Regression equation
y = 0.2758x³ − 3.174x² + 12.45x − 7.479
Scatter plot with the fitted curve
Coefficient a₃ (x³)
0.275758
Coefficient a₂ (x²)
-3.173918
Coefficient a₁ (x)
12.447944
Coefficient a₀ (constant term)
-7.478571
Coefficient of determination (R²)
0.99981
Adjusted R²
0.99967
Residual standard error
0.1558
Overall F-test
F(3, 4) = 7,168.1459, p < 0.0001
Predicted y at the chosen x
48.49286
95% prediction interval for a new y
47.3425 to 49.6432
95% confidence interval for the mean y
47.427 to 49.5587
Interpolation or extrapolation?
x = 9 lies outside the data range (1 to 8) – this is an extrapolation, treat it with caution.
Coefficients with standard errors and t-tests
Term Coefficient Std. error t p-value ────────────────────────────────────────────────────────────── Intercept (a₀) −7.479 0.3839 −19.48 < 0.0001 x (a₁) 12.45 0.3474 35.834 < 0.0001 x² (a₂) −3.174 0.08713 −36.425 < 0.0001 x³ (a₃) 0.2758 0.006393 43.136 < 0.0001
Fitted values and residuals
# x y ŷ (fitted) Residual y − ŷ Standardised ───────────────────────────────────────────────────────── 1 1 2.1 2.071212 0.028788 0.185 2 2 6.8 6.927706 −0.127706 −0.82 3 3 8.9 8.745455 0.154545 0.992 4 4 9.2 9.179004 0.020996 0.135 5 5 9.8 9.8829 −0.0829 −0.532 6 6 12.4 12.511688 −0.111688 −0.717 7 7 18.9 18.719913 0.180087 1.156 8 8 30.1 30.162121 −0.062121 −0.399
Sum of squared residuals (SSE)
0.0971
Number of points
8

A cubic polynomial can bend twice, so it can follow an S-shaped trend or a curve that levels off and then rises again – growth that slows and speeds up, dose–response curves, the output of a sensor across its range or a cost curve with economies and then diseconomies of scale. Cubic regression chooses the four coefficients a₀ to a₃ that minimise the sum of squared vertical distances between the curve and your points.

Setting a₃ = 0 turns the model into quadratic regression, and setting a₂ = a₃ = 0 gives a straight line, so the cubic is a natural next step when a lower-degree fit leaves a pattern in the residuals. The coefficient table tells you whether the x³ term is statistically supported; adjusted R² tells you whether the extra flexibility is worth the extra parameter.

A cubic needs at least four distinct x values. With exactly four points it passes through all of them and you learn nothing about the fit, so aim for considerably more points than coefficients.

How to use the Cubic Regression Calculator

  1. x values
  2. y values — Same number of values as x
  3. Predict y at x = — Optional – leave empty to skip the prediction
  4. Precision (significant figures)

Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.

How it works

The tool forms the normal equations from the columns 1, x, x² and x³ (with x centred and scaled to avoid round-off), solves them by Gauss–Jordan elimination, converts the coefficients back to powers of x and computes residuals, R², the residual standard error and the coefficient standard errors with n − 4 degrees of freedom.

Worked example

Eight readings x = 1…8 with y = 2.1, 6.8, 8.9, 9.2, 9.8, 12.4, 18.9, 30.1 rise, level off and climb again. The least-squares cubic is y = 0.2758x³ − 3.174x² + 12.45x − 7.479 with R² = 0.99981 and residual standard error 0.156. All four coefficients have p-values below 0.0001, so the cubic term is clearly needed. The inflection point is at x = 3.174 ÷ (3 × 0.2758) ≈ 3.84. At x = 9 the curve predicts 48.49 (95% prediction interval 47.34 to 49.64), an extrapolation one step beyond the data.

Choosing the degree

Degree Name Turning points Minimum points
1 Linear 0 2
2 Quadratic 1 3
3 Cubic 2 4
4 Quartic 3 5
5 Quintic 4 6

Formula

Minimise Σ(y − a₀ − a₁x − a₂x² − a₃x³)² · β = (XᵀX)⁻¹Xᵀy with columns 1, x, x², x³

Worked example

Inputs — x values: 1, 2, 3, 4, 5, 6, 7, 8; y values: 2.1, 6.8, 8.9, 9.2, 9.8, 12.4, 18.9, 30.1; Predict y at x =: 9; Precision (significant figures): 4.
Results — Regression equation = y = 0.2758x³ − 3.174x² + 12.45x − 7.479; Coefficient a₃ (x³) = 0.275758; Coefficient a₂ (x²) = -3.173918; Coefficient a₁ (x) = 12.447944; Coefficient a₀ (constant term) = -7.478571; Coefficient of determination (R²) = 0.99981.

Key terms

Cubic polynomial
A polynomial of degree three, a₃x³ + a₂x² + a₁x + a₀.
Inflection point
Where the curve changes from bending up to bending down, at x = −a₂ ÷ (3a₃).
Normal equations
The linear system (XᵀX)β = Xᵀy whose solution is the least-squares estimate.
Degrees of freedom
n minus the number of coefficients, here n − 4.

Frequently asked questions

How many points are needed for cubic regression?

At least four distinct x values. Four points give an exact fit; use eight or more to judge how well a cubic describes the data.

How do I calculate a cubic regression?

Build the matrix X with columns 1, x, x², x³, then solve (XᵀX)β = Xᵀy. The calculator does this for you and shows every coefficient.

Is a higher R² always better?

No – R² never falls when you add terms. Compare adjusted R², which can drop when a term does not help.

What shape can a cubic follow?

Up to two turning points and one inflection point, e.g. rise–plateau–rise or an S-curve.

How can I tell if the cubic term is needed?

Look at the p-value of a₃. If it is large (say above 0.05) a quadratic is probably enough.

Can I extrapolate with a cubic?

Rarely safely – the x³ term dominates outside the data and sends predictions off sharply.

Why are my coefficients huge with years as x?

Powers of large numbers like 2024 are enormous, so the coefficients become tiny or huge. Subtract a base year (use 0, 1, 2…) for readable coefficients; predictions are unchanged.

Sources

  1. Penn State STAT 462 – Applied Regression Analysis
  2. NIST/SEMATECH e-Handbook of Statistical Methods
  3. Wolfram MathWorld – Probability and statistics

Cite this calculator

Speedy Calculator. (2026). Cubic Regression Calculator. Speedy Calculator. https://speedycalculator.com/calculators/statistics/cubic-regression/