Residual Calculator - Observed vs Predicted
This residual calculator shows the gap between an observed y and the value predicted by your regression line. Enter the slope, intercept, and the point you are checking to get the residual and its square.
Residual Calculator
Results
What Is a Residual Calculator?
A residual calculator finds the residual, which is the difference between an observed value and the value a regression model predicts for the same input. In statistics, the residual for a point is e = y − ŷ, where y is what you measured and ŷ (y-hat) is what the fitted line estimates. This residual calculator handles that subtraction for any straight-line model so you can judge how well the line describes each data point.
- • Check a single regression point: Enter the slope, intercept, and one (x, y) observation to see how far it sits from its predicted value.
- • Compare model fit across points: Run each observation through the tool to rank which points the line fits poorly.
- • Build a residual plot by hand: Use the residuals this calculator returns as the vertical axis when you sketch a residual plot.
- • Teach or verify homework: Students can confirm their hand-computed residuals against a quick, transparent calculation.
The residual is not an error in the sense of a mistake. It is the leftover variation after the model has done its best to explain y from x. A small residual means the line passes close to the point; a large one means the model misses that observation.
Residuals sit at the heart of regression diagnostics. The total of their squares, the residual sum of squares, is what least-squares fitting minimizes when it draws the line. The Variance Calculator and Standard Deviation Calculator build on the same idea of measuring spread around a center.
How the Residual Calculator Works
The calculator applies the residual formula in two steps. First it builds the predicted value from your line, then it subtracts that prediction from the observed value.
- a (intercept): The predicted y when x is zero; taken directly from your fitted line.
- b (slope): The rate of change of predicted y per one unit of x.
- x (observed): The horizontal coordinate of the point being checked.
- y (observed): The actual measured value for that x.
- e (residual): The signed gap y minus ŷ; positive means underpredicted, negative means overpredicted.
With the line y = 5 + 2x and the point (4, 15), the predicted value is 5 + 2·4 = 13. The residual is 15 − 13 = 2, so the observation sits two units above the line. Squaring that gives 4, and because 2 is 13.33% of the observed 15, the relative residual is about 13.33%.
This single-point view is the building block of full regression diagnostics. When you repeat it for every observation, the squared residuals add up to the residual sum of squares that the Least Squares Regression Calculator minimizes when it fits the line.
Worked example: line y = 5 + 2x at point (4, 15)
slope b = 2, intercept a = 5, observed x = 4, observed y = 15
ŷ = 5 + 2·4 = 13; residual = 15 − 13 = 2; squared = 4; relative = (2 / 15)·100 = 13.3333%
Predicted y = 13, residual = 2, squared residual = 4, relative residual = 13.33%
The point lies above the fitted line by 2 units, so the model slightly underpredicted it.
Worked example: perfect fit point (5, 15) on y = 3x
slope b = 3, intercept a = 0, observed x = 5, observed y = 15
ŷ = 0 + 3·5 = 15; residual = 15 − 15 = 0
Predicted y = 15, residual = 0, squared residual = 0, relative residual = 0%
The point sits exactly on the line, so its residual is zero.
According to Wikipedia: Errors and residuals, a residual is the difference between an observed value and the value predicted by a model: e_i = y_i − y_hat_i
When you repeat it for every observation, the squared residuals add up to the residual sum of squares that the Least Squares Regression Calculator minimizes when it fits the line.
Key Concepts Explained
Four ideas make residual output useful rather than just a number. Each one changes how you read a residual once you have it.
Observed vs predicted
The observed value y is the real measurement; the predicted value ŷ comes from plugging x into your fitted line. The residual is the distance between them.
Sign of the residual
A positive residual means the model underpredicted (the point is above the line). A negative residual means it overpredicted (the point is below the line). Zero means a perfect fit for that point.
Squared residual
Squaring the residual removes the sign and punishes large misses more than small ones. Summed across all points, these squares form the residual sum of squares.
Relative residual
Dividing the absolute residual by the observed value gives a scale-free percentage, useful when comparing fits across data with very different magnitudes.
The sign of the residual is the quickest diagnostic. A cluster of all-positive residuals on one side of the x range suggests the line is bending away from the data and a curved model might fit better.
Relative residuals matter when your y values span orders of magnitude. A raw residual of 2 is trivial next to a y of 200 but large next to a y of 3, which is exactly what the percentage view captures.
How to Use This Calculator
Follow these steps to turn a fitted regression line and one observation into a clear residual.
- 1 Enter the slope: Type the slope b of your regression line into the first field. If you have not fit a line yet, the Linear Regression Calculator can produce one from your data.
- 2 Enter the intercept: Type the intercept a, the predicted y when x is zero.
- 3 Enter the observed x: Put the x coordinate of the point you want to check in the observed x field.
- 4 Enter the observed y: Put the measured y value for that x in the observed y field.
- 5 Read the outputs: The tool shows the predicted y, the raw residual, the squared residual, and the relative residual as a percentage.
- 6 Repeat for other points: Run each observation through to build the set of residuals you need for a residual plot or sum-of-squares check.
Suppose your line is y = 1.5 + 0.8x and you measured (10, 12). Predicted y = 1.5 + 0.8·10 = 9.5, so the residual is 12 − 9.5 = 2.5, meaning the model underpredicted this point by 2.5 units.
If you have not fit a line yet, the Linear Regression Calculator can produce one from your data.
Benefits of Using This Calculator
A dedicated residual tool pays off whenever you need to judge a model honestly rather than trusting a single fit statistic.
- • Spot poor-fitting points: Large residuals flag the observations a line fails to explain, which often point to outliers or recording errors.
- • Support residual plots: The residuals returned here are exactly what you plot against x to check for patterns the line cannot capture.
- • Verify your own arithmetic: Students and analysts can confirm hand work on the spot and see the squared and relative forms at once.
- • Compare models on the same data: Feeding two candidate lines through the same points lets you compare their residual sums of squares directly.
- • Scale-free comparison: The relative residual percentage lets you compare misfit across variables measured on different scales.
Residual plots are the standard first check after any regression, because a good model leaves residuals that look like random scatter with no curve or fan shape. The Outlier Calculator and Z-Score Calculator help you decide whether an extreme residual reflects a genuine unusual point or just expected variation.
Because residuals are signed, they also keep you honest about direction: the model is not just 'off,' it is systematically high or low for that observation, which guides the next modeling choice.
Factors That Affect Your Results
The residual you get depends on inputs you control and on limits built into the straight-line model itself.
Quality of the fitted line
Residuals are only as meaningful as the slope and intercept you enter. A line fit to the wrong variables produces residuals that measure the wrong gap.
Scale of y
Raw residuals grow with the size of y, so the relative residual percentage matters when comparing across datasets of different magnitude.
Number of points checked
A single residual says nothing about overall fit; you need the set of all residuals to compute the residual sum of squares or judge a plot.
Linearity assumption
This tool assumes a straight line. If the true relationship curves, residuals will show a pattern the line cannot remove.
- • The calculator evaluates one point at a time; it does not itself sum residuals into the residual sum of squares or compute the residual standard error.
- • When the observed y is zero, the relative residual percentage is undefined, and the tool returns it as not applicable rather than a misleading number.
Residuals are most informative in aggregate. The residual sum of squares, written RSS = Σ(yᵢ − ŷᵢ)², summarizes total misfit, and dividing it by its degrees of freedom leads to the residual standard error used in inference.
Remember that residuals measure fit to the chosen line, not truth. A small residual can still come from a model that is wrong for the wrong reason, so always pair residuals with a scatterplot of the raw data.
According to NIST/SEMATECH e-Handbook of Statistical Methods, residuals, the differences between observed and fitted values, are examined to assess how well a model fits the data
The Statistics Calculator summarizes total misfit and supports the broader descriptive statistics that sit behind residual analysis.
Frequently Asked Questions
Q: What is a residual in statistics?
A: A residual is the difference between an observed value and the value a regression model predicts for the same input. It is written e = y − ŷ, where y is the measured value and ŷ is the predicted value from the fitted line.
Q: How do you calculate a residual?
A: Plug your x into the fitted line to get the predicted ŷ, then subtract: residual = observed y − predicted ŷ. For example, with line y = 5 + 2x and point (4, 15), predicted y is 13, so the residual is 15 − 13 = 2.
Q: What does a positive or negative residual mean?
A: A positive residual means the model underpredicted the observation, so the point sits above the line. A negative residual means the model overpredicted, so the point sits below the line. A zero residual means the point lies exactly on the line.
Q: What is the residual sum of squares (RSS)?
A: The residual sum of squares is the sum of every squared residual across all data points: RSS = Σ(yᵢ − ŷᵢ)². Least-squares regression fits the line that makes this total as small as possible.
Q: How do you interpret a residual plot?
A: A residual plot places residuals on the vertical axis against x (or predicted y) on the horizontal axis. Good models show formless scatter; a curve or funnel shape signals that a straight line is missing part of the relationship.
Q: Can a residual be negative?
A: Yes. A negative residual is normal and simply means the model predicted a higher value than what was observed. Residuals can be positive, negative, or zero depending on where each point falls relative to the line.