How to compute Spearman's rank correlation excluding specific values?
Show older comments
Hello,
I have two matrices A and B (both 20x20) with data from 0 to 1 (some are tied). I want to compute Spearman's rank correlation, but I don't want to include those values which in both matrices are equal to 0 (e.g. A(3,2) and B(3,2) are 0). How can I do that?
2 Comments
the cyclist
on 9 Aug 2017
What correlations do you want? Between corresponding columns of A & B (20 correlations), or all possible pairs of columns (400 correlations)?
Snap
on 9 Aug 2017
Accepted Answer
More Answers (1)
dpb
on 9 Aug 2017
ix=(A>0) & (B>0);
A=A(ix);
B=B(ix);
Do whatever with A, B; they will be returned as column vectors by the logical addressing operation.
Categories
Find more on Correlation and Convolution in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!