\(S = \sum_{i < j} sign(x_j - x_i)\) with the tie-corrected null variance
\(var(S) = (n(n-1)(2n+5) - \sum_t t(t-1)(2t+5)) / 18\) over the
multiplicities t of tied values, and \(z = sign(S)(|S| - 1)/\sqrt{var(S)}\)
under the continuity correction (\(S / \sqrt{var(S)}\) without it); the
p-value is two-sided normal. Kendall's tau uses the tie-adjusted
denominator (tau-b against an untied time index). Identical to the Python
arm morie.fn.mannK.mann_kendall.
References
Mann, H. B. (1945). Nonparametric tests against trend. Econometrica 13, 245-259.
Kendall, M. G. (1975). Rank Correlation Methods, 4th edn. Griffin.
Examples
MannKendall(c(1.2, 0.8, 1.9, 2.4, 2.1, 3.3, 3.0, 4.1))
#> $statistic
#> [1] 2.598076
#>
#> $p_value
#> [1] 0.009374768
#>
#> $S
#> [1] 22
#>
#> $varS
#> [1] 65.33333
#>
#> $tau
#> [1] 0.7857143
#>
#> $n
#> [1] 8
#>
#> $method
#> [1] "Mann-Kendall trend test"
#>
