Regression Residual Diagnostics

Regression LINE assumption audit

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.

👨‍🏫 Professor Mode: Guided Learning Experience

New to residual diagnostics? Enable Professor Mode for step-by-step guidance on the 4 classic diagnostic plots, LINE assumptions, and fault injection!

📖 What residuals can tell you

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
1. Raw Residual & Residual Standard Error (Typical Miss)
\[ e_i = y_i - \hat{y}_i, \qquad s = \sqrt{\frac{\sum_{i=1}^{n} e_i^2}{n - k}} \]
💬 Read it in plain English: Each row's residual (ei) is the actual outcome minus the model's prediction, and the residual standard error (s) measures the size of a typical prediction miss in the outcome's natural units.
yi, ŷi
Actual Outcome & Fitted Value YOUR DATA ⓘ
What actually happened in row i (yi) versus what the fitted regression line predicted (ŷi).
ei, s
Raw Residual & Residual Standard Error OUTPUT ⓘ
Row i's prediction error (ei; positive means the model predicted too low) and typical miss size (s).
n, k
Sample Size & Number of Parameters YOUR DATA ⓘ
Total rows used (n) and total estimated coefficients (k, counting the intercept plus numeric and dummy columns).
2. Leverage, Standardized Residual & Cook's Distance
\[ h_{ii} = \mathbf{x}_i^\top \left(\mathbf{X}^\top \mathbf{X}\right)^{-1} \mathbf{x}_i = \frac{1}{n} + \frac{(x_i - \bar{x})^2}{\sum_{j=1}^{n} (x_j - \bar{x})^2} \] \[ r_i = \frac{e_i}{s\sqrt{1 - h_{ii}}}, \qquad D_i = \frac{r_i^2}{k} \cdot \frac{h_{ii}}{1 - h_{ii}} \]
💬 Read it in plain English: Leverage (hii) measures how far a row's predictor values sit from the center of the data; Standardized Residual (ri) scales the miss into standard-deviation units; and Cook's Distance (Di) combines both to measure how much the entire regression shifts if row i is removed.
hii, xi, X
Hat-Matrix Leverage & Design Matrix OUTPUT ⓘ
Leverage hii computed from row vector xi and design matrix X (or distance from mean x̄ in 1-predictor form).
ri
Internally Standardized Residual INFERENCE ⓘ
Row i's miss measured in typical misses after adjusting for leverage; values beyond ±2 or ±3 flag outliers.
Di
Cook's Distance (Overall Influence) INFERENCE ⓘ
Combined influence score showing how far all fitted predictions move when row i is omitted from the regression.

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.

No file uploaded.

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.

Tests Influence
    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

    Fitted model

    Load a case to fit the model.

    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
    Linearity
    Waiting for data
    Independence
    Waiting for data
    Normality
    Waiting for data
    Equal Variance
    Waiting for data
    Influence
    Waiting for data
    📊 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.

    APA-Style Statistical Reporting

    Managerial Interpretation

    Diagnostics & assumptions