# Cubic Regression Calculator

URL: https://speedycalculator.com/calculators/statistics/cubic-regression/
Last updated: 2026-10-30

> 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.

## Inputs

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

## Results

- Regression equation
- Scatter plot with the fitted curve
- Coefficient a₃ (x³)
- Coefficient a₂ (x²)
- Coefficient a₁ (x)
- Coefficient a₀ (constant term)
- Coefficient of determination (R²)
- Adjusted R²
- Residual standard error
- Overall F-test
- Predicted y at the chosen x
- 95% prediction interval for a new y
- 95% confidence interval for the mean y
- Interpolation or extrapolation?
- Coefficients with standard errors and t-tests
- Fitted values and residuals
- Sum of squared residuals (SSE)
- Number of points

## Formula

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

## Explanation

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

- **x values**
- **y values** — Same number of values as x
- **Predict y at x =** — Optional – leave empty to skip the prediction
- **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

DegreeNameTurning pointsMinimum points1Linear022Quadratic133Cubic244Quartic355Quintic46

## 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.

## FAQ

**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

- [Penn State STAT 462 – Applied Regression Analysis](https://online.stat.psu.edu/stat462/)
- [NIST/SEMATECH e-Handbook of Statistical Methods](https://www.itl.nist.gov/div898/handbook/)
- [Wolfram MathWorld – Probability and statistics](https://mathworld.wolfram.com/topics/ProbabilityandStatistics.html)
