Language Reference


BRANKS Function

BRANKS (matrix);

The BRANKS function computes the tied ranks and the bivariate ranks for an $n \times 2$ matrix and returns an $n \times 3$ matrix of these ranks. The tied ranks of the first column of matrix are contained in the first column of the result matrix; the tied ranks of the second column of matrix are contained in the second column of the result matrix; and the bivariate ranks of matrix are contained in the third column of the result matrix.

The tied rank of an element $x_ j$ of a vector is defined as

\[  \mb{R}_ i = \frac{1}{2} + \sum _ j u(x_ i - x_ j)  \]

where

\[  u(t) = \left\{  \begin{array}{lcl} 1 & &  \mbox{if } t>0 \\ \frac{1}{2} & &  \mbox{if } t=0 \\ 0 & &  \mbox{if } t<0 \end{array} \right.  \]

The bivariate rank of a pair $(x_ j,y_ j)$ is defined as

\[  \mb{Q}_ i = \frac{3}{4} + \sum _ j u(x_ i - x_ j)\,  u(y_ i - y_ j)  \]

The results of the BRANKS function can be used to compute rank-based correlation coefficients such as the Spearman rank-order correlation and Hoeffding’s D statistic.

The following statements compute the bivariate ranks of two columns of data:

z = { 1 2,
      2 1,
      3 3,
      3 5,
      4 4,
      5 4,
      5 4,
      4 5 };

b = branks(z);
print b;

Figure 24.60: Tied Ranks and Bivariate Ranks

b
1 2 1
2 1 1
3.5 3 3
3.5 7.5 3.5
5.5 5 4
7.5 5 4.75
7.5 5 4.75
5.5 7.5 5