Английская Википедия:Cook's distance
Шаблон:Short description 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
- <math>\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>\boldsymbol{\varepsilon} \sim \mathcal{N}\left( 0, \sigma^2 \mathbf{I} \right)</math> is the error term, <math>\boldsymbol{\beta} = \left[ \beta_{0} \, \beta_{1} \dots \beta_{p-1} \right]^{\mathsf{T}}</math> is the coefficient matrix, <math>p</math> is the number of covariates or predictors for each observation, and <math>\mathbf{X}</math> is the design matrix including a constant. The least squares estimator then is <math>\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>\mathbf{y}</math> are
- <math>\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>\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>i</math>-th diagonal element of <math>\mathbf{H} \,</math>, given by <math>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>i</math>-th observation. Similarly, the <math>i</math>-th element of the residual vector <math>\mathbf{e} = \mathbf{y} - \mathbf{\widehat{y\,}} = \left( \mathbf{I} - \mathbf{H} \right) \mathbf{y}</math> is denoted by <math>e_i</math>.
Cook's distance <math>D_i</math> of observation <math>i \; (\text{for } i = 1, \dots, n)</math> is defined as the sum of all the changes in the regression model when observation <math>i</math> is removed from it[5]
- <math>
D_i = \frac { \sum_{j=1}^n \left( \widehat{y\,}_j - \widehat{y\,}_{j(i)} \right)^2 } {p s^2} </math>
where p is the rank of the model and <math>\widehat{y\,}_{j(i)}</math> is the fitted response value obtained when excluding <math>i</math>, and <math>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>h_{ii}</math>):
- <math>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>p</math> and <math>n-p</math> (as defined for the design matrix <math>\mathbf{X}</math> above) degrees of freedom, the median point (i.e., <math>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>n</math>, a simple operational guideline of <math>D_i>1</math> has been suggested.[8]
The <math>p</math>-dimensional random vector <math> \mathbf{b} - \mathbf{b \,}_{(i)} </math>, which is the change of <math>\mathbf{b} </math> due to a deletion of the <math>i</math>-th case, has a covariance matrix of rank one and therefore it is distributed entirely over one dimensional subspace (a line) of the <math>p</math>-dimensional space. However, in the introduction of Cook’s distance, a scaling matrix of full rank <math>p</math> is chosen and as a result <math> \mathbf{b} - \mathbf{b \,}_{(i)} </math> is treated as if it is a random vector distributed over the whole space of <math>p</math> 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)
<math>D_i</math> can be expressed using the leverage[5] (<math>0 \leq h_{ii} \leq 1</math>) and the square of the internally Studentized residual (<math>0 \leq t_i^2</math>), as follows:
- <math>
\begin{align} D_i &= \frac{e_i^2}{p s^2} \cdot \frac{h_{ii}}{(1-h_{ii})^2} = \frac{1}{p} \cdot \frac{e_i^2}{{1 \over n-p} \sum_{j=1}^n \widehat{\varepsilon\,}_j^{\,2} (1-h_{ii})} \cdot \frac{h_{ii}}{1-h_{ii}} \\[5pt] &= \frac{1}{p} \cdot t_i^2 \cdot \frac{h_{ii}}{1-h_{ii}} . \end{align} </math>
The benefit in the last formulation is that it clearly shows the relationship between <math>t_i^2</math> and <math>h_{ii}</math> to <math>D_i</math> (while p and n are the same for all observations). If <math>t_i^2</math> is large then it (for non-extreme values of <math>h_{ii}</math>) will increase <math>D_i</math>. If <math>h_{ii}</math> is close to 0 then <math>D_i</math> will be small, while if <math>h_{ii}</math> is close to 1 then <math>D_i</math> will become very large (as long as <math>t_i^2 > 0</math>, i.e.: that the observation <math>i</math> is not exactly on the regression line that was fitted without observation <math>i</math>).
<math>D_i</math> is related to DFFITS through the following relationship (note that <math>{\widehat{\sigma} \over \widehat{\sigma}_{(i)}} t_i = t_{i(i)}</math> is the externally studentized residual, and <math>\widehat{\sigma}, \widehat{\sigma}_{(i)}</math> are defined here):
- <math>
\begin{align} D_i &= \frac 1 p \cdot t_i^2 \cdot \frac{h_{ii}}{1-h_{ii}} \\ &= \frac{1}{p} \cdot \frac{\widehat{\sigma}_{(i)}^2}{\widehat{\sigma}^2} \cdot \frac{\widehat{\sigma}^2}{\widehat{\sigma}_{(i)}^2} \cdot t_i^2 \cdot \frac{h_{ii}}{1-h_{ii}} = \frac{1}{p} \cdot \frac{\widehat{\sigma}_{(i)}^2}{\widehat{\sigma}^2} \cdot \left(t_{i(i)} \sqrt{\frac{h_{ii}}{1-h_{ii}}}\right)^2 \\ &= \frac{1}{p} \cdot \frac{\widehat{\sigma}_{(i)}^2}{\widehat{\sigma}^2} \cdot \text{DFFITS}^2 \end{align} </math>
<math>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.Шаблон:Clarify 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>D_i</math> has been proposed. Instead of considering the influence a single observation has on the overall model, the statistics <math>S_i</math> serves as a measure of how sensitive the prediction of the <math>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>D_{j}</math>'s of all data points. Again, the projection matrix is involved in the calculation to obtain the required weights:
- <math>
S_i = \frac{\sum_{j=1}^n \left(\widehat{y}_i-{\widehat{y}_i}_{(j)}\right)^2}{ps^2 h_{ii}} = \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 </math>
In this context, <math>\rho_{ij}</math> (<math>\leq 1</math>) resembles the correlation between the predictions <math> \widehat{y\,}_i</math> and <math> \widehat{y\,}_j</math>Шаблон:Refn.
In contrast to <math>D_{i}</math>, the distribution of <math>S_{i}</math> is asymptotically normal for large sample sizes and models with many predictors. In absence of outliers the expected value of <math>S_{i}</math> is approximately <math>p^{-1}</math>. An influential observation can be identified if
- <math>
\left| S_i - \operatorname{med}(S) \right| \geq 4.5 \cdot \operatorname{MAD}(S) </math>
with <math>\operatorname{med}(S)</math> as the median and <math>\operatorname{MAD}(S)</math> as the median absolute deviation of all <math>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>S_i</math>. The factor 4.5 covers approx. 3 standard deviations of <math>S</math> around its centre.
When compared to Cook's distance, <math>S_i</math> was found to perform well for high- and intermediate-leverage outliers, even in presence of masking effects for which <math>D_{i}</math> failed.[11]
Interestingly, <math>D_i</math> and <math>S_i</math> are closely related because they can both be expressed in terms of the matrix <math>\mathbf{T}</math> which holds the effects of the deletion of the <math>j</math>-th data point on the <math>i</math>-th prediction:
- <math>
\begin{align} & \mathbf{T} = \left[\begin{matrix} \widehat{y}_{1}-{\widehat{y}_{1}}_{\left(1\right)} & \widehat{y}_{1}-{\widehat{y}_{1}}_{\left(2\right)} & \widehat{y}_{1}-{\widehat{y}_{1}}_{\left(3\right)} & \cdots & \widehat{y}_{1}-{\widehat{y}_{1}}_{\left(n-1\right)} & \widehat{y}_{1}-{\widehat{y}_{1}}_{\left(n\right)} \\ \widehat{y}_{2}-{\widehat{y}_{2}}_{\left(1\right)} & \widehat{y}_{2}-{\widehat{y}_{2}}_{\left(2\right)} & \widehat{y}_{2}-{\widehat{y}_{2}}_{\left(3\right)} & \cdots & \widehat{y}_{2}-{\widehat{y}_{2}}_{\left(n-1\right)} & \widehat{y}_{2}-{\widehat{y}_{2}}_{\left(n\right)} \\ \vdots & \vdots & \vdots &\ddots & \vdots & \vdots \\ \widehat{y}_{n-1}-{\widehat{y}_{n-1}}_{\left(1\right)} & \widehat{y}_{n-1}-{\widehat{y}_{n-1}}_{\left(2\right)} & \widehat{y}_{n-1}-{\widehat{y}_{n-1}}_{\left(3\right)} & \cdots & \widehat{y}_{n-1}-{\widehat{y}_{n-1}}_{\left(n-1\right)} & \widehat{y}_{n-1}-{\widehat{y}_{n-1}}_{\left(n\right)} \\ \widehat{y}_{n}-{\widehat{y}_{n}}_{\left(1\right)} & \widehat{y}_{n}-{\widehat{y}_{n}}_{\left(2\right)} & \widehat{y}_{n}-{\widehat{y}_{n}}_{\left(3\right)} & \cdots & \widehat{y}_{n}-{\widehat{y}_{n}}_{\left(n-1\right)} & \widehat{y}_{n}-{\widehat{y}_{n}}_{\left(n\right)} \end{matrix}\right] \\ \\ &\ \ = \mathbf{H}\mathbf{E}\mathbf{G} = \mathbf{H} \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{align} </math>
With <math>\mathbf{T}</math> at hand, <math>\mathbf{D}</math> is given by:
- <math>
\mathbf{D} = \left[\begin{matrix} D_1 \\ D_2 \\ \vdots \\ D_{n-1} \\ D_n \end{matrix}\right] = \frac 1{ps^2} \operatorname{diag}\left(\mathbf{T}^{\mathsf{T}}\mathbf{T}\right) = \frac 1 {ps^2} \operatorname{diag} \left(\mathbf{G} \mathbf{E} \mathbf{H}^{\mathsf{T}} \mathbf{H} \mathbf{E} \mathbf{G} \right) = \operatorname{diag}(\mathbf{M}) </math>
where <math>\mathbf{H}^{\mathsf{T}}\mathbf{H} = \mathbf{H}</math> if <math>\mathbf{H}</math> is symmetric and idempotent, which is not necessarily the case. In contrast, <math>\mathbf{S}</math> can be calculated as:
- <math>
\begin{align} & \mathbf{S} = \left[\begin{matrix} S_1 \\ S_2 \\ \vdots \\ S_{n-1} \\ S_n \end{matrix}\right] = \frac{1}{ps^2} \mathbf{F} \operatorname{diag} \left(\mathbf{T}\mathbf{T}^{\mathsf{T}}\right) = \frac{1}{ps^2} \left[\begin{matrix} \frac{1}{h_{11}} & 0 & 0 & \cdots & 0 & 0 \\ 0 & \frac{1}{h_{22}} & 0 & \cdots & 0 & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots & \vdots \\ 0 & 0 & 0 & \cdots & \frac{1}{h_{n-1n-1}} & 0 \\ 0 & 0 & 0 & \cdots & 0 & \frac{1}{h_{nn}} \end{matrix}\right] \operatorname{diag} \left(\mathbf{T}\mathbf{T}^{\mathsf{T}}\right) \\ \\ &\ \ = \frac{1}{ps^2} \mathbf{F} \operatorname{diag} \left( \mathbf{H} \mathbf{E} \mathbf{G} \mathbf{G} \mathbf{E} \mathbf{H}^{\mathsf{T}} \right) = \mathbf{F} \operatorname{diag}(\mathbf{P}) \end{align} </math>
where <math>\operatorname{diag}(\mathbf{A})</math> extracts the main diagonal of a square matrix <math>\mathbf{A}</math>. In this context, <math>\mathbf{M} = p^{-1} s^{-2} \mathbf{G} \mathbf{E} \mathbf{H}^{\mathsf{T}} \mathbf{H} \mathbf{E} \mathbf{G}</math> is referred to as the influence matrix whereas <math>\mathbf{P} = p^{-1} s^{-2} \mathbf{H} \mathbf{E} \mathbf{G} \mathbf{G} \mathbf{E} \mathbf{H}^{\mathsf{T}} </math> resembles the so-called sensitivity matrix. An eigenvector analysis of <math>\mathbf{M}</math> and <math>\mathbf{P}</math> - 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 |
---|---|---|
Stata | predict, cooksd |
See [1] |
R | cooks.distance(model, ...) |
See [2] |
Python | CooksDistance().fit(X, y) |
See [3] |
Julia | cooksdistance(model, ...) |
See [4] |
Extensions
High-dimensional Influence Measure (HIM) is an alternative to Cook's distance for when <math>p>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
Notes
References
Further reading
- ↑ Шаблон:Cite book
- ↑ Шаблон:Cite journal
- ↑ Шаблон:Cite journal
- ↑ Шаблон:Cite book
- ↑ 5,0 5,1 5,2 Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite book
- ↑ Шаблон:Cite book
- ↑ Шаблон:Cite journal
- ↑ On deletion diagnostic statistic in regression
- ↑ Шаблон:Cite journal
- ↑ Шаблон:Cite book
- ↑ High-dimensional influence measure