Contenuto principale

rcoplot

Residual case order plot

Description

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

example

rcoplot(ax,r,rInt) plots in the target axes 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.

Input Arguments

collapse all

Residuals, specified as a numeric vector. r must have the same number of rows as rInt.

Data Types: single | double

Confidence intervals, specified as an n-by-2 numeric matrix, where n is the number of rows in r.

Data Types: single | double

Axes for the plot, specified as an Axes object. If you do not specify ax, then rcoplot creates the plot using the current axes. For more information on creating an Axes object, see axes.

Version History

Introduced before R2006a

expand all

See Also