# NAG FL Interfaceg08daf (concordance_​kendall)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

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

## 2Specification

Fortran Interface
 Subroutine g08daf ( x, ldx, k, n, rnk, w, p,
 Integer, Intent (In) :: ldx, k, n Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: x(ldx,n) Real (Kind=nag_wp), Intent (Inout) :: rnk(ldx,n) Real (Kind=nag_wp), Intent (Out) :: w, p
C Header Interface
#include <nag.h>
 void g08daf_ (const double x[], const Integer *ldx, const Integer *k, const Integer *n, double rnk[], double *w, double *p, Integer *ifail)
The routine may be called by the names g08daf or nagf_nonpar_concordance_kendall.

## 3Description

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-12k(n+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)).

## 4References

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

## 5Arguments

1: $\mathbf{x}\left({\mathbf{ldx}},{\mathbf{n}}\right)$Real (Kind=nag_wp) array Input
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: $\mathbf{ldx}$Integer Input
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: $\mathbf{k}$Integer Input
On entry: $k$, the number of comparisons.
Constraint: ${\mathbf{k}}\ge 2$.
4: $\mathbf{n}$Integer Input
On entry: $n$, the number of objects.
Constraint: ${\mathbf{n}}\ge 2$.
5: $\mathbf{rnk}\left({\mathbf{ldx}},{\mathbf{n}}\right)$Real (Kind=nag_wp) array Workspace
6: $\mathbf{w}$Real (Kind=nag_wp) Output
On exit: the value of Kendall's coefficient of concordance, $W$.
7: $\mathbf{p}$Real (Kind=nag_wp) Output
On exit: the approximate significance, $p$, of $W$.
8: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ 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).

## 6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-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}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 2$.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{ldx}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{k}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ldx}}\ge {\mathbf{k}}$.
${\mathbf{ifail}}=3$
On entry, ${\mathbf{k}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{k}}\ge 2$.
${\mathbf{ifail}}=-99$
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

## 7Accuracy

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

## 8Parallelism and Performance

g08daf is not threaded in any implementation.

## 9Further Comments

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

## 10Example

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.

### 10.1Program Text

Program Text (g08dafe.f90)

### 10.2Program Data

Program Data (g08dafe.d)

### 10.3Program Results

Program Results (g08dafe.r)