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

조회 수: 1 (최근 30일)
Lauren
Lauren 2020년 6월 4일
댓글: Lauren 2020년 6월 4일
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?

채택된 답변

Jeff Miller
Jeff Miller 2020년 6월 4일
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')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by