Documentation Center

  • Trial Software
  • Product Updates

plotEffects

Class: LinearModel

Plot main effects of each predictor in linear regression model

Syntax

plotEffects(mdl)
h = plotEffects(mdl)

Description

plotEffects(mdl) produces an effects plot for the predictors in the mdl regression model. The plot shows the estimated effect on the response from changing each predictor value, averaging out the effects of the other predictors. plotEffects chooses values to produce a relatively large effect on the response.

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

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

Linear model, as constructed by fitlm or stepwiselm.

Output Arguments

h

Vector of handles to lines or patches in plot. h(1) is a handle to the circles that represent the main effect estimates. h(j+1) is a handle to the line that defines the confidence interval for the effect of predictor j.

Examples

expand all

Effects Plot

Plot the effects of two predictors in 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
ds = dataset(MPG,Weight);
ds.Year = ordinal(Model_Year);
mdl = fitlm(ds,'MPG ~ Year + Weight^2');

Create an effects plot.

plotEffects(mdl)

The width of each horizontal line in the figure shows a confidence interval for the effect on the response of the listed change in each predictor. The estimated effect of changing Year from 70 to 82 is an increase of about 8, and is between 6 and 10 with 95% confidence.

Alternatives

Use plotInteraction for an effects plot of the interactions of two specified variables.

See Also

| |

How To

Was this topic helpful?