Documentation

plotSlice

Class:CompactLinearModel

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

Input Arguments

expand all

Linear model object, specified as a fullLinearModelobject constructed usingfitlmorstepwiselm, or a compactedCompactLinearModelobject constructed usingcompact.

Output Arguments

expand all

Graphics handles, returned as a vector of graphics handles corresponding to the lines or patches in the plot.

Examples

expand all

Plot the slices through a fitted linear model.

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

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

Create a slice plot.

plotSlice(mdl)

Drag theWeightprediction line to the right and observe the change in the predictedMPGand the response curve forYear.

Tips

  • If there are more than eight predictors,plotSliceselects the first five for plotting. Use thePredictorsmenu to control which predictors are plotted.

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

Was this topic helpful?