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

    %% Determine High Leverage Observations  
% This example shows how to compute |Leverage| values and assess high leverage
% observations.   Load the sample data and define the response and independent
% variables. 

% Copyright 2015 The MathWorks, Inc.

load hospital
y = hospital.BloodPressure(:,1);
X = double(hospital(:,2:5)); 

%% 
% Fit a linear regression model. 
mdl = fitlm(X,y);  

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

%%
% For this example, the recommended threshold value is 2*5/100 = 0.1. There
% is no indication of high leverage observations.