This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Cook’s Distance


Cook’s distance is useful for identifying outliers in the X values (observations for predictor variables). It also shows the influence of each observation on the fitted response values. An observation with Cook’s distance larger than three times the mean Cook’s distance might be an outlier.


Cook’s distance is the scaled change in fitted values. Each element in CooksDistance is the normalized change in the vector of coefficients due to the deletion of an observation. The Cook’s distance, Di, of observation i is



  • y^j is the jth fitted response value.

  • y^j(i) is the jth fitted response value, where the fit does not include observation i.

  • MSE is the mean squared error.

  • p is the number of coefficients in the regression model.

Cook’s distance is algebraically equivalent to the following expression:


where ri is the ith residual, and hii is the ith leverage value.

CooksDistance is an n-by-1 column vector in the Diagnostics table of the LinearModel object.

How To

After obtaining a fitted model, say, mdl, using fitlm or stepwiselm, you can:

  • Display the Cook’s distance values by indexing into the property using dot notation,


  • Plot the Cook’s distance values using

    For details, see the plotDiagnostics method of the LinearModel class.

Determine Outliers Using Cook's Distance

This example shows how to use Cook's Distance to determine the outliers in the data.

Load the sample data and define the independent and response variables.

load hospital
X = double(hospital(:,2:5));
y = hospital.BloodPressure(:,1);

Fit the linear regression model.

mdl = fitlm(X,y);

Plot the Cook's distance values.


The dashed line in the figure corresponds to the recommended threshold value, 3*mean(mdl.Diagnostics.CooksDistance). The plot has some observations with Cook's distance values greater than the threshold value, which for this example is 3*(0.0108) = 0.0324. In particular, there are two Cook's distance values that are relatively higher than the others, which exceed the threshold value. You might want to find and omit these from your data and rebuild your model.

Find the observations with Cook's distance values that exceed the threshold value.

ans = 10×1


Find the observations with Cook's distance values that are relatively larger than the other observations with Cook's distances exceeding the threshold value.

ans = 2×1



[1] Neter, J., M. H. Kutner, C. J. Nachtsheim, and W. Wasserman. Applied Linear Statistical Models. 4th ed. Chicago: Irwin, 1996.

See Also

| | |

Related Topics