plotResiduals

Class: NonLinearModel

Plot residuals of nonlinear regression model

Syntax

plotResiduals(mdl)
plotResiduals(mdl,plottype)
h = plotResiduals(...)
h = plotResiduals(mdl,plottype,Name,Value)

Description

plotResiduals(mdl) gives a histogram plot of the residuals of the mdl nonlinear model.

plotResiduals(mdl,plottype) plots residuals in a plot of type plottype.

h = plotResiduals(...) returns handles to the lines in the plot.

h = plotResiduals(mdl,plottype,Name,Value) plots with additional options specified by one or more Name,Value pair arguments.

Tips

  • 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.

Input Arguments

mdl

Nonlinear regression model, constructed by fitnlm.

plottype

String specifying the type of plot:

'caseorder'Residuals vs. case (row) order
'fitted'Residuals vs. fitted values
'histogram'Histogram
'lagged'Residuals vs. lagged residual (r(t) vs. r(t–1))
'probability'Normal probability plot
'symmetry'Symmetry plot

Default: 'histogram'

Name-Value Pair Arguments

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.

    Note:   The plot property name-value pairs apply to the first returned handle h(1).

'Color'

Color of the line or marker, a string or ColorSpec specification. For details, see linespec.

'LineStyle'

Type of line, a string or Chart Line Properties 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.

'ResidualType'

Type of residual used in the plot:

'Raw'Observed minus fitted values
'Pearson'Raw residuals divided by RMSE
'Standardized'Raw residuals divided by their estimated standard deviation
'Studentized'Raw residuals divided by an independent (delete-1) estimate of their standard deviation

Default: 'Raw'

Output Arguments

h

Vector of handles to lines or patches in the plot.

Examples

expand all

Residual Plot

Plot the residuals of a fitted nonlinear model.

Load the reaction data and fit a model of the reaction rate as a function of reactants.

load reaction
mdl = fitnlm(reactants,rate,@hougen,[1 .05 .02 .1 2]);

Plot the residuals of the fitted model.

plotResiduals(mdl)

Residual Probability Plot

Create a normal probability plot of the residuals of a fitted nonlinear model.

Load the reaction data and fit a model of the reaction rate as a function of reactants.

load reaction
mdl = fitnlm(reactants,rate,@hougen,[1 .05 .02 .1 2]);

Create a normal probability plot of the residuals of the fitted model.

plotResiduals(mdl,'probability')

Was this topic helpful?