plotInteraction(mdl,var1,var2) plotInteraction(mdl,var1,var2,ptype) h = plotInteraction(...)

Description

plotInteraction(mdl,var1,var2) creates
a plot of the interaction effects of the predictors var1 and var2 in mdl.
The plot shows the estimated effect on the response from changing
each predictor value, averaging out the effects of the other predictors.
The plot also shows the estimated effect with the other predictor
fixed at certain values. plotInteraction chooses
values to produce a relatively large effect on the response. The plot
lets you examine whether the effect of one predictor depends on the
value of the other predictor.

plotInteraction(mdl,var1,var2,ptype) returns
a plot of the type specified in ptype.

h = plotInteraction(...) 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.

String naming the variable for plot. plotInteraction chooses
values of var1 to create relatively large changes
in the response. When you set ptype = 'predictions',
the plot shows curves as a function of var2 with
various fixed values of var1.

var2

String naming the variable for plot. plotInteraction chooses
values of var2 to create relatively large changes
in the response. When you set ptype = 'predictions',
the plot shows curves as a function of var2 various
fixed values of var1.

ptype

String naming the plot type.

'effects' — The plot shows
each effect as a circle, with a horizontal bar showing the confidence
interval for the estimated effect. plotInteraction computes
the effect values from the adjusted response curve, as shown by the plotAdjustedResponse function.

'predictions' — The plot
shows the adjusted response curve as a function of var2,
with var1 fixed at certain values.

Default: 'effects'

Output Arguments

h

Vector of handles to lines or patches in the plot.

The plot might show an interaction, because the groups of points
are not perfectly vertical. But the error bars seem large enough that
a vertical line could pass within all of the confidence intervals
for each group, possibly indicating no interaction.

Create a model of car mileage as a function
of weight and model year. Then create an interaction curve plot to
see if the predictors have interactions.

Create a linear model of mileage from the carsmall data.

Create an interaction plot with type 'predictions'.

plotInteraction(mdl,var1,var2,'predictions')

The curves are not parallel. This indicates interactions between
the predictors. The effect is subtle enough not to definitively indicate
a interaction.