MATLAB: Is it possible to compute Spearman’s rank correlation in MATLAB

correlationrankspearmanStatistics and Machine Learning Toolbox

I would like to compute Spearman's rank correlation using MATLAB or the Statistics Toolbox.

Best Answer

In the Statistics Toolbox 5.0 (R14), the CORR function can compute Spearman's rank correlation. The syntax is as follows:
rho = corr(X, Y, 'type', 'Spearman');
where 'type' is a type of correlation, specified as the comma-separated. The acceptable values include 'Pearson', 'Kendall' and 'Spearman'. Please refer to the following link for more information:
For previous product releases, please read below for any possible workarounds:
You can easily code the Spearman rank correlation, however, using the existing functions from the Statistics Toolbox.
Here are some functions that will assist you:
TIEDRANK Compute the ranks of a sample, adjusting for ties
CORRCOEF Computes the Correlation coefficients