Adjusted response plot for linear regression model
h = plotAdjustedResponse(mdl,var)
h = plotAdjustedResponse(mdl,var,Name,Value)
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.
mdl— Full, fitted linear regression model
var— Variable for adjusted response plot
Variable for adjusted response plot, specified as a variable
name or an integer value representing the index of a variable in
Specify optional comma-separated pairs of
Name is the argument
Value is the corresponding
Name must appear
inside single quotes (
You can specify several name and value pair
arguments in any order as
The plot property name-value pairs apply to the first returned
'Color'— Color of line or marker
'LineStyle'— Line style
Chart Line Propertiesspecification
'LineWidth'— Width of line or edges
Width of the line or edges of filled area, in points, specified
as the comma-separated pair consisting of
a positive numeric value. One point is equal to 1/72 inch.
'MarkerEdgeColor'— Color of marker or edge
'MarkerFaceColor'— Color of marker face
'MarkerSize'— Size of marker
Size of the marker in points, specified as the comma-separated
pair consisting of
'MarkerSize' and a positive
numeric value. One point is 1/72 inch.
h— Graphics handles
Graphics handles, returned as a vector of graphics handles corresponding to the lines or patches in the plot.
The adjusted response plot shows the fitted response as a function
var, with the other predictors averaged out
by averaging the fitted values over the data used in the fit. Adjusted
data points are computed by adding the residual to the adjusted fitted
value for each observation.
Plot the adjusted responses of a fitted linear model.
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 = categorical(Model_Year); mdl = fitlm(tbl,'MPG ~ Year + Weight^2');
Plot the effect of
'Weight' averaged over
Plot the effect of
Year averaged over
'Weight' values. Include the
h = plotAdjustedResponse(mdl,'Year');
Change the adjusted data to black
x instead of red
h(1).Marker = 'x'; h(1).Color = 'k';