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

    %% Determine Influential Observations Using CovRatio  
% This example shows how to use the |CovRatio| statistics to determine the
% influential points in data.   Load the sample data and define the response
% and predictor 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 |CovRatio| statistics. 
plotDiagnostics(mdl,'CovRatio')    

%%
% For this example, the threshold limits are 1 + 3*5/100 = 1.15 and 1 -
% 3*5/100 = 0.85. There are a few points beyond the limits, which might
% be influential points.  

%% 
% Find the observations that are beyond the limits. 
find((mdl.Diagnostics.CovRatio)>1.15|(mdl.Diagnostics.CovRatio)<0.85)