Concept · Statistics Library

Cook's distance

Cook's distance measures how much a regression's fitted values would change if one row were left out of the fit, by combining how far that row is from the line (its residual) with how unusual its predictor values are (its leverage).

Topic indexA reference reading outside the guided chapter sequence

Understand the idea

Some rows matter more to a regression than others. Cook's distance asks, for each row: if I refit the model without this row, how far would the fitted values move? A row with a small Cook's distance could be dropped and almost nothing would change; a row with a large one is holding the line where it is.

Two things make a row influential, and Cook's distance multiplies them together. One is how far the row is from the line, its residual Residual. The other is how unusual its predictor values are, its leverage Leverage. A row far from the line with ordinary predictor values has little pull, and so does a row with unusual predictor values that sits on the line. A row unusual in both ways can move the line a lot.

That is why the biggest outlier is not always the most influential row. Take two rows of the same regression: one is 3.2 standard errors below the line with leverage 0.08, the other only 1.4 below with leverage 0.35. The second has the larger Cook's distance, because its leverage more than makes up for its smaller residual.

The KernelStats linear regression card flags a row whose Cook's distance is above 4/n, where n is the number of rows used. That is a screening rule: it picks out rows worth a look, not rows that are wrong. A flag is not an error. Check a flagged row for a data-entry mistake; if it is a real observation, keep it, and if you want to know how much it matters, compare the fit with and without it.

To compare residuals from different parts of the data, each residual is divided by an estimate of its own spread. A residual scaled this way is called a studentized residual, and some software calls one version of it a standardized residual; the formula for Cook's distance differs with the version, so it is worth knowing which one you have. Cook's distance is often written Cook's D.

Practitioner explanation

Cook (1977) defined D_i = Σ_j (ŷ_j − ŷ_j(i))² / (p s²), where ŷ_j(i) is row j's fitted value from the fit without row i, p the number of coefficients (intercept included) and s² the full-fit residual mean square; equivalently D_i = (β̂ − β̂_(i))ᵀXᵀX(β̂ − β̂_(i)) / (p s²), a scaled distance between the coefficient vectors with and without row i.

No refit is needed. With e_i the ordinary residual and h_i the leverage, D_i = e_i² h_i / (p s² (1 − h_i)²). With the internally studentized residual r_i = e_i / (s√(1 − h_i)), the same quantity is D_i = (r_i²/p) · h_i/(1 − h_i): one factor of (1 − h_i) has been absorbed into r_i. The two forms are identical and differ only in the residual they start from, so use the one that matches the residual you have: h/(1 − h) applied to e/s understates D by the factor (1 − h), and h/(1 − h)² applied to r overstates it by 1/(1 − h). The externally studentized residual t_i = e_i / (s_(i)√(1 − h_i)), with s_(i)² the residual mean square without row i, gives (t_i²/p) · h_i/(1 − h_i) = D_i · s²/s_(i)², close to D_i unless the row is itself a gross outlier.

The names are not standard. R calls the internally studentized residual standardized (rstandard) and the externally studentized one rstudent; SAS calls them STUDENT and RSTUDENT; and some regression textbooks reserve "standardized residual" for e_i/s. Before computing D from a quoted residual, say which one it is.

Cut-offs are conventions, not tests. 4/n is a sensitive screen that flags a few percent of rows in most data sets. D_i > F_0.5(p, n − p), the median of the F distribution (0.69 for p = 2 and large n, approaching 1 as p grows), is the rule R's influence.measures() uses; it means that deleting the row moves the coefficient vector beyond the edge of the 50% confidence region around β̂. D_i > 1 is the older rule of thumb. Two influential rows close together can mask each other, since deleting either one alone changes little; DFFITS, DFBETAS and refitting without the group of rows address that.

The KernelStats linear regression card computes D_i from the full fit (statsmodels' closed form, the same values as R's cooks.distance) and calls it Cook's distance (Cook's D on the Unusual obs tile). It flags D_i > 4/n, one of the three rules behind the Unusual obs tile and the Unusual observations table, with leverage > 2p/n and |externally studentized residual| > 3; the table lists at most ten flagged rows, largest D first, the Residuals vs Leverage panel is colored by D, and Save Columns writes D_i as "Linear regression Cook's D". The residual the card flags on and saves is the externally studentized one (R's rstudent), not the internally studentized residual inside D's formula. On the penguin regression of body mass on flipper length, the row with the largest D has e = 1,288.7 g and h = 0.00717, so r = 3.28 and D = (3.28²/2) × 0.00717/0.99283 = 0.0388, while its externally studentized residual t = 3.33 in the same formula would give 0.0400; 15 of the 342 rows exceed 4/n = 0.0117 and none exceeds F_0.5(2, 340) = 0.69.

When to use it

Consider it when

With every fitted regression, to find the rows the fit depends on most before trusting its coefficients, and to compare how much pull two rows have.

Use caution when

Not as a test that a row is wrong and not as a deletion rule: the 4/n, F-median and D > 1 cut-offs are screening conventions, and a large D says the fit depends on the row, not that the row is an error.

Formulas and symbols

Cook's distance (by deletion)

Di=∑j=1n(y^j−y^j(i))2p s2D_i = \frac{\sum_{j=1}^{n}\left(\hat{y}_j - \hat{y}_{j(i)}\right)^2}{p\,s^2}

y-hat_j(i) is row j's fitted value with row i left out, p the number of coefficients including the intercept and s^2 the residual mean square of the full fit.

Cook's distance from the ordinary residual

Di=ei2p s2⋅hii(1−hii)2D_i = \frac{e_i^2}{p\,s^2}\cdot\frac{h_{ii}}{(1 - h_{ii})^2}

e_i is the ordinary residual and h_ii the leverage of row i.

Cook's distance from the internally studentized residual

Di=ri2p⋅hii1−hii,ri=eis1−hiiD_i = \frac{r_i^2}{p}\cdot\frac{h_{ii}}{1 - h_{ii}}, \qquad r_i = \frac{e_i}{s\sqrt{1 - h_{ii}}}

r_i is the internally studentized residual (R's rstandard).

The card's screening cut-off

Di>4nD_i > \frac{4}{n}

n is the number of rows used.

Worked example

Scenario

Two rows of the same linear regression with p = 2 coefficients: row A has internally studentized residual r = −3.2 and leverage h = 0.08; row B has r = −1.4 and h = 0.35.

Result

D_A = (10.24/2) × 0.08/0.92 = 0.445 and D_B = (1.96/2) × 0.35/0.65 = 0.528. Read as residuals divided by s instead, D = (r²/p) × h/(1 − h)² gives 0.484 and 0.812.

Interpretation

Row B is more influential although row A is the bigger outlier: B's leverage gives it more pull on the fitted line. The order is the same under either reading of the residual, and with p the same for both rows the comparison does not depend on p (r² × h/(1 − h) is 0.89 for A and 1.06 for B).

Common misconceptions

Misconception

A row with a large Cook's distance is an error and should be removed.

Correction

A flag is not an error: Cook's distance says how much the fit depends on a row, not whether the row is wrong. Check the row for an entry or measurement mistake; if it is real, keep it, and if it matters, report the fit with and without it.

Misconception

The row with the biggest residual is always the most influential.

Correction

Influence needs leverage too: Cook's distance multiplies the squared residual by a leverage term, so a row with a smaller residual but unusual predictor values can move the line more than the biggest outlier. A row 3.2 standard errors from the line with leverage 0.08 has less influence than one 1.4 standard errors away with leverage 0.35.

Misconception

A standardized residual is always the residual divided by s.

Correction

Not in R: its standardized residual (rstandard) divides the residual by its own standard error, s times the square root of 1 minus the leverage, which is the internally studentized residual; only some textbooks use the name for the residual divided by s. The two need different Cook's distance formulas, so say which one you have.

References

  1. Detection of influential observation in linear regression, Cook, R. D. (1977), Technometrics, 19(1), 15-18.
  2. Applied Linear Statistical Models, 5th edition, Kutner, M. H., Nachtsheim, C. J., Neter, J. and Li, W. (2004), Chapter 10 (identifying influential cases: DFFITS, Cook's distance, DFBETAS).
  3. KernelStats linear regression card (engine code, Learn More and Save Columns descriptions), KernelStats documentation (2026).