2
$\begingroup$

I have this data for four quantities measured in different temperatures:

data = {{729, 656, 2156, 2035}, {761, 677, 2178, 2060}, {952, 856, 
    2651, 2465}, {888, 796, 2311, 2139}, {747, 645, 1807, 1658}, {863,
     737, 1975, 1817}, {844, 734, 1841, 1654}, {705, 602, 1466, 
    1305}, {788, 686, 1491, 1303}, {927, 779, 1732, 1547}, {910, 742, 
    1616, 1429}};
N[Correlation[data], 2]

There are 11 temperature measurements and 4 quantities measured at the same time. The correlation function gives as output:

{{1.0, 0.95, 0.36, 0.30}, {0.95, 1.0, 0.59, 0.54}, {0.36, 0.59, 1.0, 
  1.0}, {0.30, 0.54, 1.0, 1.0}}

As I understand, the output of Correlation[] gives a matrix of the Pearson coefficient for each element in the data. Is that correct? Does it mean that the first and last entries in each data point have a correlation of 0.30?

$\endgroup$
1
  • 1
    $\begingroup$ That is correct. Using the following is sometimes more readable: Correlation[data] // N // TableForm. $\endgroup$ – JimB Mar 19 at 20:07
1
$\begingroup$
data = {
   {729, 656, 2156, 2035}, {761, 677, 2178, 2060},
   {952, 856, 2651, 2465}, {888, 796, 2311, 2139},
   {747, 645, 1807, 1658}, {863, 737, 1975, 1817},
   {844, 734, 1841, 1654}, {705, 602, 1466, 1305},
   {788, 686, 1491, 1303}, {927, 779, 1732, 1547},
   {910, 742, 1616, 1429}};
matrix = N[Correlation[data], 4];

rules = (N[Correlation @@
       Transpose[data[[All, #]]], 4] -> #) & /@ Tuples[Range[4], {2}];
{1,1} {1,2} {1,3} {1,4}
{1,2} {1,1} {2,3} {2,4}
{1,3} {2,3} {1,1} {3,4}
{1,4} {2,4} {3,4} {1,1}

This grid shows which columns correspond to the correlations in the matrix.

E.g. Grid[matrix]

1.000   0.9504  0.3553  0.3012
0.9504  1.000   0.5918  0.5411
0.3553  0.5918  1.000   0.9977
0.3012  0.5411  0.9977  1.000

0.3012 corresponds to the correlation of columns 1 & 4

N[Correlation @@ Transpose[data[[All, {1, 4}]]], 4]

0.3012

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.