Residual Calculator
Fit a least-squares line to paired data, inspect every residual, and measure the total unexplained squared error.
Paired data
Model: ŷ = intercept + slope × x. Enter 2 – 30 complete (x, y) pairs with at least two distinct x values.
Controls displayed decimals only; calculations and Excel cells retain canonical numeric values.
Live results
Residuals vs. fitted values
Residual detail
| Observation | x | Observed y | Predicted ŷ | Residual e | Residual² |
|---|---|---|---|---|---|
| 1 | 1.0000 | 3.0000 | 3.0000 | 0.0000 | 0.0000 |
| 2 | 2.0000 | 5.0000 | 4.9000 | 0.1000 | 0.0100 |
| 3 | 3.0000 | 7.0000 | 6.8000 | 0.2000 | 0.0400 |
| 4 | 4.0000 | 8.0000 | 8.7000 | -0.7000 | 0.4900 |
| 5 | 5.0000 | 11.0000 | 10.6000 | 0.4000 | 0.1600 |
How to use this residual calculator
What this calculator does
This calculator fits an ordinary least-squares straight line to paired x and y observations, computes the predicted value for every row, and then calculates each residual as observed y minus predicted ŷ. It also adds the squared residuals to produce SSE, the residual sum of squares. The tool is designed for checking point-by-point model error and for seeing whether the remaining errors look random after a linear fit. It does not prove that a linear model is correct, establish causality, or replace a broader regression diagnostic review. NIST describes residual examination as a key part of statistical modeling because residual patterns can reveal structure the fitted model has not captured; see its guidance on checking model residuals.
When to use it
Use the calculator when you want to check homework or hand calculations for simple linear regression, inspect forecast or calibration errors against a fitted line, screen a small experimental dataset for unusually large residuals, or create a residual-versus-fitted plot before deciding whether a straight-line model is adequate. A residual close to zero means that the fitted line predicted that observation closely; a large positive or negative residual marks a point where the prediction missed by more.
How to calculate
- The calculator opens with five demonstration points and a validated example Excel workbook already available. Replace the sample x and y entries row by row. Use Add point for additional observations, up to 30, or the × control beside a row to remove it. At least two complete pairs are required, and x cannot be constant across every row.
- Choose Precision from 2 to 8 decimals. This changes display rounding only. Read Sum of squared residuals (SSE), the Fitted model, the residual table, and – when at least three points are present – the residual plot.
- Select Download Excel to export the current inputs, coefficients, residuals, and notes as a real .xlsx workbook. Reset clears the demonstration data instead of restoring it. After Reset, Excel export is disabled until you enter a complete valid dataset again.
Input guide
x coordinate is the independent-variable value for each observation. It is required for every included row and accepts ordinary decimal notation such as 1, -2.5, or 12.75; scientific notation and decimal-comma input are rejected to avoid ambiguous parsing. x may be negative, zero, or positive, but at least two x values must differ or a slope cannot be identified. Changing x changes the fitted slope, intercept, predicted values, and therefore the residuals. A common mistake is leaving an x value filled while its matching y is blank.
y coordinate is the observed dependent-variable value paired with x. It is also required for every included row and uses the same plain-decimal format. For example, the first demonstration y is 3. Larger or smaller y values alter the fitted line and each observation's error. Do not enter predicted values in this column; y is the measured or observed response.
Precision is a required display control with choices from 2 through 8 decimals; the startup setting is 4 decimals. It affects visible rounding in cards, the chart labels, and the detail table, while the underlying regression and exported numeric cells retain full finite JavaScript precision. Precision therefore changes presentation, not the mathematical fit.
Output guide
Sum of squared residuals (SSE) is the exact sum Σ(y – ŷ)² for the fitted dataset. It cannot be negative. Smaller values mean less squared unexplained error for the same y scale and dataset, although SSE by itself is not scale-free. Fitted model displays ŷ = intercept + slope × x. Observations and the header Points pill show the number of complete pairs used. The header Slope and SSE pills mirror the current fitted slope and residual sum of squares so the same canonical results remain visible while you scan the inputs.
In the Residual detail table, Observation is the row number, x and Observed y reproduce the input pair, Predicted ŷ is the fitted-line estimate, Residual e is observed minus predicted, and Residual² is the nonnegative contribution to SSE. The Residuals vs. fitted values plot uses fitted ŷ on the horizontal axis and residual e on the vertical axis. A random-looking cloud around zero is more consistent with a linear model than a curve, funnel, or other systematic pattern. NIST's least-squares discussion shows that the straight-line coefficients are chosen by minimizing the sum of squared deviations.
Worked example
The startup data are (1, 3), (2, 5), (3, 7), (4, 8), and (5, 11). Their means are x̄ = 3 and ȳ = 6.8. The least-squares slope is 1.9 and the intercept is 1.1, giving the fitted line ŷ = 1.1 + 1.9x. Predicted values are therefore 3.0, 4.9, 6.8, 8.7, and 10.6. The residuals are 0.0, 0.1, 0.2, – 0.7, and 0.4. Squaring and summing them gives 0 + 0.01 + 0.04 + 0.49 + 0.16 = 0.70, so the first-open SSE is 0.7000 at four-decimal precision. The residuals sum to zero apart from floating-point noise, as expected for an OLS model that includes an intercept.
How residuals should be interpreted
A residual's sign tells direction: a positive residual means observed y is above the fitted line, while a negative residual means observed y is below it. Magnitude tells how far the point lies vertically from the line in y units. Squaring residuals removes cancellation and penalizes larger misses more heavily, which is why least squares chooses the line that minimizes SSE. NIST's overview of linear least squares likewise explains that the least-squares method minimizes squared residuals.
Do not judge a model by SSE alone across datasets with different response scales or different numbers of observations. Residual plots add diagnostic information: curvature can suggest a missing nonlinear term, a funnel shape can suggest nonconstant variance, and isolated large residuals can flag unusual observations. Those patterns are reasons to investigate the model or data, not automatic proof that a point should be deleted. The calculator therefore keeps the residual table and the plot tied to the same canonical fitted model so each visual point can be traced back to an exact row.