Main Content

rcoplot

Residual case order plot

Syntax

rcoplot(r,rint)
rcoplot(ax,r,rint)

Description

rcoplot(r,rint) displays an error bar plot of the confidence intervals on the residuals from a regression. The residuals appear in the plot in case order.

rcoplot(ax,r,rint) plots into the axes specified by ax instead of the current axes (gca). (since R2024a)

Examples

collapse all

Plot a residual case order plot by using the rcoplot function. This type of plot can help you identify outliers.

Load the moore data set, which contains the biochemical oxygen demand on five predictors.

load moore

Fit a linearly additive regression model to the data by using the regress function.

X = [ones(size(moore,1),1) moore(:,1:5)];
y = moore(:,6);
alpha = 0.05;
[beta,betaInt,residual,residualInt,stats] = regress(y,X,alpha);

Plot the residuals and prediction intervals from the model.

rcoplot(residual,residualInt)

Figure contains an axes object. The axes object with title Residual Case Order Plot, xlabel Case Number, ylabel Residuals contains 5 objects of type line. One or more of the lines displays its values using only markers These objects represent Outlier Intervals, Outlier Residuals, Intervals, Residuals.

The interval around the first residual, shown in red, does not contain zero. This result indicates that the residual is larger than expected in 95% of new observations, and suggests that the data point is an outlier.

Version History

Introduced before R2006a

expand all

See Also