The R_CORRELATE function computes Spearman's (rho) or Kendalls's ( tau) rank correlation of two sample populations X and Y . The result is a two-element vector containing the rank correlation coefficient and the two-sided significance of its deviation from zero. The significance is a value in the interval [0.0, 1.0]; a small value indicates a significant correlation.
where Rx i and Ry i are the magnitude-based ranks among X and Y , respectively. Elements of identical magnitude are ranked using a rank equal to the mean of the ranks that would otherwise be assigned.
This routine is written in the IDL language. Its source code can be found in the file
r_correlate.pro
in the
lib
subdirectory of the IDL distribution.
Set this keyword to a named variable that will contain the sum-squared difference of ranks. If the KENDALL keyword is set, this parameter is returned as zero.
Set this keyword to compute Kendalls's (tau) rank correlation. By default, Spearman's (rho) rank correlation is computed.
Define two n -element sample populations.
X = [257, 208, 296, 324, 240, 246, 267, 311, 324, 323, 263, $
305, 270, 260, 251, 275, 288, 242, 304, 267]
Y = [201, 56, 185, 221, 165, 161, 182, 239, 278, 243, 197, $
271, 214, 216, 175, 192, 208, 150, 281, 196]
Compute Spearman's (rho) rank correlation of X and Y.
Compute Kendalls's (tau) rank correlation of X and Y.
A_CORRELATE , CORRELATE , C_CORRELATE , M_CORRELATE , P_CORRELATE