distances.m

% ------------------------------------------------------------------------
% Function: [rd,sd,crd,csd]=distances(r,T,method,alfa,pct)
% ------------------------------------------------------------------------
% Aim:
% Computes distances in residual and score spaces for PLS, PRM and RCR
% models
% -------------------------------------------------------------------------
% Inputs: 
% r, vector (n,1), squared residuals 
% T, matrix (n,h), scores obtained from PLS, PRM or RCR
% method, string, regression method used to estimate residuals and scores;
%    possible options are:
%   'pls' - Partial Least Squares regression
%   'prm' - Partial Robust M-regression
%   'rcr' - Robust Continuum Regression
% alfa, scalar, confidence level for chi2 distribution (0.95, 0.97. 0.99)
% pct, scalar, optional, if method is 'rcr', percentage of trimming used
% in rcr
% -------------------------------------------------------------------------
% Outputs: 
% rd, vector (n,1), standardized residual distances 
% sd, vector (n,1), score distances
% crd, scalar, cutoff value for residual distance
% csd, scalar, cutoff value for score distance
% -------------------------------------------------------------------------
% Example: 
% [rd,sd,crd,csd]=distances(r,T,'rcr',0.95,20)
% -------------------------------------------------------------------------
% Reference: 
% P.J. Rousseeuw, B. van Zomeren, Journal of the American 
% Statistical Association, 85 (1990) 633-651
Valid CSS! Valid HTML 4.01!