plotSlice

Class: LinearModel

Plot of slices through fitted linear regression surface

Syntax

plotSlice(mdl)
h = plotSlice(mdl)

Description

plotSlice(mdl) creates a new figure containing a series of plots, each representing a slice through the regression surface predicted by mdl. For each plot, the surface slice is shown as a function of a single predictor variable, with the other predictor variables held constant.

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

Tips

  • If there are more than eight predictors, plotSlice selects the first five for plotting. Use the Predictors menu to control which predictors are plotted.

  • The Bounds menu lets you choose between simultaneous or non-simultaneous bounds, and between bounds on the function or bounds on a new observation.

Input Arguments

mdl

Linear model, as constructed by fitlm or stepwiselm.

Output Arguments

h

Vector of handles to lines or patches in the plot.

Examples

expand all

Slice Plot

Plot the slices through a fitted linear model.

Load the carsmall data and fit a linear model of the mileage as a function of model year, weight, and weight squared.

load carsmall
tbl = table(MPG,Weight);
tbl.Year = ordinal(Model_Year);
mdl = fitlm(tbl,'MPG ~ Year + Weight^2');

Create a slice plot.

plotSlice(mdl)

Drag the Weight prediction line to the right and observe the change in the predicted MPG and the response curve for Year.

Was this topic helpful?