www.gusucode.com > stats 源码程序 matlab案例代码 > stats/PredictionCurveInteractionPlotforLinearModelExample.m
%% Prediction Curve Interaction Plot for Linear Model % 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. load carsmall tbl = table(MPG,Weight); tbl.Year = ordinal(Model_Year); var1 = 'Year'; var2 = 'Weight'; mdl = fitlm(tbl,'MPG ~ Year * Weight^2'); %% % 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.