G08 Chapter Contents
G08 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG08DAF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

G08DAF calculates Kendall's coefficient of concordance on $k$ independent rankings of $n$ objects or individuals.

## 2  Specification

 SUBROUTINE G08DAF ( X, LDX, K, N, RNK, W, P, IFAIL)
 INTEGER LDX, K, N, IFAIL REAL (KIND=nag_wp) X(LDX,N), RNK(LDX,N), W, P

## 3  Description

Kendall's coefficient of concordance measures the degree of agreement between $k$ comparisons of $n$ objects, the scores in the $i$th comparison being denoted by
 $xi1,xi2,…,xin.$
The hypothesis under test, ${H}_{0}$, often called the null hypothesis, is that there is no agreement between the comparisons, and this is to be tested against the alternative hypothesis, ${H}_{1}$, that there is some agreement.
The $n$ scores for each comparison are ranked, the rank ${r}_{ij}$ denoting the rank of object $j$ in comparison $i$, and all ranks lying between $1$ and $n$. Average ranks are assigned to tied scores.
For each of the $n$ objects, the $k$ ranks are totalled, giving rank sums ${R}_{j}$, for $j=1,2,\dots ,n$. Under ${H}_{0}$, all the ${R}_{j}$ would be approximately equal to the average rank sum $k\left(n+1\right)/2$. The total squared deviation of the ${R}_{j}$ from this average value is therefore a measure of the departure from ${H}_{0}$ exhibited by the data. If there were complete agreement between the comparisons, the rank sums ${R}_{j}$ would have the values $k,2k,\dots ,nk$ (or some permutation thereof). The total squared deviation of these values is ${k}^{2}\left({n}^{3}-n\right)/12$.
Kendall's coefficient of concordance is the ratio
 $W = ∑ j=1 n Rj - 12 kn+1 2 112 k2 n3-n$
and lies between $0$ and $1$, the value $0$ indicating complete disagreement, and $1$ indicating complete agreement.
If there are tied rankings within comparisons, $W$ is corrected by subtracting $k\sum T$ from the denominator, where $T=\sum \left({t}^{3}-t\right)/12$, each $t$ being the number of occurrences of each tied rank within a comparison, and the summation of $T$ being over all comparisons containing ties.
G08DAF returns the value of $W$, and also an approximation, $p$, of the significance of the observed $W$. (For $n>7,k\left(n-1\right)W$ approximately follows a ${\chi }_{n-1}^{2}$ distribution, so large values of $W$ imply rejection of ${H}_{0}$.) ${H}_{0}$ is rejected by a test of chosen size $\alpha$ if $p<\alpha$. If $n\le 7$, tables should be used to establish the significance of $W$ (e.g., Table R of Siegel (1956)).

## 4  References

Siegel S (1956) Non-parametric Statistics for the Behavioral Sciences McGraw–Hill

## 5  Parameters

1:     X(LDX,N) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{X}}\left(\mathit{i},\mathit{j}\right)$ must be set to the value ${x}_{\mathit{i}\mathit{j}}$ of object $\mathit{j}$ in comparison $\mathit{i}$, for $\mathit{i}=1,2,\dots ,k$ and $\mathit{j}=1,2,\dots ,n$.
2:     LDX – INTEGERInput
On entry: the first dimension of the arrays X and RNK as declared in the (sub)program from which G08DAF is called.
Constraint: ${\mathbf{LDX}}\ge {\mathbf{K}}$.
3:     K – INTEGERInput
On entry: $k$, the number of comparisons.
Constraint: ${\mathbf{K}}\ge 2$.
4:     N – INTEGERInput
On entry: $n$, the number of objects.
Constraint: ${\mathbf{N}}\ge 2$.
5:     RNK(LDX,N) – REAL (KIND=nag_wp) arrayWorkspace
6:     W – REAL (KIND=nag_wp)Output
On exit: the value of Kendall's coefficient of concordance, $W$.
7:     P – REAL (KIND=nag_wp)Output
On exit: the approximate significance, $p$, of $W$.
8:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
 On entry, ${\mathbf{N}}<2$.
${\mathbf{IFAIL}}=2$
 On entry, ${\mathbf{LDX}}<{\mathbf{K}}$.
${\mathbf{IFAIL}}=3$
 On entry, ${\mathbf{K}}\le 1$.

## 7  Accuracy

All computations are believed to be stable. The statistic $W$ should be accurate enough for all practical uses.

The time taken by G08DAF is approximately proportional to the product $nk$.

## 9  Example

This example is taken from page 234 of Siegel (1956). The data consists of $10$ objects ranked on three different variables: X, Y and Z. The computed values of Kendall's coefficient is significant at the $1%$ level of significance $\left(p=0.008<0.01\right)$, indicating that the null hypothesis of there being no agreement between the three rankings X, Y, Z may be rejected with reasonably high confidence.

### 9.1  Program Text

Program Text (g08dafe.f90)

### 9.2  Program Data

Program Data (g08dafe.d)

### 9.3  Program Results

Program Results (g08dafe.r)