MATLAB Answers

Anna
0

Calculating Kendall's tau

Asked by Anna
on 3 Aug 2013
Hi, I'm trying to calculate Kendall's tau using the 'corrcoef' command. My code so far is:
A_col = A_short'
idx = find(~isnan(B)+~isnan(A_col)==2);
[RHO,PVAL] = corrcoef(B(idx),A_col(idx),'type',Kendall)
The last line produces the error 'Undefined function or variable 'Kendall'. According to matlab help this is a valid value so how can I specify that I want a Kendall tau correaltion as oposed to a Pearson correlation?
Please help. Thanks

  0 Comments

Sign in to comment.

1 Answer

Answer by Wayne King
on 3 Aug 2013
Edited by Wayne King
on 3 Aug 2013
 Accepted Answer

Hi Anna, 'Kendall' is not an option of corrcoef(). It is an option for the function corr(), which is part of the Statistics Toolbox.
So, this will work:
x = randn(30,4);
y = randn(30,4);
y(:,4) = sum(x,2);
[r,p] = corr(x,y,'type','Kendall');
provided you have the Statistics Toolbox

  1 Comment

Hi Wayne, thank you that works brilliantly! I was worried that using corr instead of corrcoef would give me a huge matrix of r and p values but there's only one thankfully! Cheers :)

Sign in to comment.