{CORREL.TLS Prozeduren und Funktionen: function pearson_corr_koeff(x,y:DatVectorType_TLS):real; function spearman(x,y:DatVectorType_TLS):real; procedure corr_mat(x,y:DatMatrixType_TLS;VAR corr_mat:RealMatrixType_TLS); function fisher_z_tr(r:real;inv:boolean):real; procedure corr_w_test(r:real;n:integer;roh0:real;VAR tg:real;VAR f:integer); function mult_corr(rxy:RealVectorType_TLS;ryy:RealMatrixType_TLS; n:integer;VAR tg:real;VAR f1,f2:integer):real; } function pearson_corr_koeff(x,y:DatVectorType_TLS):real; const err_pos=''; var x_var,y_var,dummy:real; begin average(x,ari,dummy,x_var,dummy,dummy,dummy); average(y,ari,dummy,y_var,dummy,dummy,dummy); dummy:=x_var*y_var; if dummy>NULL then pearson_corr_koeff:=covariance(x,y)/sqrt(dummy) else error(3,err_pos) end; function spearman(x,y:DatVectorType_TLS):real; var i,j,k:integer; begin rank_class(x,x);rank_class(y,y); spearman:=pearson_corr_koeff(x,y) end; procedure corr_mat(x,y:DatMatrixType_TLS;VAR corr_mat:RealMatrixType_TLS); var i,j; begin corr_mat.p:=x.p;corr_mat.q:=y.p; for i:=1 to x.p do for j:=1 to y.p do corr_mat.elt[i,j]:=pearson_corr_koeff(x.line[i],y.line[j]) end; function fisher_z_tr(r:real;inv:boolean):real; const err_pos=''; begin if inv then fisher_z_tr:=(exp(2*r)-1)/(exp(2*r)+1) else if 1-abs(r)>NULL then fisher_z_tr:=ln((1+r)/(1-r))/2 else error(2,err_pos) end; procedure corr_w_test(r:real;n:integer;roh0:real;VAR tg:real;VAR f:integer); const err_pos=''; begin if(1-abs(r)>NULL)and(n>3) then if abs(roh0)<=NULL then begin tg:=r*sqrt(n-2)/sqrt(1-r*r); f:=n-2; end else tg:=abs((fisher_z_tr(r,false)-fisher_z_tr(roh0,false)-roh0/(2*(n-1)))*sqrt(n-3)) else error(3,err_pos) end; function mult_corr(rxy:RealVectorType_TLS;ryy:RealMatrixType_TLS; n:integer;VAR tg:real;VAR f1,f2:integer):real; const err_pos=''; var p:integer; help:real; begin p:=ryy.p; invert_mat(ryy.elt,p); help:=vec_mat_vec_prod(rxy,ryy); if help>NULL then begin mult_corr:=sqrt(help); if abs(1-help)>NULL then tg:=(n-p-1)*help/(p*(1-help)) else error(2,err_pos); f1:=p; f2:=n-p-1; end else error(3,err_pos) end;