Skip to contents

Formula: \(S = \sum_{i<j} \mathrm{sign}(x_j - x_i)\) with null variance \([n(n-1)(2n+5) - \sum t(t-1)(2t+5)]/18\) over the tie multiplicities \(t\), and \(z = \mathrm{sign}(S)(|S|-1)/ \sqrt{\mathrm{var} S}\) under the continuity correction. Kendall's tau uses the tie-adjusted denominator.

Usage

Mktest(x, continuity = TRUE)

Arguments

x

Series in time order.

continuity

Apply the \(|S|-1\) continuity correction.

Value

List with statistic (z), p_value, S, varS, tau, n, method.

References

Mann (1945), Econometrica 13:245-259; Kendall (1975), Rank Correlation Methods. Both paywalled; the coded form was read from Pohlert's CRAN package trend (R/mk.test.R, R/utilfn.R), whose .varmk and .Dfn give the tie corrections verbatim.

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
Mktest(V)
#> $statistic
#> [1] 3.340384
#> 
#> $p_value
#> [1] 0.0008366271
#> 
#> $S
#> [1] 28
#> 
#> $varS
#> [1] 65.33333
#> 
#> $tau
#> [1] 1
#> 
#> $n
#> [1] 8
#> 
#> $method
#> [1] "Mann-Kendall trend test"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"