Skip to contents

Performs the Mann–Kendall trend test on a numeric vector to detect the presence of an increasing or decreasing monotonic trend over time. The test is nonparametric and accounts for tied observations in the data. The null hypothesis assumes there is no monotonic trend.

Usage

eda_mk_test(data, alpha = 0.05)

Arguments

data

Numeric vector of observed annual maximum series values. Must be strictly positive, finite, and not missing.

alpha

Numeric scalar in \([0.01, 0.1]\). The significance level for confidence intervals or hypothesis tests. Default is 0.05.

Value

A list containing the test results, including:

  • data: The data argument.

  • alpha: The significance level as specified in the alpha argument.

  • null_hypothesis: A string describing the null hypothesis.

  • alternative_hypothesis: A string describing the alternative hypothesis.

  • statistic: The Mann–Kendall test statistic.

  • variance: The variance of the test statistic under the null hypothesis.

  • p_value: The p-value associated with the two-sided hypothesis test.

  • reject: Logical. If TRUE, the null hypothesis is rejected at alpha.

Details

The test statistic \(S\) is the sum over all pairs \(i < j\) of the sign of the difference \(x_j - x_i\). Ties are explicitly accounted for when calculating the variance of \(S\), using grouped frequencies of tied observations. The test statistic \(Z\) is then computed based on the sign and magnitude of \(S\), and the p-value is derived from the standard normal distribution.

References

Kendall, M. (1975). Rank Correlation Methods. Griffin, London, 202 pp.

Mann, H. B. (1945). Nonparametric Tests Against Trend. Econometrica, 13(3): 245-25

See also

Examples

data <- rnorm(n = 100, mean = 100, sd = 10)
eda_mk_test(data)
#> $data
#>   [1] 107.34841  99.84156  88.23479  97.79369 115.64516 111.22041 104.63076
#>   [8] 106.33357  95.12631  89.60322  75.68793 102.59373  96.36258 110.89977
#>  [15] 107.88251 105.74549  98.24206 100.42963 101.62222  97.24310  99.82175
#>  [22] 102.24486  83.05105  98.18668 108.51155 105.74684 107.53031  92.67545
#>  [29]  85.09204  98.48259  96.75074 111.55520  98.43460 110.63326 102.35489
#>  [36] 120.92595  83.07251  89.94641 116.74478  95.62255 113.27158 114.27544
#>  [43]  84.60421 111.82677 106.54959 113.19297  95.98798  94.25990  81.96696
#>  [50] 100.44151 100.24345 111.49112  97.26690  94.35158 107.04075 105.20372
#>  [57] 107.43372 101.73053 109.10044  93.58330  88.93986  92.14111 105.30740
#>  [64] 112.18120  84.70178 105.51114  94.83542  96.01779 103.24808 107.26851
#>  [71]  96.57706  94.41080  96.02413  99.10775 110.40952 102.40919  96.55350
#>  [78]  91.02249  98.98338  92.13937  90.92910 114.08476 102.50388  94.02291
#>  [85]  94.74065  94.91006  92.55806  91.13979 118.16085  83.30854 111.22617
#>  [92] 107.17357  96.59280  99.14638 103.38835  96.73917 101.31666  98.82788
#>  [99] 108.98828 110.77115
#> 
#> $alpha
#> [1] 0.05
#> 
#> $null_hypothesis
#> [1] "There is no monotonic trend in the mean of the data."
#> 
#> $alternative_hypothesis
#> [1] "There is a monotonic trend in the mean of the data."
#> 
#> $statistic
#> [1] -202
#> 
#> $variance
#> [1] 112750
#> 
#> $p_value
#> [1] 0.5494387
#> 
#> $reject
#> [1] FALSE
#>