robcv.m

% ------------------------------------------------------------------------
% Function: [rmsecv,YPRED]=robcv(X,y,h,method,lout,pct,delta,iter,mc,sc)
% ------------------------------------------------------------------------
% Aim:
% Cross-validation for Robust Latent Variable Regression
% -----------------------------------------------------------------------
% Inputs:
% X, matrix (n,p), predictor matrix
% y, vector (n,1), predictand
% h, scalar, maximal number of factors
% method, string:
%       'rcr' - Robust Continuum regression) or
%       'prm' - Partial Robust M-Regression
% lout, scalar, number of observations to be left out in each step
% pct, scalar, percentage of trimming (corresponds to the expected
%      fraction of outliers in the data)
% delta, vector (ndelta,1), values of the continuum
%       parameter at which to evaluate the model (must be in [0,1])
%       (only necessary for RCR, fill in any value for PRM)
% iter, scalar, number of iterations to be run for cross validation. If
%       unspecified, leave-fold-out cross-validation is performed. Else,
%       Monte Carlo cross-validation is performed over iter runs leaving
%       out blocks of size fold.
% mc, string, for centring inside the Cross-Validation loops,
%       empty: no centring
%       'cmi': coordinatewise median centring
%       'l1m': L1 median centring
%       If unspecified, it is set to 'l1m'
% sc, string, does internal robust scaling.
%       empty: no scaling
%       'qn': qn scaling
%       'sn': sn scaling
%       'mad': median absolute deviation scaling
% -----------------------------------------------------------------------
% Outputs:
% rmsecv, matrix (h,ndelta), root mean squared error of cross-validation
%         (rows correspond to increasing No.
%         of latent variables; columns correspond to different
%         values of delta)
% YPRED, matrix (h*n,ndelta), contains residuals
%        for n left out samples (blocks of n rows correspond to
%        predictions for an increasing No. of latent variables; colums
%        correspond to different values of delta)
% -----------------------------------------------------------------------
% Example:
% [rmsecv,YPRED]=robcv(X,y,5,'rcr',10,15,[0.1:0.1:0.8],100,'l1m','qn')
% [rmsecv,YPRED]=robcv(X,y,5,'prm',10,15,[],100,'l1m','qn')
% -----------------------------------------------------------------------
% Reference:
% S. Serneels, P. Filzmoser, C. Croux, P. J. Van Espen,
% Robust Continuum Regression, Chemometrics and Intelligent Laboratory
% Systems, 76 (2005) 197-204
Valid CSS! Valid HTML 4.01!