dear group,
I try to compute the corr.coeff. of a datamatrix X|Y.
I use three methods at the moment to calculate this for an example datamatrix:
XY:
matrix([8.5,5.2],[13.7,8.3],[15,9.4],[16,9.5],[16.9,9.6],[15.1,9.4],[13.9,8.8],[12,7.3]);
[1] use package 'descriptive' and functions mean() and std()
to z-transform the data X and Y and than do:
rXY : (zX.zY)/length(X);
==> 0.979
[2] use the cov-matrix of package 'descriptive'
and write a selfmade function:
corr_coef(XY) := block([cv: cov(XY)], cv[1,2]/sqrt(cv[1,1]*cv[2,2]);
corr_coef(XY), numer;
==> 0.979
[3] use package 'stats'
and look into the output of 'simple_linear_regression':
load("stats");
simple_linear_regression(XY,'conflevel=0.99);
===> 0.979
Here are my questions:
Q1: what is the most simple method to transform the splitted data
X:[8.5,13.7,15,16,16.9,15.1,13.9,12];
Y:[5.2,8.3,9.4,9.5,9.6,9.4,8.8,7.3];
into the above data_matrix_ XY as input for cov()?
Q2: is there a 'corr.ceff?'-function already implemented I have overlooked?
What method is to be prefered in your opinion?
Any hints are very welcome.
HTH Wolfgang