Residual Calculator

Enter your X (independent) and Y (observed) data points to calculate linear regression residuals. This Residual Calculator fits a regression line (ŷ = a·x + b), then computes each predicted value, residual (observed − predicted), and the sum of squared residuals (SSR) — giving you a full picture of your model's fit.

Enter your independent variable values separated by commas or new lines.

Enter your dependent (observed) variable values in the same order as X.

Results

Sum of Squared Residuals (SSR)

--

Slope (a)

--

Intercept (b)

--

R² (Coefficient of Determination)

--

Number of Data Points

--

Mean Residual

--

Residuals by Data Point

Results Table

Frequently Asked Questions

What is a residual in linear regression?

A residual is the difference between an observed value (y) and the value predicted by your regression model (ŷ). The formula is: residual = y − ŷ. Positive residuals mean the model underestimated the actual value; negative residuals mean it overestimated.

What is the significance of residuals in regression analysis?

Residuals measure how well your linear regression model fits your data. Small residuals close to zero indicate a good fit. Analyzing the pattern of residuals also helps diagnose whether the assumptions of linear regression (linearity, constant variance, normality) are satisfied.

How is the regression line (ŷ = a·x + b) calculated?

The slope (a) and intercept (b) are estimated using the least squares method, which minimizes the sum of squared residuals. The slope is a = Σ[(xᵢ − x̄)(yᵢ − ȳ)] / Σ[(xᵢ − x̄)²], and the intercept is b = ȳ − a·x̄, where x̄ and ȳ are the means of X and Y respectively.

What is the sum of squared residuals (SSR)?

The sum of squared residuals (SSR) is the total of each residual squared: SSR = Σ(yᵢ − ŷᵢ)². Squaring prevents positive and negative residuals from cancelling each other out. A lower SSR indicates a better-fitting model. It is also used to compute R² and other regression diagnostics.

Why do we use sum of squares residuals rather than just summing residuals?

If you simply summed the raw residuals, positive and negative values would cancel out and always sum to approximately zero — regardless of fit quality. Squaring each residual ensures all values are positive and that larger deviations are penalised more heavily.

What is a residual plot and how do you use it?

A residual plot graphs residuals on the y-axis against X values (or predicted values) on the x-axis. Ideally the points should scatter randomly around zero with no pattern. A curved or fanning pattern suggests the linear model may not be appropriate, or that variance is not constant (heteroscedasticity).

Can every relationship be modelled with linear regression?

No. Linear regression is only appropriate when the relationship between X and Y is approximately linear. Non-linear relationships (e.g. exponential, quadratic) require polynomial or other regression models. Residual plots are a key diagnostic tool — a curved pattern in the residuals signals a non-linear relationship.

What does R² (coefficient of determination) tell me?

R² measures the proportion of variance in Y that is explained by X through the regression model. A value of 1 means the model explains 100% of the variation (perfect fit), while 0 means the model explains none of it. For example, R² = 0.85 means 85% of Y's variability is accounted for by the regression line.

More Statistics Tools