Regression Residual Diagnostics
Check whether a regression, simple or multiple, with numeric or categorical predictors, can be trusted: five verdicts, the four classic residual plots and a plot for each predictor.
📖 What residuals can tell you
- A residual is one row's miss: the actual outcome minus the model's prediction for that row.
- If the model has captured the pattern, the misses look like structureless noise: no curve, no funnel, no streaks over time.
- A shape in the misses, or one row that moves the whole line, tells you which part of the model to distrust before you act on it.
OVERVIEW & WHAT THIS TOOL SOLVES
A regression model can report an impressive R-squared and significant p-values while still making systematically wrong predictions—because a hidden curve, a widening funnel of errors, or a single extreme store is hijacking the line. Regression Residual Diagnostics inspects what your model leaves behind (the residuals, or row-by-row prediction misses) across the four classic diagnostic plots so you can spot assumption violations and influential outliers before acting on a flawed forecast.
🎯 Questions It Answers
- Did our straight-line regression miss a curved relationship or diminishing-returns pattern (Linearity)?
- Do prediction misses fan out wildly at higher spend or revenue levels, invalidating standard p-values (Equal Variance)?
- Is a single high-leverage outlier pulling the entire regression slope toward itself (Cook's Distance)?
📂 What Data You Need
- Case-Level CSV or Preset Scenario: One row per store, customer, campaign, or time period.
- 1 Continuous Outcome: The numeric metric your regression predicts.
- 1+ Predictors: Numeric or categorical predictors (plus an optional Fault Injection toggle to see how violations look in real time).
💡 What You'll Discover
- The 4 Classic Diagnostic Plots: Residuals vs. Fitted, Normal Q-Q, Scale-Location, and Residuals vs. Leverage.
- LINE Assumption Health Checks: Automated visual and statistical checks for Linearity, Independence, Normality, and Equal Variance.
- Influence & Outlier Inspector: Row-by-row leverage, standardized residuals, and Cook's Distance flags.
🔍 Key Nuances: The LINE Assumptions, Categorical Stripes & Cook's Distance Rules
L: Linearity
Does a straight line follow the real pattern? On the Residuals vs. Fitted plot the misses should scatter evenly above and below zero all the way across. If they sag in the middle and rise at both ends, or the reverse, the relationship curves and the line misreads it.
I: Independence
Is each miss its own surprise? In time-ordered data, last week's miss should not predict this week's. Long runs of misses on the same side of zero mean neighbouring periods move together. Rows with no time order cannot show this.
N: Normality
Are big misses about as rare as a bell curve says? On the Normal Q-Q plot the dots should hug the dashed line. Dots peeling away at either end mean more extreme misses than a bell curve allows.
E: Equal variance
Is the typical miss about the same size everywhere? On the Scale-Location plot the trend should stay flat. A rising trend means the misses grow with the prediction, like a funnel. With categories, compare each group's spread too.
What changes with categorical predictors
A category such as region enters as 0/1 columns, one per level except the baseline. Rows that share a group get the same push, so residual plots show vertical stripes: those are the groups, not a pattern. Check the spread group by group. A level with only a few rows pulls the fit towards itself (high leverage), and a level with one row is fitted exactly.
Cook's distance and leverage rules of thumb: A row can have unusual predictor values (high leverage) and do no harm if its outcome sits along the trend line. It becomes influential only when it pulls the fitted model away from the rest:
- Cook's D > 0.5: Worth a close look—one row may be steering a coefficient.
- Cook's D > 1.0: That row alone steers the fit. Always report the model with and without it before relying on the slope.
- Cook's D > 4/n: A sensitive screening threshold that flags top influential rows to inspect (not to drop automatically).
📐 Under the Hood: Model Equations & Variable Definitions
Where:
- \(n\) is the number of rows the model uses.
- \(k\) is the number of coefficients: the intercept, one per numeric predictor and one per dummy (0/1) column of each category.
- \(y_i\) is what actually happened in row \(i\): its outcome value.
- \(\hat{y}_i\) is the model's prediction for row \(i\), also called its fitted value.
- \(e_i\) is row \(i\)'s residual: actual minus predicted. Positive means the model predicted too low.
- \(s\) is the residual standard error: the size of a typical miss, in the outcome's own units.
- \(h_{ii}\) is row \(i\)'s leverage: between \(1/n\) and 1, averaging \(k/n\). Above about \(2k/n\) counts as high.
- \(r_i\) is the standardized residual. About 95% should fall between −2 and +2 when the model is right.
- \(\mathbf{x}_i\) is row \(i\)'s predictor values in a list, starting with 1 for the intercept and 0 or 1 for each dummy column.
- \(\mathbf{X}\) stacks every row's list into one table (the design matrix). \(\top\) turns a table on its side and \(^{-1}\) is the matrix inverse.
- \(x_i\) and \(\bar{x}\), in the one-predictor form, are row \(i\)'s predictor value and the average of all of them.
- \(D_i\) is Cook's distance: above 0.5 is worth a look, above 1 means that row alone steers the fit.
DATA SOURCE
Use a Case Study
Use Your Data
Drag & Drop raw data file (.csv, .tsv, .txt)
One row per case, with a header row. At least 8 usable rows.
Outcome: one numeric column. Predictors: numeric columns, or category columns with 2–12 levels. Optional: a time-order column (week, date, period) for the independence check.
Messy file? Clean it in the Import Wizard. Large file? Upload it here directly; use the Import Wizard for small or messy files.
INPUTS & SETTINGS
The model being checked
The case sets these for you. Change any of them and every check below reruns.
Units (every sentence below uses them)
⚠️ Break the model
Each switch damages a copy of the data in one specific way, so you can see which card and which plot react.
Advanced: random seed
The switches above use random numbers. The same seed gives the same broken data on every screen in the room.
RESULTS
Start here
How much does the prediction move per typical step of the predictor?
–Regression slope
Load a case to see what this means here.
How much of the ups and downs in the outcome does the model account for?
–Adjusted R²
Load a case to see what this means here.
Is one row pulling the whole model towards itself?
–Largest Cook's distance
Load a case to see what this means here.
Those three names are the ones you will be graded on. The questions above them are what each one actually answers.
Coefficients
| Term | Estimate | Std. error | t | p |
|---|
📊 How the five checks are decided
- Linearity. The model is refitted with the squared prediction added (Ramsey RESET). If that bend helps, with p below .05, the card says "Check this". Each numeric predictor's own squared term is then tested to name the one that bends. With only categorical predictors there is no line to bend, so the check does not apply.
- Independence. Only runs when you choose a time order. A Ljung-Box p below .05 says neighbouring misses move together. A Durbin-Watson value near 2 is good; well below 2 means runs of same-side misses.
- Normality. A Shapiro-Wilk p of .05 or more passes. Below .05 the card says "Worth a look", or "Check this" when there are fewer than 30 rows, very heavy tails (excess kurtosis above 3) or strong skew (above 2 either way).
- Equal variance. "Check this" needs two signs together: a Breusch-Pagan p below .05, and one third of the predictions or one group with at least twice the typical miss of another. One sign alone gives "Worth a look".
- Influence. "Check this" when any row has a Cook's distance above 1. "Worth a look" when one sits between 0.5 and 1, or when every row of a small category has high leverage.
- Recheck. A missed curve can make the misses look uneven and heavy-tailed. When Linearity fails and no single row explains it, Equal variance and Normality wait until the curve is fixed.
The four residual plots
Tab to a plot, then use the arrow keys (or tap a point) to read any row's numbers. Escape clears the selection.
1. Residuals vs. Fitted (Linearity)
📊 How to read this chart
- Axes. Across: the model's prediction for each row. Up: that row's miss, actual minus predicted. Zero is a perfect prediction.
- What good looks like. An even band of dots around zero, with the orange dashed trend (LOWESS) staying close to flat.
- Red flag. The trend bends into an arch or a U, which is a curve the straight line missed. A band that widens to one side is a funnel; check Equal variance.
- Stripes. With a category, or only a few distinct predictions, dots stack in vertical stripes. Those are the groups, not a pattern.
2. Normal Q-Q Plot (Normality)
📊 How to read this chart
- Axes. The misses are sorted from smallest to largest. Across: where each one would sit if the misses followed a bell curve. Up: where it actually sits, in typical misses (standardized residuals).
- What good looks like. Dots close to the dashed line, with a little wobble at the two ends.
- Red flag. Both ends peel away from the line (heavy tails: more extreme misses than a bell curve allows), or the dots bow to one side (skew).
- One far dot. A single miss past ±3 is a row to check, not by itself a failed normality check.
3. Scale-Location (Equal Variance)
📊 How to read this chart
- Axes. Across: the prediction. Up: the size of each miss in typical misses, with the sign dropped and square-rooted, so bigger misses sit higher.
- What good looks like. A flat orange trend: the misses are about the same size whatever the model predicts.
- Red flag. A trend that rises (or falls) is a funnel. The coefficients stay fair, but their standard errors and p-values become too optimistic.
4. Cook's Distance (Influential Points)
- below 0.5
- 0.5 to 1 (dashed outline)
- above 1 (hatched, ▲)
📊 How to read this chart
- Axes. Across: each row in file order. Up: Cook's distance, how far all the predictions would move if that row were left out.
- What good looks like. Every bar low, near or below the dotted 4/n line.
- Red flag. A bar past the dashed 0.5 line is worth a look. A bar past the solid 1 line is hatched and marked ▲: that row alone steers the fit.
- Before you drop a row. Influential is not the same as wrong. Check it for a data error, then report the model with and without it.
Residuals against each predictor
📊 How to read this chart
- Numeric panels. Across: the predictor's values. Up: the miss. A flat orange trend around zero is good; a bend says this predictor needs a curve.
- Category panels. Each stripe is one group (level), with the baseline first. The diamond is the group's average miss and the bar its spread (±1 standard deviation).
- Per-level spread. Bars of similar length mean equal spread across groups. One bar about twice as long as another is a sign of unequal spread.
- Rare levels. The count in brackets is the group's size. A group with only a few rows has high leverage: the model bends to fit it, and a group of one is fitted exactly.