KatInterview

Outliers, Leverage, and Influence in OLS Regression

Machine LearningModel answer
HardModel answerMachine Learningregressiondiagnosticsrobust-statistics

Last updated

Derive Cook's distance from first principles, build a diagnostic workflow, show how one point can flip a coefficient's sign, and compare robust regression alternatives.

Setting the scene

You are reviewing a linear regression model before it ships to production. A colleague flags that "there might be some weird points." Your job is to be precise about what that means and to decide what to do about it.

The model is ordinary least squares: $y = X\beta + \varepsilon$, where $X$ is $n \times p$ (including the intercept column).

What you are asked to do

Part 1 — Definitions and derivation

Clearly distinguish three concepts that are often conflated:

  • An outlier in the response
  • A high-leverage observation
  • An influential observation

Then derive Cook's distance $D_i$ from the leave-one-out deletion formula. Your derivation should make explicit how $D_i$ depends on the leverage $h_{ii}$ and the studentized residual $r_i$, and explain why both components are necessary.

Part 2 — Diagnostic workflow

Walk through the sequence of plots and statistics you would run, in the order you would run them, to detect each of the three point types. Note any traps — situations where a standard diagnostic gives a misleading result.

Part 3 — Consequences and alternatives

Using a small concrete example (you may construct one), show how removing a single influential point can materially change a conclusion — for instance, flipping the sign of a coefficient. Then propose at least two robust regression alternatives to OLS, explaining how each one limits the damage from problematic points and what its limitations are.

Part 4 — Reporting

How would you document and justify a decision to retain, remove, or down-weight one or more observations in a model review? What distinguishes a defensible decision from p-hacking?

What a complete answer looks like

  • A clean derivation with the key algebraic step made explicit
  • A prioritized workflow (not just a list of tools)
  • A numerical example that makes the sign-flip concrete
  • A comparison of at least two robust methods with honest trade-offs
  • A short but principled position on reporting

Hints

Hint 1

The hat matrix H = X(X'X)⁻¹X' projects y onto the column space of X. The diagonal entry h_ii is the leverage of observation i. Think about what it means geometrically — how far x_i sits from the centroid of the predictor space — and why that makes it possible for one observation to control the fit without showing a large raw residual.

Hint 2

For the derivation, apply the Sherman–Morrison identity to (X'X − x_i x_i')⁻¹. The payoff is a closed-form expression for β̂ − β̂_(i) that requires no refitting. Once you have that, Cook's distance is just that shift measured in the natural metric of the coefficient space.

Hint 3

Residual-only screening is the most common mistake. A high-leverage point that lies close to where the fitted line would land anyway has a small residual — but it may still be the observation that determined where the line landed. Always check leverage and Cook's distance together, and watch for masking: several bad points clustered in predictor space can make each other look unremarkable.