Cook's distance

From testwiki
Jump to navigation Jump to search

Template: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

๐ฒnร—1=๐—nร—p๐œทpร—1+๐œบnร—1

where ๐œบโˆผ๐’ฉ(0,ฯƒ2๐ˆ) is the error term, ๐œท=[ฮฒ0ฮฒ1ฮฒpโˆ’1]๐–ณ is the coefficient matrix, p is the number of covariates or predictors for each observation, and ๐— is the design matrix including a constant. The least squares estimator then is ๐›=(๐—๐–ณ๐—)โˆ’1๐—๐–ณ๐ฒ, and consequently the fitted (predicted) values for the mean of ๐ฒ are

๐ฒ^=๐—๐›=๐—(๐—๐–ณ๐—)โˆ’1๐—๐–ณ๐ฒ=๐‡๐ฒ

where ๐‡โ‰ก๐—(๐—๐–ณ๐—)โˆ’1๐—๐–ณ is the projection matrix (or hat matrix). The i-th diagonal element of ๐‡, given by hiiโ‰ก๐ฑi๐–ณ(๐—๐–ณ๐—)โˆ’1๐ฑi,[4] is known as the leverage of the i-th observation. Similarly, the i-th element of the residual vector ๐ž=๐ฒโˆ’๐ฒ^=(๐ˆโˆ’๐‡)๐ฒ is denoted by ei.

Cook's distance Di of observation i(for i=1,,n) is defined as the sum of all the changes in the regression model when observation i is removed from it[5]

Di=โˆ‘j=1n(y^jโˆ’y^j(i))2ps2

where p is the rank of the model (i.e., number of independent variables in the design matrix) and y^j(i) is the fitted response value obtained when excluding i, and s2=๐žโŠค๐žnโˆ’p is the mean squared error of the regression model.[6]

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

Di=ei2ps2[hii(1โˆ’hii)2].

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 ๐— 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 ๐›โˆ’๐›(i), which is the change of ๐› 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 ๐›โˆ’๐›(i) mentioned above implies that information about the influence of the i-th observation provided by ๐›โˆ’๐›(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 ๐›โˆ’๐›(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 ๐›โˆ’๐›(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โ‰คhiiโ‰ค1) and the square of the internally Studentized residual (0โ‰คti2), as follows:

Di=ei2ps2โ‹…hii(1โˆ’hii)2=1pโ‹…ei21nโˆ’pโˆ‘j=1nฮต^j2(1โˆ’hii)โ‹…hii1โˆ’hii=1pโ‹…ti2โ‹…hii1โˆ’hii.

The benefit in the last formulation is that it clearly shows the relationship between ti2 and hii to Di (while p and n are the same for all observations). If ti2 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 ti2>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 ฯƒ^ฯƒ^(i)ti=ti(i) is the externally studentized residual, and ฯƒ^,ฯƒ^(i) are defined here):

Di=1pโ‹…ti2โ‹…hii1โˆ’hii=1pโ‹…ฯƒ^(i)2ฯƒ^2โ‹…ฯƒ^2ฯƒ^(i)2โ‹…ti2โ‹…hii1โˆ’hii=1pโ‹…ฯƒ^(i)2ฯƒ^2โ‹…(ti(i)hii1โˆ’hii)2=1pโ‹…ฯƒ^(i)2ฯƒ^2โ‹…DFFITS2

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.Template: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 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=โˆ‘j=1n(y^iโˆ’y^i(j))2ps2hii=โˆ‘j=1nhij2โ‹…Djhiiโ‹…hjj=โˆ‘j=1nฯij2โ‹…Dj

In this context, ฯij (โ‰ค1) resembles the correlation between the predictions y^i and y^jTemplate:Refn.
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

|Siโˆ’med(S)|โ‰ฅ4.5โ‹…MAD(S)

with med(S) as the median and 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 ๐“ which holds the effects of the deletion of the j-th data point on the i-th prediction:

๐“=[y^1โˆ’y^1(1)y^1โˆ’y^1(2)y^1โˆ’y^1(3)โ‹ฏy^1โˆ’y^1(nโˆ’1)y^1โˆ’y^1(n)y^2โˆ’y^2(1)y^2โˆ’y^2(2)y^2โˆ’y^2(3)โ‹ฏy^2โˆ’y^2(nโˆ’1)y^2โˆ’y^2(n)โ‹ฎโ‹ฎโ‹ฎโ‹ฑโ‹ฎโ‹ฎy^nโˆ’1โˆ’y^nโˆ’1(1)y^nโˆ’1โˆ’y^nโˆ’1(2)y^nโˆ’1โˆ’y^nโˆ’1(3)โ‹ฏy^nโˆ’1โˆ’y^nโˆ’1(nโˆ’1)y^nโˆ’1โˆ’y^nโˆ’1(n)y^nโˆ’y^n(1)y^nโˆ’y^n(2)y^nโˆ’y^n(3)โ‹ฏy^nโˆ’y^n(nโˆ’1)y^nโˆ’y^n(n)]  =๐‡๐„๐†=๐‡[e100โ‹ฏ000e20โ‹ฏ00โ‹ฎโ‹ฎโ‹ฎโ‹ฑโ‹ฎโ‹ฎ000โ‹ฏenโˆ’10000โ‹ฏ0en][11โˆ’h1100โ‹ฏ00011โˆ’h220โ‹ฏ00โ‹ฎโ‹ฎโ‹ฎโ‹ฑโ‹ฎโ‹ฎ000โ‹ฏ11โˆ’hnโˆ’1,nโˆ’10000โ‹ฏ011โˆ’hnn]

With ๐“ at hand, ๐ƒ is given by:

๐ƒ=[D1D2โ‹ฎDnโˆ’1Dn]=1ps2diag(๐“๐–ณ๐“)=1ps2diag(๐†๐„๐‡๐–ณ๐‡๐„๐†)=diag(๐Œ)

where ๐‡๐–ณ๐‡=๐‡ if ๐‡ is symmetric and idempotent, which is not necessarily the case. In contrast, ๐’ can be calculated as:

๐’=[S1S2โ‹ฎSnโˆ’1Sn]=1ps2๐…diag(๐“๐“๐–ณ)=1ps2[1h1100โ‹ฏ0001h220โ‹ฏ00โ‹ฎโ‹ฎโ‹ฎโ‹ฑโ‹ฎโ‹ฎ000โ‹ฏ1hnโˆ’1nโˆ’10000โ‹ฏ01hnn]diag(๐“๐“๐–ณ)  =1ps2๐…diag(๐‡๐„๐†๐†๐„๐‡๐–ณ)=๐…diag(๐)

where diag(๐€) extracts the main diagonal of a square matrix ๐€. In this context, ๐Œ=pโˆ’1sโˆ’2๐†๐„๐‡๐–ณ๐‡๐„๐† is referred to as the influence matrix whereas ๐=pโˆ’1sโˆ’2๐‡๐„๐†๐†๐„๐‡๐–ณ resembles the so-called sensitivity matrix. An eigenvector analysis of ๐Œ and ๐ - 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 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

Notes

Template:Reflist

References

Template:Reflist

Further reading