Skip to contents

Performs the Spearman serial correlation test on annual maximum series data to check for serial correlation at various lags. Reports the smallest lag where the serial correlation is not statistically significant at the given significance level (the least insignificant lag).

Usage

eda_spearman_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.

  • rho: Numeric vector of serial correlation estimates for lags \(1\) to \(n-3\).

  • least_lag: The smallest lag at which the serial correlation is insignificant.

  • significant: Indicates whether the serial correlation is significant at each lag.

  • reject: If TRUE, the null hypothesis was rejected at significance alpha.

Examples

data <- rnorm(n = 100, mean = 100, sd = 10)
eda_spearman_test(data)
#> $data
#>   [1]  86.05348  86.47162 106.82030  93.79462 101.08264 111.23510  95.33119
#>   [8] 103.83775  77.06348 117.92758  78.22464  91.43614 109.47363 105.26578
#>  [15]  81.73983 112.47440  99.33391 109.85445 112.67286 100.08714  87.93782
#>  [22]  95.52039  88.28031 107.00460 115.12215 101.99070  93.67655  94.53010
#>  [29] 106.48141 101.00782  82.42012 109.38275  84.40313  97.26097 107.97217
#>  [36]  96.08833 109.67785  93.54223 100.93528 107.62956  94.67642  97.07130
#>  [43] 102.06642  79.20201 108.58147 107.13222  84.83731 109.16774  89.74668
#>  [50]  91.85919 108.46643  94.93178 107.50644 106.77331 101.41293  85.65508
#>  [57]  86.16541  92.84438 122.92140  90.07804 104.59519  97.62281 108.35991
#>  [64]  93.65053  80.76932  98.64659 108.60061 113.31049  83.67603  97.24631
#>  [71]  97.62521 107.06400  99.04726 127.25076 106.30267  88.88680  96.44126
#>  [78] 110.38200  87.75264  93.26501 118.97439  96.53224  78.59880 124.76428
#>  [85]  95.97234 103.79369  92.51198 105.05991  94.64354 103.41252  92.41732
#>  [92]  95.76410  88.48226 115.30293 101.12761  98.74202  85.32868 109.61289
#>  [99] 109.64497 112.58596
#> 
#> $alpha
#> [1] 0.05
#> 
#> $null_hypothesis
#> [1] "There is no autocorrelation in the data."
#> 
#> $alternative_hypothesis
#> [1] "There is autocorrelation in the data."
#> 
#> $rho
#>  [1] -0.222993197 -0.129710741 -0.011242899 -0.058572979 -0.089389698
#>  [6]  0.130672254 -0.077646146  0.111200160 -0.174964166  0.083261308
#> [11]  0.056196799 -0.136434081  0.111503973  0.087315439 -0.196873168
#> [16]  0.119530222 -0.203161076 -0.034229057  0.089859982 -0.037552743
#> [21]  0.032935735  0.172346641 -0.090015248 -0.040929597 -0.183669986
#> [26]  0.097193632  0.303683821 -0.244260081  0.154158283 -0.098976468
#> [31] -0.083120205  0.097950147  0.099329555 -0.228514769  0.238330420
#> [36]  0.001373626 -0.067588326  0.013824885 -0.058751983 -0.077188108
#> [41]  0.054646406 -0.043834015  0.083419756 -0.230211893  0.118903319
#> [46] -0.014751286 -0.065312046  0.089729361  0.356199095 -0.153325330
#> [51] -0.215000000 -0.113221884  0.049259944  0.068023435  0.081422925
#> [56]  0.177167019 -0.125339777  0.055181914 -0.018292683  0.037523452
#> [61] -0.083400810  0.169493380 -0.238027501  0.141827542  0.126890756
#> [66] -0.198166539 -0.214572193  0.368401760 -0.164516129  0.070522803
#> [71]  0.065517241 -0.095238095 -0.523809524  0.223247863  0.082307692
#> [76]  0.260000000 -0.423913043  0.338226990 -0.290909091  0.160902256
#> [81]  0.142105263  0.391124871 -0.360294118  0.220588235 -0.164285714
#> [86]  0.230769231 -0.285714286  0.223776224 -0.136363636  0.054545455
#> [91] -0.016666667  0.095238095 -0.178571429  0.371428571  0.600000000
#> [96]  0.800000000  1.000000000
#> 
#> $least_lag
#> [1] 2
#> 
#> $significant
#>  [1]  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [25] FALSE FALSE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [37] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [49]  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [61] FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE
#> [73]  TRUE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [85] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [97]  TRUE
#> 
#> $reject
#> [1] TRUE
#>