Residual Plot Generator
Enter your X (predictor) and Y (response) values below. The tool fits a simple linear regression automatically and computes all residual diagnostics.
Each dataset below illustrates a different residual pattern — from ideal random scatter to classic non-linearity and heteroscedasticity. Click any dataset to load it.
Residual Plot Pattern Library
Six common residual patterns explained — click any card to load that dataset
What Is a Residual Plot?
A residual plot is a scatter plot where each point represents one observation, with the residual (the difference between the observed value and the fitted value from a regression model) on the vertical axis and the fitted value or an independent variable on the horizontal axis. Residual plots are the standard method for checking whether a linear regression model fits the data well and whether the core assumptions of the model hold.
A residual tells you how far off a prediction was for a single observation. If the model were perfect, every residual would be zero. In reality, residuals scatter around zero, and the pattern of that scatter reveals whether the model is adequate. Random, structureless scatter suggests a good fit. Any detectable pattern — a curve, a funnel, clustering — indicates a problem that should be addressed before drawing conclusions from the regression.
The Residual Formula
| Term | Symbol | Definition | Meaning |
|---|---|---|---|
| Observed value | yᵢ | The actual measured outcome for observation i | What you recorded |
| Fitted value | ŷᵢ | β₀ + β₁xᵢ — the value predicted by the regression line | What the model predicted |
| Residual | eᵢ | yᵢ − ŷᵢ | The error for observation i |
| Standardized residual | eᵢ / s | Residual divided by the standard deviation of residuals | How many standard deviations from zero |
| RMSE | √(Σeᵢ²/(n−2)) | Root mean squared error | Typical prediction error in original units |
The Four Assumptions Residual Plots Check
Linear regression rests on four core assumptions. Residual plots test all four. No single number (not even R²) can tell you whether these assumptions hold — only visual inspection of the residuals reveals whether your model is reliable.
How to Read a Residual vs Fitted Plot
The residual vs fitted plot is the most informative of all regression diagnostic charts. On the horizontal axis sits each observation's fitted (predicted) value. On the vertical axis sits that observation's residual. A horizontal reference line at zero divides positive residuals (actual > predicted) from negative ones (actual < predicted).
| What you see | What it means | Model problem | What to do |
|---|---|---|---|
| Random cloud around zero | No pattern, constant spread | None — model fits well | Proceed with confidence |
| U-shape or arch | Curve in the residuals | Non-linearity | Add polynomial term; try log(X) |
| Funnel (wider right) | Variance grows with ŷ | Heteroscedasticity | Log-transform Y; use WLS |
| Funnel (wider left) | Variance shrinks with ŷ | Heteroscedasticity | Square-root transform |
| Points far from zero | Large residuals | Outliers present | Investigate; consider robust regression |
| Alternating pos/neg clusters | Groups in data | Omitted variable | Add a categorical predictor |
The Q-Q Plot: Checking Normality of Residuals
A normal quantile-quantile (Q-Q) plot compares the distribution of your residuals to a theoretical normal distribution. The residuals are sorted from smallest to largest, then plotted against the quantiles of a standard normal distribution. If residuals are normally distributed, all points fall close to the 45-degree reference line.
Points curving away from the line at both ends (an S-curve) indicate heavy tails — the residuals have more extreme values than a normal distribution would predict. Points bending upward at the right end suggest right skewness. For inference (p-values and confidence intervals) to be valid with small samples, residual normality matters. With large samples (n > 30), the central limit theorem makes regression inference more robust to non-normality.
What Is Heteroscedasticity?
Heteroscedasticity means that the variance of the residuals is not constant across all levels of the predictor variable. The term comes from Greek: hetero (different) and skedastikos (able to scatter). The opposite condition — equal variance — is called homoscedasticity, which is what a valid linear regression requires.
A typical example: predicting household spending from income. Low-income households have similar, predictable spending. High-income households vary widely in how much they spend. A regression on this data will show residuals spreading out as fitted values increase, producing the characteristic funnel pattern. The regression coefficient estimates remain unbiased under heteroscedasticity, but the standard errors are wrong — making t-tests and F-tests unreliable.
Detecting Outliers with Standardized Residuals
A standardized residual divides each residual by an estimate of its standard deviation. This puts all residuals on a common scale regardless of the original units of Y. Under the assumption of normally distributed errors, roughly 95% of standardized residuals should fall between −2 and +2, and 99.7% between −3 and +3.
Any observation with a standardized residual beyond ±2 deserves investigation. Points beyond ±3 are strong outlier candidates. An outlier in Y (a large residual) does not always mean the observation is wrong — it might represent a genuinely unusual case, a data entry error, or evidence that the model is missing an important predictor. Context matters.
The RESIDUAL Framework for Regression Diagnostics
A systematic approach to regression diagnostics helps ensure no assumption goes unchecked. This eight-step framework covers the full cycle from fitting to interpretation:
Worked Examples: Residual Plots Across Domains
Below are six real-world datasets, each illustrating a distinct residual pattern. Load any of them in the generator above to see the diagnostic plots and interpretation.
Residuals vs Error: An Important Distinction
In regression theory, the error (εᵢ) is the true, unobservable discrepancy between an observation and the population regression line. The residual (eᵢ) is the observable estimate of that error, computed from the fitted regression line in your sample. Residuals sum to zero by the mathematics of ordinary least squares (when an intercept is included), while theoretical errors need not.
This distinction matters when interpreting diagnostic plots: we examine residuals as proxies for errors. They carry information about the errors but are not identical to them. The residuals are slightly correlated with one another (they sum to zero), which is why some diagnostics use studentized residuals rather than raw or standardized ones for more precise outlier detection.
Entity and Formula Glossary
| Term | Symbol / Formula | Definition |
|---|---|---|
| Residual | eᵢ = yᵢ − ŷᵢ | Observed minus fitted value for observation i |
| Observed value | yᵢ | The actual recorded outcome |
| Predicted (fitted) value | ŷᵢ = β₀ + β₁xᵢ | Value estimated by the regression equation |
| Standardized residual | eᵢ / s√(1−hᵢᵢ) | Residual scaled by its standard deviation; flags outliers beyond ±2 |
| Studentized residual | eᵢ / s₍ᵢ₎√(1−hᵢᵢ) | Like standardized, but uses leave-one-out estimate of σ; more sensitive for outlier detection |
| Homoscedasticity | Var(εᵢ) = σ² | Equal error variance at all levels of X — a core regression assumption |
| Heteroscedasticity | Var(εᵢ) ≠ constant | Unequal error variance; shown as funnel pattern in residual plots |
| Regression line | ŷ = β₀ + β₁x | The least squares line minimizing Σeᵢ² |
| Leverage | hᵢᵢ (hat matrix diagonal) | Measures how far xᵢ is from the mean of X; high leverage can distort the regression line |
| Cook's Distance | Dᵢ = eᵢ² · hᵢᵢ / (p·s²(1−hᵢᵢ)²) | Combines residual size and leverage; values > 0.5 indicate influential observations |
| Mean Squared Error | MSE = Σeᵢ² / (n−p) | Average squared residual; estimates σ² |
| RMSE | √MSE | Typical prediction error in the original units of Y |
| R² (coefficient of determination) | 1 − SSR/SST | Proportion of variance in Y explained by the model |
| Regression diagnostics | — | Set of plots and tests to verify regression assumptions |
| Model fit | R², RMSE, residual plots | How well the regression line represents the observed data |
| Q-Q plot | Quantile-Quantile plot | Compares residual quantiles to theoretical normal quantiles to check normality |
Related Topics
Sources & further reading:
- NIST Engineering Statistics Handbook — Residual Analysis
- James, G., Witten, D., Hastie, T., & Tibshirani, R. (2021). An Introduction to Statistical Learning (2nd ed.). Springer. Free PDF
- Penn State STAT 501 — Residuals, Sums of Squares, and R²
- scikit-learn documentation — Linear Models
- American Statistical Association — Statistical practice guidelines
Frequently Asked Questions
A residual is the difference between an observed value and the value predicted by a regression model for the same observation. Written as eᵢ = yᵢ − ŷᵢ, where yᵢ is the actual observation and ŷᵢ is the fitted value from the regression line. Residuals measure how far each data point falls from the regression line. When residuals are small and randomly scattered, the model fits well.
A good residual plot shows points scattered randomly around the horizontal zero line with no discernible pattern. The spread of the points should be roughly consistent across all fitted values (no funnel shape), and no individual points should stand far apart from the rest. Roughly 95% of standardized residuals should fall between −2 and +2.
A U-shaped or arch pattern in the residual plot means the relationship between X and Y is non-linear. A funnel shape (residuals spreading wider as fitted values increase) indicates heteroscedasticity — unequal variance across the range of X. Points far from zero are outlier candidates. Alternating positive and negative residuals in sequence suggests autocorrelation, common in time-series data.
Heteroscedasticity means the variance of the residuals is not constant across all values of the predictor. It shows as a funnel or fan shape in the residual vs fitted plot. While the regression coefficients remain unbiased, heteroscedasticity makes the standard errors incorrect. This means t-tests, F-tests, and confidence intervals from the regression output cannot be trusted. Remedies include transforming Y (often log), using heteroscedasticity-consistent standard errors, or fitting a weighted least squares model.
In Excel, run the regression through Data → Data Analysis → Regression. Check the "Residuals" and "Residual Plots" boxes before clicking OK. Excel will generate a table of predicted values and residuals, plus an individual residual plot for each predictor. Alternatively, use this generator — paste your X and Y columns as comma-separated pairs in the CSV tab for instant, publication-ready residual diagnostics.
A raw residual (eᵢ = yᵢ − ŷᵢ) is in the original units of Y, making it hard to compare across datasets or identify outliers on a common scale. A standardized residual divides the raw residual by the standard deviation of all residuals, producing a unit-free value. Standardized residuals follow approximately a standard normal distribution, so values beyond ±2 flag potential outliers and values beyond ±3 are strong outlier candidates.
Yes. For multiple regression, plot residuals vs the overall fitted values (ŷ) as well as residuals vs each individual predictor. The fitted vs residual plot catches overall model misfit, while predictor-specific plots can reveal which variable is causing the problem. This generator handles simple linear regression; for multiple regression, tools such as R (using plot(lm(y ~ x1 + x2))) or Python's statsmodels library provide the full suite of multi-predictor diagnostics.
Cook's Distance measures how much the regression coefficients would change if a single observation were removed. It combines the size of the residual with the leverage of the observation (how far its X value is from the mean of all X values). An observation can have a moderate residual but still be highly influential if it has high leverage. Cook's Distance > 0.5 typically warrants investigation; values > 1 are considered highly influential. This is why examining both residuals and leverage together provides a more complete picture than residuals alone.