Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_nonpar_concordance_kendall (g08da)

## Purpose

nag_nonpar_concordance_kendall (g08da) calculates Kendall's coefficient of concordance on k$k$ independent rankings of n$n$ objects or individuals.

## Syntax

[w, p, ifail] = g08da(x, k, 'n', n)
[w, p, ifail] = nag_nonpar_concordance_kendall(x, k, 'n', n)

## Description

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

## References

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

## Parameters

### Compulsory Input Parameters

1:     x(ldx,n) – double array
ldx, the first dimension of the array, must satisfy the constraint ldxk$\mathit{ldx}\ge {\mathbf{k}}$.
x(i,j)${\mathbf{x}}\left(\mathit{i},\mathit{j}\right)$ must be set to the value xij${x}_{\mathit{i}\mathit{j}}$ of object j$\mathit{j}$ in comparison i$\mathit{i}$, for i = 1,2,,k$\mathit{i}=1,2,\dots ,k$ and j = 1,2,,n$\mathit{j}=1,2,\dots ,n$.
2:     k – int64int32nag_int scalar
k$k$, the number of comparisons.
Constraint: k2${\mathbf{k}}\ge 2$.

### Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The second dimension of the array x.
n$n$, the number of objects.
Constraint: n2${\mathbf{n}}\ge 2$.

ldx rnk

### Output Parameters

1:     w – double scalar
The value of Kendall's coefficient of concordance, W$W$.
2:     p – double scalar
The approximate significance, p$p$, of W$W$.
3:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
 On entry, n < 2${\mathbf{n}}<2$.
ifail = 2${\mathbf{ifail}}=2$
 On entry, ldx < k$\mathit{ldx}<{\mathbf{k}}$.
ifail = 3${\mathbf{ifail}}=3$
 On entry, k ≤ 1${\mathbf{k}}\le 1$.

## Accuracy

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

The time taken by nag_nonpar_concordance_kendall (g08da) is approximately proportional to the product nk$nk$.

## Example

```function nag_nonpar_concordance_kendall_example
x = [1, 4.5, 2, 4.5, 3, 7.5, 6, 9, 7.5, 10;
2.5, 1, 2.5, 4.5, 4.5, 8, 9, 6.5, 10, 6.5;
2, 1, 4.5, 4.5, 4.5, 4.5, 8, 8, 8, 10];
k = int64(3);
[w, p, ifail] = nag_nonpar_concordance_kendall(x, k)
```
```

w =

0.8277

p =

0.0078

ifail =

0

```
```function g08da_example
x = [1, 4.5, 2, 4.5, 3, 7.5, 6, 9, 7.5, 10;
2.5, 1, 2.5, 4.5, 4.5, 8, 9, 6.5, 10, 6.5;
2, 1, 4.5, 4.5, 4.5, 4.5, 8, 8, 8, 10];
k = int64(3);
[w, p, ifail] = g08da(x, k)
```
```

w =

0.8277

p =

0.0078

ifail =

0

```