Skip to contents

Source: Kendall, M. G. (1938), A new measure of rank correlation, Biometrika 30, 81-93. The 1938 paper is paywalled here; the measure is quoted in its standard published form tau = (P - Q)/(P + Q) with P concordant and Q discordant pairs. Kendall states this for untied rankings, where it coincides with the tie-corrected tau-b. With ties the two differ, so tau here is tau-b, (P - Q)/sqrt((n0 - n1)(n0 - n2)) with n0 = n(n-1)/2, n1 the tied pairs in t and n2 those in x, which is the form base R cor(method = "kendall") returns; the untied ratio Kendall (1938) writes is returned separately as tau_a. With no ties the two are equal.

Usage

Ktrend(t, x)

Arguments

t

Numeric ordering variable, normally time.

x

Numeric series to test.

Value

list: tau (tau-b), tau_a, S, var_S, z, p_value, n_concordant, n_discordant, n, method.

Details

With the first argument time this is the Mann-Kendall trend test, S = P - Q, null variance Var(S) = (n(n-1)(2n+5) - sum_g u_g(u_g-1)(2u_g+5))/18 over groups of tied x values, and continuity-corrected deviate Z = (S - sign(S))/sqrt(Var(S)), p = 2(1 - Phi(|Z|)).

Examples

Ktrend(1:20, (1:20)^2)$tau
#> [1] 1