Cook's distance explained

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]

Definition

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

\underset{n x 1}{y

} = \underset \quad \underset \quad + \quad \underset

where

\boldsymbol{\varepsilon}\siml{N}\left(0,\sigma2I\right)

is the error term,

\boldsymbol{\beta}=\left[\beta0\beta1...\betap-1\right]T

is the coefficient matrix,

p

is the number of covariates or predictors for each observation, and

X

is the design matrix including a constant. The least squares estimator then is

b=\left(XTX\right)-1XTy

, and consequently the fitted (predicted) values for the mean of

y

are

\widehat{y

} = \mathbf \mathbf = \mathbf \left(\mathbf^ \mathbf \right)^ \mathbf^ \mathbf = \mathbf \mathbf

where

H\equivX(XTX)-1XT

is the projection matrix (or hat matrix). The

i

-th diagonal element of

H

, given by

hii\equiv

T
x
i

(XTX)-1xi

,[4] is known as the leverage of the

i

-th observation. Similarly, the

i

-th element of the residual vector

e=y-\widehat{y

} = \left(\mathbf - \mathbf \right) \mathbf is denoted by

ei

.

Cook's distance

Di

of observation

i(fori=1,...,n)

is defined as the sum of all the changes in the regression model when observation

i

is removed from it[5]

Di=

n
\sum
j=1
\left(\widehat{y
j

-\widehat{y}j(i)\right)2}{ps2}

where p is the rank of the model (i.e., number of independent variables in the design matrix) and

\widehat{y}j(i)

is the fitted response value obtained when excluding

i

, and

s2=

e\tope
n-p

is the mean squared error of the regression model.[6]

Equivalently, it can be expressed using the leverage[5] (

hii

):

Di=

2
e
i
\left[
ps2
hii
(1-hii)2

\right].

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

p

and

n-p

(as defined for the design matrix

X

above) degrees of freedom, the median point (i.e.,

F0.5(p,n-p)

) can be used as a cut-off.[7] Since this value is close to 1 for large

n

, a simple operational guideline of

Di>1

has been suggested.[8]

The

p

-dimensional random vector

b-b(i)

, which is the change of

b

due to a deletion of the

i

-th observation, has a covariance matrix of rank one and therefore it is distributed entirely over one dimensional subspace (a line, say

L

) of the

p

-dimensional space. The distributional property of

b-b(i)

mentioned above implies that information about the influence of the

i

-th observation provided by

b-b(i)

should be obtained not from outside of the line

L

but from the line

L

itself.However, in the introduction of Cook’s distance, a scaling matrix of full rank

p

is chosen and as a result

b-b(i)

is treated as if it is a random vector distributed over the whole space of

p

dimensions. This means that information about the influence of the

i

-th observation provided by

b-b(i)

through the Cook’s distance comes from the whole space of

p

dimensions.Hence the Cook's distance measure is likely to distort the real influence of observations, misleading the right identification of influential observations.[9] [10]

Relationship to other influence measures (and interpretation)

Di

can be expressed using the leverage[5] (

0\leqhii\leq1

) and the square of the internally Studentized residual (

0\leq

2
t
i
), as follows:

\begin{align} Di&=

2
e
i
ps2

hii
(1-hii)2

=

1
p

2
e
i
{1\overn-p
n
\sum
j=1
2
\widehat{\varepsilon}
j

(1-hii)}

hii
1-hii

\\[5pt]&=

1
p

2
t
i

hii
1-hii

.\end{align}

The benefit in the last formulation is that it clearly shows the relationship between

2
t
i
and

hii

to

Di

(while p and n are the same for all observations). If
2
t
i
is large then it (for non-extreme values of

hii

) will increase

Di

. If

hii

is close to 0 then

Di

will be small, while if

hii

is close to 1 then

Di

will become very large (as long as
2
t
i

>0

, i.e.: that the observation

i

is not exactly on the regression line that was fitted without observation

i

).

Di

is related to DFFITS through the following relationship (note that

{\widehat{\sigma}\over\widehat{\sigma}(i)

} t_i = t_ is the externally studentized residual, and

\widehat{\sigma},\widehat{\sigma}(i)

are defined here):

\begin{align} Di&=

1
p

2
t
i

hii
1-hii

\\ &=

1
p

\widehat{\sigma
(i)

2}{\widehat{\sigma}2}

\widehat{\sigma
2}{\widehat{\sigma}
2}
(i)

2
t
i

hii
1-hii

=

1
p

\widehat{\sigma
(i)

2}{\widehat{\sigma}2}\left(ti(i)\sqrt{

hii
1-hii
}\right)^2 \\&= \frac \cdot \frac \cdot \text^2\end

Di

can be interpreted as the distance one's estimates move within the confidence ellipsoid that represents a region of plausible values for the parameters. 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

Di

has been proposed. Instead of considering the influence a single observation has on the overall model, the statistics

Si

serves as a measure of how sensitive the prediction of the

i

-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

Dj

's of all data points. Again, the projection matrix is involved in the calculation to obtain the required weights:

Si=

n
\sum\left(\widehat{y
j=1
i-{\widehat{y}

i}(j)\right)2}{ps2hii

} = \sum_^n \frac = \sum_^n \rho_^2 \cdot D_j

In this context,

\rhoij

(

\leq1

) resembles the correlation between the predictions

\widehat{y}i

and

\widehat{y}j

.
In contrast to

Di

, the distribution of

Si

is asymptotically normal for large sample sizes and models with many predictors. In absence of outliers the expected value of

Si

is approximately

p-1

. An influential observation can be identified if

\left|Si-\operatorname{med}(S)\right|\geq4.5\operatorname{MAD}(S)

with

\operatorname{med}(S)

as the median and

\operatorname{MAD}(S)

as the median absolute deviation of all

S

-values within the original data set, i.e., a robust measure of location and a robust measure of scale for the distribution of

Si

. The factor 4.5 covers approx. 3 standard deviations of

S

around its centre.
When compared to Cook's distance,

Si

was found to perform well for high- and intermediate-leverage outliers, even in presence of masking effects for which

Di

failed.[11]
Interestingly,

Di

and

Si

are closely related because they can both be expressed in terms of the matrix

T

which holds the effects of the deletion of the

j

-th data point on the

i

-th prediction:

\begin{align} &T=\left[\begin{matrix}\widehat{y}1-{\widehat{y}1

}_ & \widehat_-_ & \widehat_-_ & \cdots & \widehat_-_ & \widehat_-_ \\ \widehat_-_ & \widehat_-_ & \widehat_-_ & \cdots & \widehat_-_ & \widehat_-_ \\ \vdots & \vdots & \vdots &\ddots & \vdots & \vdots \\ \widehat_-_ & \widehat_-_ & \widehat_-_ & \cdots & \widehat_-_ & \widehat_-_ \\ \widehat_-_ & \widehat_-_ & \widehat_-_ & \cdots & \widehat_-_ & \widehat_-_ \end\right] \\ \\&\ \ = \mathbf\mathbf\mathbf = \mathbf \left[\begin{matrix} e_1 & 0 & 0 & \cdots & 0 & 0 \\ 0 & e_2 & 0 & \cdots & 0 & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots & \vdots \\ 0 & 0 & 0 & \cdots & e_{n-1} & 0 \\ 0 & 0 & 0 & \cdots & 0 & e_n \end{matrix}\right] \left[\begin{matrix} \frac 1 {1-h_{11}} & 0 & 0 & \cdots & 0 & 0 \\ 0 & \frac 1 {1-h_{22}} & 0 & \cdots & 0 & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots & \vdots \\ 0 & 0 & 0 & \cdots & \frac 1 {1-h_{n-1,n-1}} & 0 \\ 0 & 0 & 0 & \cdots & 0 & \frac 1 {1-h_{nn}} \end{matrix}\right]\end

With

T

at hand,

D

is given by:

D=\left[\begin{matrix}D1\D2\\vdots\Dn-1\Dn\end{matrix}\right]=

1{ps
2}

\operatorname{diag}\left(TTT\right)=

1
ps2

\operatorname{diag}\left(GEHTHEG\right)=\operatorname{diag}(M)

where

HTH=H

if

H

is symmetric and idempotent, which is not necessarily the case. In contrast,

S

can be calculated as:

\begin{align} &S=\left[\begin{matrix}S1\S2\\vdots\Sn-1\Sn\end{matrix}\right]=

1
ps2

F\operatorname{diag}\left(TTT\right)=

1
ps2

\left[\begin{matrix}

1
h11

&0&0&&0&0\ 0&

1
h22

&0&&0&0\\vdots&\vdots&\vdots&\ddots&\vdots&\vdots\ 0&0&0&&

1
hn-1n-1

&0\ 0&0&0&&0&

1
hnn

\end{matrix}\right]\operatorname{diag}\left(TTT\right)\\\ &  =

1
ps2

F\operatorname{diag}\left(HEGGEHT\right)=F\operatorname{diag}(P) \end{align}

where

\operatorname{diag}(A)

extracts the main diagonal of a square matrix

A

. In this context,

M=p-1s-2GEHTHEG

is referred to as the influence matrix whereas

P=p-1s-2HEGGEHT

resembles the so-called sensitivity matrix. An eigenvector analysis of

M

and

P

- which both share the same eigenvalues – serves as a tool in outlier detection, although the eigenvectors of the sensitivity matrix are more powerful. [12]

Software implementations

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

Language/Program Function Notes
predict, cooksd See https://www.stata.com/manuals/rregresspostestimation.pdf
cooks.distance(model, ...) See https://stat.ethz.ch/R-manual/R-devel/library/stats/html/influence.measures.html
CooksDistance.fit(X, y) See https://www.scikit-yb.org/en/latest/api/regressor/influence.html#cook-s-distance
cooksdistance(model, ...) See https://juliastats.org/GLM.jl/stable/

Extensions

High-dimensional Influence Measure (HIM) is an alternative to Cook's distance for when

p>n

(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

Further reading

Notes and References

  1. Book: Mendenhall . William . Sincich . Terry . A Second Course in Statistics: Regression Analysis . 5th . 1996 . Prentice-Hall . Upper Saddle River, NJ . 0-13-396821-9 . 422 . A measure of overall influence an outlying observation has on the estimated

    \beta

    coefficients was proposed by R. D. Cook (1979). Cook's distance, Di, is calculated....
  2. Cook . R. Dennis . Detection of Influential Observations in Linear Regression . Technometrics . 19 . 1 . 15–18 . February 1977 . . 0436478 . 10.2307/1268249 . 1268249 .
  3. Cook . R. Dennis . Influential Observations in Linear Regression . . 74 . 365 . 169–174 . March 1979 . American Statistical Association . 0529533 . 10.2307/2286747 . 2286747 . 11299/199280 . free .
  4. Book: Hayashi, Fumio . Econometrics . Princeton University Press . 2000 . 21–23 . 1400823838 .
  5. Web site: Cook's Distance.
  6. Web site: Statistics 512: Applied Linear Models . Purdue University . 2016-03-25 . https://web.archive.org/web/20161130150249/http://www.stat.purdue.edu/~jennings/stat514/stat512notes/topic3.pdf#page=9 . 2016-11-30 . dead .
  7. Book: Bollen . Kenneth A. . Kenneth A. Bollen . Jackman . Robert W. . 1990 . Regression Diagnostics: An Expository Treatment of Outliers and Influential Cases . Fox . John . Long . J. Scott Long . J. Scott . Modern Methods of Data Analysis . 266 . Newbury Park, CA . Sage . 0-8039-3366-5 . https://archive.org/details/modernmethodsofd0000unse/page/266 .
  8. Book: Cook . R. Dennis . Weisberg . Sanford . Sanford Weisberg . 1982 . Residuals and Influence in Regression . New York, NY . Chapman & Hall . 0-412-24280-X . 11299/37076.
  9. Myung Geun. Kim. A cautionary note on the use of Cook's distance. Communications for Statistical Applications and Methods. 31 May 2017. 2383-4757. 317–324. 24. 3. 10.5351/csam.2017.24.3.317. free.
  10. https://arxiv.org/abs/2012.14127v3 On deletion diagnostic statistic in regression
  11. Daniel . Peña . A New Statistic for Influence in Linear Regression . Technometrics . 47 . 1 . 1–12 . 2005 . . 10.1198/004017004000000662. 1802937 .
  12. Book: Peña , Daniel . Springer Handbook of Engineering Statistics . 523–536 . Hoang . Pham . 2006 . Springer London . 10.1007/978-1-84628-288-1 . 978-1-84628-288-1 . 60460007 .
  13. https://projecteuclid.org/euclid.aos/1384871348 High-dimensional influence measure