How to find 2d spearman and kendall correlations using corr2?

4 visualizaciones (últimos 30 días)
Lauren
Lauren el 4 de Jun. de 2020
Comentada: Lauren el 4 de Jun. de 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?

Respuesta aceptada

Jeff Miller
Jeff Miller el 4 de Jun. de 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')

Más respuestas (0)

Categorías

Más información sobre Descriptive Statistics en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by