Cook's distance

From HandWiki
Short description: Measure of the influence of a data point in regression analysis

In statistics, Cook's distance or Cook's D is a commonly used estimate of the influence of a data point when performing a least-squares regression analysis.[1] In a practical ordinary least squares analysis, Cook's distance can be used in several ways: to indicate influential data points that are particularly worth checking for validity; or to indicate regions of the design space where it would be good to be able to obtain more data points. It is named after the American statistician R. Dennis Cook, who introduced the concept in 1977.[2][3]


Data points with large residuals (outliers) and/or high leverage may distort the outcome and accuracy of a regression. Cook's distance measures the effect of deleting a given observation. Points with a large Cook's distance are considered to merit closer examination in the analysis.

For the algebraic expression, first define

[math]\displaystyle{ \underset{n \times 1}{\mathbf{y}} = \underset{n \times p}{\mathbf{X}} \quad \underset{p \times 1}{\boldsymbol{\beta}} \quad + \quad \underset{n \times 1}{\boldsymbol{\varepsilon}} }[/math]

where [math]\displaystyle{ \boldsymbol{\varepsilon} \sim \mathcal{N}\left( 0, \sigma^2 \mathbf{I} \right) }[/math] is the error term, [math]\displaystyle{ \boldsymbol{\beta} = \left[ \beta_{0} \, \beta_{1} \dots \beta_{p-1} \right] }[/math] is the coefficient matrix, [math]\displaystyle{ p }[/math] is the number of covariates or predictors for each observation, and [math]\displaystyle{ \mathbf{X} }[/math] is the design matrix including a constant. The least squares estimator then is [math]\displaystyle{ \mathbf{b} = \left( \mathbf{X}^{\mathsf{T}} \mathbf{X} \right)^{-1} \mathbf{X}^{\mathsf{T}} \mathbf{y} }[/math], and consequently the fitted (predicted) values for the mean of [math]\displaystyle{ \mathbf{y} }[/math] are

[math]\displaystyle{ \mathbf{\widehat{y}} = \mathbf{X} \mathbf{b} = \mathbf{X} \left( \mathbf{X}^{\mathsf{T}} \mathbf{X} \right)^{-1} \mathbf{X}^{\mathsf{T}} \mathbf{y} = \mathbf{H} \mathbf{y} }[/math]

where [math]\displaystyle{ \mathbf{H} \equiv \mathbf{X} ( \mathbf{X}^{\mathsf{T}} \mathbf{X})^{-1} \mathbf{X}^{\mathsf{T}} }[/math] is the projection matrix (or hat matrix). The [math]\displaystyle{ i }[/math]-th diagonal element of [math]\displaystyle{ \mathbf{H} \, }[/math], given by [math]\displaystyle{ h_{ii} \equiv \mathbf{x}_i^{\mathsf{T}} ( \mathbf{X}^{\mathsf{T}} \mathbf{X})^{-1} \mathbf{x}_i }[/math],[4] is known as the leverage of the [math]\displaystyle{ i }[/math]-th observation. Similarly, the [math]\displaystyle{ i }[/math]-th element of the residual vector [math]\displaystyle{ \mathbf{e} = \mathbf{y} - \mathbf{\widehat{y\,}} = \left( \mathbf{I} - \mathbf{H} \right) \mathbf{y} }[/math] is denoted by [math]\displaystyle{ e_i }[/math].

Cook's distance [math]\displaystyle{ D_i }[/math] of observation [math]\displaystyle{ i \; (\text{for } i = 1, \dots, n) }[/math] is defined as the sum of all the changes in the regression model when observation [math]\displaystyle{ i }[/math] is removed from it[5]

[math]\displaystyle{ D_i = \frac { \sum_{j=1}^n \left( \widehat{y\,}_j - \widehat{y\,}_{j(i)} \right)^2 } {p s^2} }[/math]

where [math]\displaystyle{ \widehat{y\,}_{j(i)} }[/math] is the fitted response value obtained when excluding [math]\displaystyle{ i }[/math], and [math]\displaystyle{ s^2 = \frac{\mathbf{e}^\top \mathbf{e}}{n-p} }[/math] is the mean squared error of the regression model.[6]

Equivalently, it can be expressed using the leverage[5] ([math]\displaystyle{ h_{ii} }[/math]):

[math]\displaystyle{ D_i = \frac{e_i^2}{p s^2}\left[\frac{h_{ii}}{(1-h_{ii})^2}\right] . }[/math]

Detecting highly influential observations

There are different opinions regarding what cut-off values to use for spotting highly influential points. Since Cook's distance is in the metric of an F distribution with [math]\displaystyle{ p }[/math] and [math]\displaystyle{ n-p }[/math] (as defined for the design matrix [math]\displaystyle{ \mathbf{X} }[/math] above) degrees of freedom, the median point (i.e., [math]\displaystyle{ F_{0.5}(p,n-p) }[/math]) can be used as a cut-off.[7] Since this value is close to 1 for large [math]\displaystyle{ n }[/math], a simple operational guideline of [math]\displaystyle{ D_i\gt 1 }[/math] has been suggested.[8] Note that the Cook's distance measure does not always correctly identify influential observations.[9][10]

Relationship to other influence measures (and interpretation)

[math]\displaystyle{ D_i }[/math] can be expressed using the leverage[5] ([math]\displaystyle{ 0 \leq h_{ii} \leq 1 }[/math]) and the square of the internally Studentized residual ([math]\displaystyle{ 0 \leq t_i^2 }[/math]), as follows:

[math]\displaystyle{ \begin{align} D_i &= \frac{e_i^2}{p s^2}\left[\frac{h_{ii}}{(1-h_{ii})^2}\right] = \frac{1}{p} \frac{e_i^2}{{1 \over n-p}\sum_{j=1}^n \widehat{\varepsilon\,}_j^{\,2} (1-h_{ii})}\left[\frac{h_{ii}}{1-h_{ii}}\right] \\ &= \left[\frac{1}{p} \right] t_i^2 \frac{h_{ii}}{1-h_{ii}} . \end{align} }[/math]

The benefit in the last formulation is that it clearly shows the relationship between [math]\displaystyle{ t_i^2 }[/math] and [math]\displaystyle{ h_{ii} }[/math] to [math]\displaystyle{ D_i }[/math] (while p and n are the same for all observations). If [math]\displaystyle{ t_i^2 }[/math] is large then it (for non-extreme values of [math]\displaystyle{ h_{ii} }[/math]) will increase [math]\displaystyle{ D_i }[/math]. If [math]\displaystyle{ h_{ii} }[/math] is close to 0 than [math]\displaystyle{ D_i }[/math] will be small, while if [math]\displaystyle{ h_{ii} }[/math] is close to 1 then [math]\displaystyle{ D_i }[/math] will become very large (as long as [math]\displaystyle{ t_i^2 \gt 0 }[/math], i.e.: that the observation [math]\displaystyle{ i }[/math] is not exactly on the regression line that was fitted without observation [math]\displaystyle{ i }[/math]).

[math]\displaystyle{ D_i }[/math] is related to DFFITS through the following relationship (note that [math]\displaystyle{ {\widehat{\sigma} \over \widehat{\sigma}_{(i)}} t_i = t_{i(i)} }[/math] is the externally studentized residual, and [math]\displaystyle{ \widehat{\sigma}, \widehat{\sigma}_{(i)} }[/math] are defined here):

[math]\displaystyle{ \begin{align} D_i &= \left[\frac{1}{p} \right] t_i^2 \frac{h_{ii}}{1-h_{ii}} \\ &= \left[\frac{1}{p} \right] {\widehat{\sigma}_{(i)}^2 \over \widehat{\sigma}^2} {\widehat{\sigma}^2 \over \widehat{\sigma}_{(i)}^2} t_i^2 \frac{h_{ii}}{1-h_{ii}} = \left[\frac{1}{p} \right] {\widehat{\sigma}_{(i)}^2 \over \widehat{\sigma}^2} \left(t_{i(i)} \sqrt{\frac{h_{ii}}{1-h_{ii}}}\right)^2 \\ &= \left[\frac{1}{p} \right] {\widehat{\sigma}_{(i)}^2 \over \widehat{\sigma}^2} \text{DFFITS}^2 \end{align} }[/math]

[math]\displaystyle{ D_i }[/math] can be interpreted as the distance one's estimates move within the confidence ellipsoid that represents a region of plausible values for the parameters.[clarification needed] This is shown by an alternative but equivalent representation of Cook's distance in terms of changes to the estimates of the regression parameters between the cases, where the particular observation is either included or excluded from the regression analysis.

An alternative to [math]\displaystyle{ D_i }[/math] has been proposed. Instead of considering the influence a single observation has on the overall model, the statistics [math]\displaystyle{ S_i }[/math] serves as a measure of how sensitive the prediction of the [math]\displaystyle{ i }[/math]-th observation is to the deletion of each observation in the original data set. It can be formulated as a weighted linear combination of the [math]\displaystyle{ D_j }[/math]'s of all data points. Again, the projection matrix is involved in the calculation to obtain the required weights:

[math]\displaystyle{ \begin{align} S_i = \sum_{j=1}^n \frac { h_{ij}^{2} \cdot D_{j}} { h_{ii} \cdot h_{jj} } = \sum_{j=1}^n \rho_{ij}^{2} \cdot D_{j} \end{align} }[/math]

In this context, [math]\displaystyle{ \rho_{ij} }[/math] ([math]\displaystyle{ \leq 1 }[/math]) resembles the correlation between the predictions [math]\displaystyle{ \widehat{y\,}_i }[/math] and [math]\displaystyle{ \widehat{y\,}_j }[/math][lower-alpha 1].
In contrast to [math]\displaystyle{ D_i }[/math], the distribution of [math]\displaystyle{ S_i }[/math] is asymptotically normal for large sample sizes and models with many predictors. In absence of outliers the expected value of [math]\displaystyle{ S_i }[/math] is approximately [math]\displaystyle{ p^{-1} }[/math]. An influential observation can be identified if

[math]\displaystyle{ \begin{align} \left| S_i - med \left( S \right) \right| \geq 4.5 \cdot MAD \left( S \right) \end{align} }[/math]

with [math]\displaystyle{ med \left( S \right) }[/math] as the median and [math]\displaystyle{ MAD \left( S \right) }[/math] as the median absolute deviation of all [math]\displaystyle{ S }[/math]-values within the original data set, i.e., a robust measure of location and a robust measure of scale for the distribution of [math]\displaystyle{ S_i }[/math]. The factor 4.5 covers approx. 3 standard deviations of [math]\displaystyle{ S }[/math] around its centre.
When compared to Cook's distance, [math]\displaystyle{ S }[/math] was found to perform well for high- and intermediate-leverage outliers, even in presence of masking effects for which [math]\displaystyle{ D_i }[/math] failed.[12]

Software implementations

Many programs and statistics packages, such as R, Python, etc., include implementations of Cook's distance.

Language/Program Function Notes
R cooks.distance(model, ...) See [1]
Python CooksDistance().fit(X, y) See [2]


High-dimensional Influence Measure (HIM) is an alternative to Cook's distance for when [math]\displaystyle{ p\gt n }[/math] (i.e., when there are more predictors than observations).[13] While the Cook's distance quantifies the individual observation's influence on the least squares regression coefficient estimate, the HIM measures the influence of an observation on the marginal correlations.

See also


  1. The indices [math]\displaystyle{ i }[/math] and [math]\displaystyle{ j }[/math] are often interchanged in the original publication as the projection matrix [math]\displaystyle{ \mathbf{H} }[/math] is symmetric in ordinary linear regression, i.e., [math]\displaystyle{ h_{ij} = h_{ji} }[/math]. Since this is not always the case, e.g., in weighted linear regression, the indices have been written consistently here to account for potential asymmetry and thus allow for direct usage.[11]


  1. Mendenhall, William; Sincich, Terry (1996). A Second Course in Statistics: Regression Analysis (5th ed.). Upper Saddle River, NJ: Prentice-Hall. p. 422. ISBN 0-13-396821-9. "A measure of overall influence an outlying observation has on the estimated [math]\displaystyle{ \beta }[/math] coefficients was proposed by R. D. Cook (1979). Cook's distance, Di, is calculated..." 
  2. Cook, R. Dennis (February 1977). "Detection of Influential Observations in Linear Regression". Technometrics (American Statistical Association) 19 (1): 15–18. doi:10.2307/1268249. 
  3. Cook, R. Dennis (March 1979). "Influential Observations in Linear Regression". Journal of the American Statistical Association (American Statistical Association) 74 (365): 169–174. doi:10.2307/2286747. 
  4. Hayashi, Fumio (2000). Econometrics. Princeton University Press. pp. 21–23. ISBN 1400823838. 
  5. 5.0 5.1 5.2 "Cook's Distance". 
  6. "Statistics 512: Applied Linear Models". Purdue University. 
  7. Bollen, Kenneth A.; Jackman, Robert W. (1990). "Regression Diagnostics: An Expository Treatment of Outliers and Influential Cases". in Fox, John; Long, J. Scott. Modern Methods of Data Analysis. Newbury Park, CA: Sage. pp. 266. ISBN 0-8039-3366-5. 
  8. Cook, R. Dennis; Weisberg, Sanford (1982). Residuals and Influence in Regression. New York, NY: Chapman & Hall. ISBN 0-412-24280-X. 
  9. Kim, Myung Geun (31 May 2017). "A cautionary note on the use of Cook's distance". Communications for Statistical Applications and Methods 24 (3): 317–324. doi:10.5351/csam.2017.24.3.317. ISSN 2383-4757. 
  10. On deletion diagnostic statistic in regression
  11. Peña 2005, p. 2.
  12. Peña, Daniel (2005). "A New Statistic for Influence in Linear Regression". Technometrics (American Society for Quality and the American Statistical Association) 47 (1): 1-12. doi:10.1198/004017004000000662. 
  13. High-dimensional influence measure

Further reading