1 function r = rankcorr(X,Y)
2 % RANKCORR calculated the rank correlation coefficient.
3 % This function is replaced by CORRCOEF.
4 % Significance test and confidence intervals can be obtained from CORRCOEF, too.
6 % R = CORRCOEF(X, [Y, ] 'Rank');
8 % The rank correlation r = corrcoef(ranks(x)).
9 % is often confused with Spearman's rank correlation.
10 % Spearman's correlation is defined as
11 % r(x,y) = 1-6*sum((ranks(x)-ranks(y)).^2)/(N*(N*N-1))
12 % The results are different. Here, the former version is implemented.
14 % see also: CORRCOEF, SPEARMAN, RANKS
17 % [1] http://mathworld.wolfram.com/SpearmanRankCorrelationCoefficient.html
18 % [2] http://mathworld.wolfram.com/CorrelationCoefficient.html
20 % $Id: rankcorr.m 8223 2011-04-20 09:16:06Z schloegl $
21 % Copyright (C) 2000-2003 by Alois Schloegl <alois.schloegl@gmail.com>
22 % This function is part of the NaN-toolbox
23 % http://pub.ist.ac.at/~schloegl/matlab/NaN/
25 % This program is free software; you can redistribute it and/or modify
26 % it under the terms of the GNU General Public License as published by
27 % the Free Software Foundation; either version 2 of the License, or
28 % (at your option) any later version.
30 % This program is distributed in the hope that it will be useful,
31 % but WITHOUT ANY WARRANTY; without even the implied warranty of
32 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 % GNU General Public License for more details.
35 % You should have received a copy of the GNU General Public License
36 % along with this program; If not, see <http://www.gnu.org/licenses/>.
39 % warning('RANKCORR might become obsolete; use CORRCOEF(ranks(x)) or CORRCOEF(...,''Rank'') instead');
42 r = corrcoef(ranks(X));
44 r = corrcoef(ranks(X),ranks(Y));