Pettitt Test for Abrupt Changes in the Mean of a Time Series
Source:R/eda-pettitt-test.R
eda_pettitt_test.Rd
Performs the nonparametric Pettitt test to detect a single abrupt change in the central tendency of a time series. Under the null hypothesis, there is no change.
Arguments
- data
Numeric vector of observed annual maximum series values. Must be strictly positive, finite, and not missing.
- years
Numeric vector of observation years corresponding to
data
. Must be the same length asdata
and strictly increasing.- 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
: Thedata
argument.years
: Theyears
argument.alpha
: The significance level as specified in thealpha
argument.null_hypothesis
: A string describing the null hypothesis.alternative_hypothesis
: A string describing the alternative hypothesis.u_series
: Numeric vector of absolute U-statistics for all years.statistic
: The test statistic and maximum absolute U-statistic.bound
: The critical value of the test statistic based onalpha
.change_points
: A dataframe containing the potential change point.p_value
: An asymptotic approximation of the p-value for the test.reject
: Logical scalar. IfTRUE
, the null hypothesis was rejected.
change_points
contains the years, test statistics, and p-values of each
potential change point. If no change points were identified, change_points
is empty.
References
Pettitt, A.N., 1979. A Non-parametric Approach to the Change-point Problem. J. Royal Statistics Society 28 (2), 126–135. http://www.jstor.org/stable/2346729
Examples
data <- rnorm(n = 100, mean = 100, sd = 10)
years <- seq(from = 1901, to = 2000)
eda_pettitt_test(data, years)
#> $data
#> [1] 93.18624 103.82141 102.02935 112.10449 85.42835 107.26397 88.20753
#> [8] 108.59298 100.01181 90.54158 111.24859 116.50599 99.71808 95.68262
#> [15] 109.62970 101.42725 92.26551 98.38343 102.72831 111.78279 99.34285
#> [22] 96.73675 106.16976 114.48573 104.01289 107.36656 106.75189 100.92422
#> [29] 105.71910 95.62950 115.22793 90.09813 101.21090 105.45931 108.28352
#> [36] 94.04016 97.61715 104.73747 103.40918 96.95804 107.33999 103.13770
#> [43] 111.29980 103.81615 103.68654 108.84609 109.21164 117.78567 92.96911
#> [50] 75.93637 99.68249 97.04275 106.00636 111.60364 100.56538 95.59872
#> [57] 98.35395 90.02786 76.48258 97.01634 78.53935 97.08140 93.10026
#> [64] 94.97523 106.05890 97.37607 96.90605 119.81818 94.51492 92.73484
#> [71] 101.06323 114.59809 93.10381 114.15768 100.04895 101.07439 98.37847
#> [78] 89.26774 100.03078 110.44615 98.93937 107.17062 87.33825 69.94219
#> [85] 108.75675 106.93614 112.83858 109.99143 86.73613 81.15200 101.48586
#> [92] 99.01536 91.65490 102.34030 104.16639 89.90877 92.40957 81.75752
#> [99] 98.91953 104.97110
#>
#> $years
#> [1] 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915
#> [16] 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930
#> [31] 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945
#> [46] 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960
#> [61] 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975
#> [76] 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990
#> [91] 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000
#>
#> $alpha
#> [1] 0.05
#>
#> $null_hypothesis
#> [1] "There are no abrupt changes in the mean of the data."
#>
#> $alternative_hypothesis
#> [1] "There is one abrupt change in the mean of the data."
#>
#> $u_series
#> [1] 55 28 15 68 19 34 47 14 7 64 11 106 97 54 123 132 65 44
#> [19] 61 142 129 88 133 222 251 308 355 356 395 350 443 370 377 414 473 420
#> [37] 393 426 447 410 465 484 561 586 609 674 741 838 777 680 669 636 677 756
#> [55] 755 708 683 608 513 478 385 354 295 246 289 260 221 320 269 206 209 300
#> [73] 243 330 327 332 309 230 225 298 281 332 249 150 213 262 347 418 333 242
#> [91] 253 238 169 184 215 138 73 16 35 35
#>
#> $statistic
#> [1] 838
#>
#> $bound
#> [1] 710.1279
#>
#> $p_value
#> [1] 0.015
#>
#> $change_points
#> index year value statistic p_value
#> 1 48 1948 117.7857 838 0.015
#>
#> $reject
#> [1] TRUE
#>