Documentation Center |
plotDiagnostics(mdl)
plotDiagnostics(mdl,plottype)
h = plotDiagnostics(...)
h = plotDiagnostics(mdl,plottype,Name,Value)
plotDiagnostics(mdl) plots diagnostics from the mdl linear model using scaled delete-1 fitted values.
plotDiagnostics(mdl,plottype) plots diagnostics in a plot of type plottype.
h = plotDiagnostics(...) returns handles to the lines in the plot.
h = plotDiagnostics(mdl,plottype,Name,Value) plots with additional options specified by one or more Name,Value pair arguments.
For many plots, the Data Cursor tool in the figure window displays the x and y values for any data point, along with the observation name or number.
mdl |
Linear model, as constructed by fitlm or stepwiselm. | ||||||||||||||
plottype |
String specifying the type of plot:
Delete-1 means compute a new model without the current observation. If the delete-1 calculation differs significantly from the model using all observations, then the observation is influential. Default: 'leverage' |
Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.
'Color' |
Color of the line or marker, a string or ColorSpec specification. For details, see linespec. |
'LineStyle' |
Type of line, a string or lineseriesproperties specification. For details, see linespec. |
'LineWidth' |
Width of the line or edges of filled area, in points, a positive scalar. One point is 1/72 inch. Default: 0.5 |
'MarkerEdgeColor' |
Color of the marker or edge color for filled markers, a string or ColorSpec specification. For details, see linespec. |
'MarkerFaceColor' |
Color of the marker face for filled markers, a string or ColorSpec specification. For details, see linespec. |
'MarkerSize' |
Size of the marker in points, a strictly positive scalar. One point is 1/72 inch. |
The hat matrix H is defined in terms of the data matrix X:
H = X(X^{T}X)^{–1}X^{T}.
The diagonal elements H_{ii} satisfy
where n is the number of observations (rows of X), and p is the number of coefficients in the regression model.
The leverage of observation i is the value of the ith diagonal term, h_{ii}, of the hat matrix H. Because the sum of the leverage values is p (the number of coefficients in the regression model), an observation i can be considered to be an outlier if its leverage substantially exceeds p/n, where n is the number of observations.
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, D_{i}, of observation i is
where
is the jth fitted response value.
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 r_{i} is the ith residual, and h_{ii} is the ith leverage value.
CooksDistance is an n-by-1 column vector in the Diagnostics table of the LinearModel object.
[1] Neter, J., M. H. Kutner, C. J. Nachtsheim, and W. Wasserman. Applied Linear Statistical Models, Fourth Edition. Irwin, Chicago, 1996.
The mdl.Diagnostics property contains the information that plotDiagnostics uses to create plots.