How to find 2d spearman and kendall correlations using corr2?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Lauren
am 4 Jun. 2020
Kommentiert: Lauren
am 4 Jun. 2020
I've been using corr2 to find correlation between two arrays. It calculates Pearson correlation.
I was hoping to repeat the code using Spearman or Kendall. Documentation doesn't mention the option to change type, but I tried anyway. Error says there are too many inputs.
A=[ 3 4 3; 0 3 0; 1 5 7];
B=[ 3 4 3; 0 3 0; 1 5 7];
C=corr2(A,B, 'Type', 'Kendall' );
Error using corr2>ParseInputs (line 30)
Too many input arguments.
Error in corr2 (line 21)
[a,b] = ParseInputs(varargin{:});
C=corr2(A,B) works just fine.
Does anyone know if it's possible to find Spearman or Kendall 2d correlation using corr2? If not, any suggestions?
0 Kommentare
Akzeptierte Antwort
Jeff Miller
am 4 Jun. 2020
corr2 is doing the same computation as corr, except that it allows 2d inputs rather than 1d. So, you can get your Spearman or Kendall correlation using corr with the 'type' option, but pretending you have 1d rather than 2d inputs, e.g.
spear = corr(A(:),B(:),'type','Spearman')
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Descriptive Statistics finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!