1

I have some vectors, for example, let´s call them a, b and c. All of them have the same size. I want to get the correlation between a and c, b and c.

I have tried that:

[rho1,pval1]=corr(a,c,'rows','complete')
[rho2,pval2]=corr(b,c,'rows','complete')


rho1=0.1054
pval1=0.2918
rho2=0.1174
pval2=0.2473


And I have thought that the results were OK, but later I have tried that:
[rho,pval]=corr([a b],c,'rows','complete')

And have given me different results:


rho=
0.1168
0.1150

pval=
0.2649
0.2726


Matlab´s help says that these function returns a p1-by-p2 matrix containing the pairwise correlation coefficient between each pair of columns in the n-by-p1 and n-by-p2 matrices X and Y.

What am I doing wrong? Thanks.

Note: The vectors are 289x1, so I can´t write them here.

user1297712
  • 73
  • 2
  • 7
  • What results did you get? Can you post a short sample of your data, and the results of applying the operations above on that data? How does the output differ from what you expected? – Li-aung Yip Mar 28 '12 at 09:36
  • 1
    Additionally I think what you really want is `corr([a b c])`, which will give you a 3x3 matrix of pairwise correlation coefficients. – Li-aung Yip Mar 28 '12 at 09:38
  • SOLVED.The problem is that these vector have NaN's so the option 'complete' only takes the rows where there are no NaN's.If a vector (for example b) have a NaN will affect to the results of both correlations (a and b). The option that I need is 'pairwise'. Thanks – user1297712 Mar 28 '12 at 14:21
  • If this question is solve, then please write up the solution as an answer and accept it. – slayton Apr 24 '12 at 22:26

1 Answers1

1

SOLVED.The problem is that these vector have NaN's so the option 'complete' only takes the rows where there are no NaN's.If a vector (for example b) have a NaN will affect to the results of both correlations (a and b). The option that I need is 'pairwise'. Thanks

user1297712
  • 73
  • 2
  • 7