A least squares regression calculator for paired data: fit a straight line or a quadratic, cubic or quartic curve, and get the equation, the correlation and R², the residual table, a fit plot and a residual plot, and predictions that are labelled interpolation or extrapolation so you always know whether a forecast sits inside the evidence or beyond it. The model is the one you choose, fitted the standard least squares way, with the sums shown for the linear case so every number can be checked by hand.
Pairs may be separated by a comma, a semicolon, a tab or spaces. Up to 200 pairs. A polynomial of degree d needs at least d + 1 points with at least d + 1 different x values; a fit with exactly as many points as parameters passes through every point, and the tool says so rather than letting a perfect R² impress you.
How to use this calculator
- Paste or type your pairs, one per line, x first. The preloaded five points are the worked example below.
- Choose the model: linear for a straight-line trend, quadratic for one bend, cubic for two, quartic for three. The plot is the judge: a good model follows the cloud without chasing every point.
- Add a prediction x if you want one. The answer is labelled INTERPOLATION when x lies inside the range of your data and EXTRAPOLATION when it lies outside it, because the second kind is a bet, not a reading.
- Read all of it: the equation for the model itself, R² for how much of the variation it accounts for, the residual table and plot for where it fails, and the residual standard error for the typical size of a miss.
The method
Least squares
Polynomial models solve the normal equations: the system formed by the power sums of x. Raw power sums become numerically treacherous when x is large (x⁴ terms explode), so the fit is computed in a centred, scaled variable t = (x − x̄) / scale and the coefficients are then converted back to powers of x exactly; the steps report the centre and scale used. That conditioning step is invisible in the answer and essential to its correctness, which is why it is stated here rather than skipped.
Fit quality
R² = 1 − SSE / SST compares the model’s error with the error of simply predicting the mean of y every time. The adjusted R² applies a penalty for each extra parameter, and the residual standard error s = √(SSE / (n − p)) puts the typical miss back in y’s own units. For the linear model the correlation r is reported as well: r = Sxy / √(Sxx Syy), and for a straight line R² is exactly r².
Worked examples
Example 1: the preloaded five points
For (1, 2), (2, 4), (3, 5), (4, 4), (5, 5): the sums are Σx = 15, Σy = 20, Σxy = 66, Σx² = 55, so Sxy = 66 − 60 = 6 and Sxx = 55 − 45 = 10, giving slope 0.6 and intercept 2.2: ŷ = 2.2 + 0.6x, with r = 0.7746, R² = 0.6000 and SSE = 2.4. The prediction at x = 3 is 4.0 and is interpolation; the preloaded prediction at x = 6 is 5.8 and is flagged extrapolation, one step beyond the data.
Example 2: a perfect line
(1, 3), (2, 5), (3, 7), (4, 9) lie exactly on ŷ = 1 + 2x: r = 1, R² = 1, SSE = 0, every residual zero. Real data almost never does this; when a fit claims it, check whether the points were generated from the formula in the first place.
Example 3: when the line is the wrong shape
The points (0, 3), (1, 2), (2, 3), (3, 6), (4, 11) come from y = x² − 2x + 3. A line does its best with ŷ = 1 + 2x and R² = 0.7407, which sounds respectable until the residuals show the pattern: +2, −1, −2, −1, +2, a U shape announcing the bend the line cannot make. The quadratic model recovers ŷ = 3 − 2x + x² exactly, with SSE = 0. The residual plot exists to make that U visible.
Example 4: a quartic that proves nothing
Five points from y = x⁴ − 3x² + x − 5 at x = −2 to 2 are fitted by the quartic model with the coefficients recovered (1, 0, −3, 1, −5) and R² = 1, because five points and five parameters always agree perfectly. The tool flags this case explicitly: with no degrees of freedom left, a perfect fit is arithmetic, not evidence.
Reading your results
R² is a share, not a grade. R² = 0.60 means the model accounts for 60 percent of the variation in y around its mean. Whether that is good depends entirely on the subject: excellent for behaviour, suspicious for a physical law. It also never says the model is the right shape; Example 3’s line scored 0.74 while being wrong.
Residuals should look like weather, not like a pattern. Random scatter around zero is what a well-specified model leaves behind. A curve, a funnel or a run of one sign in the residual plot means structure remains that the model has not captured, and no R² value overrides that evidence.
The prediction label is part of the prediction. Interpolation borrows strength from neighbours on both sides; extrapolation extends a trend into unmeasured territory where the true relationship may bend, flatten or break. The further beyond the data, the more the answer is the model’s opinion rather than the data’s.
Common mistakes
- Reading causation into a fit. Regression measures association in the data you have. Ice cream sales fit drowning deaths well, because both follow summer; the equation is real and the causal reading is false. Establishing cause needs design, not a better curve.
- Choosing the degree by R² alone. R² never falls when parameters are added, so chasing it ends at a curve threading every point and predicting nonsense between them. Use the adjusted R², the residual plot and the exact-fit warning together.
- Extrapolating far and quoting many digits. A prediction one step beyond the range is a stretch; ten steps is fiction. The label is shown for any distance outside the range, and good practice reports the prediction with its label attached.
- Fitting a line because it is the default. If the scatter bends, the line is wrong regardless of its R². Look at the fit plot: the curve should pass through the middle of the cloud everywhere, not just on average.
- Letting one outlier steer. Squared errors give distant points outsized pull. A single wild point can rotate a line noticeably at small n; the residual table identifies it, and the honest responses are to verify the point or report the fit with and without it.
- Confusing r with the slope. The slope is in y-units per x-unit and changes if you rescale; r is unit-free, always between −1 and 1, and for a line R² = r². They answer different questions.
Limitations
- Models are polynomials up to degree 4 plus the straight line. Exponential, logarithmic and power-law relationships are different models with their own pages’ worth of care; fitting a quartic to growth data because it bends is curve-chasing, not modelling.
- Ordinary least squares assumes the x values are the controlled or precisely measured ones and the errors sit in y, with roughly constant spread. Strongly fanning residuals (heteroscedasticity) or errors in x call for weighted or errors-in-variables methods beyond this tool.
- No significance tests or confidence bands are drawn on the fit: with the sums and the residual standard error shown, the descriptive fit is complete, and inferential claims need the assumptions checked first. The related confidence interval calculator covers interval thinking.
- Time order is ignored: for series data, neighbouring residuals are often correlated, and least squares summaries can flatter the fit. The residual table preserves your input order so a drift is at least visible.
Frequently asked questions
What does R² actually tell me?
The share of y’s variation that the model accounts for, relative to just predicting the mean. R² = 0.6 means 60 percent accounted for and 40 percent left in the residuals. It says nothing about whether the model shape is right, whether the relationship is causal, or whether predictions outside the data will hold; the residual plot and the extrapolation label cover those questions.
Does a strong regression mean x causes y?
No. Regression fits association in the data supplied. A confounder (summer driving both ice cream sales and drowning) produces a beautiful fit and a false cause. Causal claims come from experimental design or careful adjustment, never from the fit alone, which is why this page reports the equation and its quality and stops there.
Which model should I choose?
The simplest one whose residuals look like patternless scatter. Start linear; if the fit plot shows the curve missing a bend and the residuals form a U or an arch, step up one degree. Stop as soon as the structure is captured: every extra parameter buys fit on these points at the price of wilder behaviour between and beyond them.
Why is my R² exactly 1?
Either the points were generated from the model (Example 2), or the model has as many parameters as points and could not miss (Example 4). The tool distinguishes the two: the exact-fit case carries a warning, because there a perfect score contains no information about the relationship at all.
What is the difference between r and the slope?
The slope is the fitted rise in y per unit of x, in y’s units. The correlation r is the same relationship standardised: unit-free, bounded by −1 and 1, measuring tightness around the line rather than steepness. Rescaling x changes the slope and leaves r untouched; for a straight line, R² = r².
How far can I extrapolate?
There is no safe distance written in the mathematics; there is only your knowledge of the process. The label tells you that you have left the evidence. Short extrapolations of stable, well-understood trends are routine engineering; long ones, or any extrapolation of a quartic (whose ends race away), are speculation and should be reported as such.
Related calculators
- Math calculators
- Descriptive Statistics Calculator: the means and spreads this fit builds on.
- Z Score and Normal Distribution Calculator: standardising values, residuals included.
- Confidence Interval and Margin of Error Calculator: putting an interval around an estimate.
- Statistical Test Calculator: the inferential step this descriptive fit deliberately leaves to you.
Method: ordinary least squares. Linear coefficients come from the Sxy / Sxx formulas; polynomial coefficients solve the normal equations in a centred, scaled variable t = (x − x̄) / scale for numerical conditioning and are converted back to powers of x. R² = 1 − SSE/SST, adjusted R² penalises each parameter, and the residual standard error uses the n − p degrees of freedom. Fixtures verified against independently computed fits before publication. Last reviewed: 21 October 2026.
Disclaimer: This calculator gives estimates for general information only. It is not financial, medical or other professional advice.
