www.gusucode.com > stats 源码程序 matlab案例代码 > stats/LeveragePlotofLinearModelExample.m

    %% Leverage Plot of Linear Model  
% Plot the leverage values of observations in a fitted 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
tbl = table(MPG,Weight);
tbl.Year = categorical(Model_Year);
mdl = fitlm(tbl,'MPG ~ Year + Weight^2');  

%% 
% Plot the leverage values. 
plotDiagnostics(mdl)     

%% 
% Plot the Cook's distance. 
plotDiagnostics(mdl,'cookd')    

%%
% The two diagnostic plots give different results.