Definition of Cubic Regression
In general, regression is a statistical technique that lets us model the relationship between two variables by finding a curve that best fits the observed samples. When that curve is a polynomial, we deal with polynomial regression. In the cubic regression model we use cubic functions — polynomials of degree 3 — to describe how the independent variable x affects the dependent variable y. The idea is the same as in linear regression (fitting a straight line) or quadratic regression (fitting a parabola), only here we fit a curve that can have one hump and one dip.
The Formula for Cubic Regression
Consider a set of data points (x₁, y₁), …, (xₙ, yₙ). The cubic regression function takes the form:
y = a + bx + cx² + dx³
where a, b, c, d are real numbers called the coefficients of the cubic regression model. Two special cases are worth noting:
- If d = 0, we obtain quadratic regression.
- If c = d = 0, we get a simple linear regression model.
To determine the four coefficients we use the least-squares method: we look for the values of a, b, c, d that minimise the squared distance between each data point (xᵢ, yᵢ) and the corresponding point predicted by the model (xᵢ, a + bxᵢ + cxᵢ² + dxᵢ³).
How to Use This Cubic Regression Calculator
- Input your sample — up to 30 points, one (x, y) pair per line, separated by a comma, space, or semicolon. Remember that at least 4 points are required to fit the cubic model!
- Choose a measurement system — dimensionless, metric (SI), US customary, or a world currency (USD, RUB, EUR, and more) to label the y-axis.
- Click Calculate to instantly get the cubic regression equation y = a + bx + cx² + dx³, the R² value, the inflection point, and a full predicted-vs-actual table.
- Use the Share button to send results to colleagues, or Print for a clean report.
How to Find Cubic Regression by Hand
We use the projection (normal-equation) approach. Build the model matrix X with four columns and n rows — a column of ones, a column of the x-values, a column of their squares, and a column of their cubes — and let y be the column vector of the response values. The coefficient vector β = [a, b, c, d] is then found from the normal equation:
β = (XᵀX)⁻¹ Xᵀy
In practice this is equivalent to solving the following 4×4 system of normal equations:
- n·a + (Σx)·b + (Σx²)·c + (Σx³)·d = Σy
- (Σx)·a + (Σx²)·b + (Σx³)·c + (Σx⁴)·d = Σxy
- (Σx²)·a + (Σx³)·b + (Σx⁴)·c + (Σx⁵)·d = Σx²y
- (Σx³)·a + (Σx⁴)·b + (Σx⁵)·c + (Σx⁶)·d = Σx³y
This calculator solves the system using Gaussian elimination with partial pivoting for numerical stability. ⚠️ For some peculiar datasets the inverse of XᵀX may not exist (the system is singular). If this happens, the cubic polynomial cannot be fitted — make sure you have at least 4 distinct x-values.
Coefficient of Determination R²
After finding the coefficients, model quality is measured with R²:
R² = 1 − SSres / SStot
where SStot = Σ(yᵢ − ȳ)² and SSres = Σ(yᵢ − ŷᵢ)². R² ranges from 0 to 1: the closer to 1, the better the cubic curve fits your data.
Cubic Regression Example
Suppose you have the following data points:
| x | y |
|---|---|
| 1 | 2 |
| 2 | 9 |
| 3 | 28 |
| 4 | 65 |
| 5 | 126 |
| 6 | 217 |
After solving the normal equations you get y = 1 + 0x + 0x² + 1x³ (that is, y = x³ + 1), with R² = 100% — a perfect fit. Because the leading coefficient d is positive, the cubic rises to the right, and its inflection point is at x = 0.
FAQs
How many points do I need for cubic regression?
At least 4 points with distinct x-values. More points give a more reliable, less over-fitted model.
What is the difference between cubic and quadratic regression?
Quadratic regression fits a parabola (y = a + bx + cx²) with a single turning point. Cubic regression adds the dx³ term, allowing an S-shaped curve with up to two turning points and one inflection point — a better fit for data that rises, dips, and rises again (or vice versa).
Can R² be negative?
A properly fitted least-squares model gives R² between 0 and 1. This calculator clamps values to that range; a value near 0 simply means the cubic model explains almost none of the variation in your data.
When should I use cubic regression?
- Your scatter plot shows an S-shape or a curve with a hump and a dip.
- A linear or quadratic model leaves large, systematic residuals.
- You're modelling growth curves, dose-response relationships, or physical processes with an inflection point.
For straight-line data use linear regression; for a single parabola use quadratic regression; for higher-degree polynomials, a dedicated polynomial regression tool is recommended.