Computes Sen's linear trend estimator for a univariate time series. The estimated slope and y-intercept are given in terms of the data and the covariate (time), which is derived from the years using the formula \((\text{Years} - 1900) / 100\).
Value
A list containing the estimated trend:
data
: Thedata
argument.years
: Theyears
argument.slope
: The estimated slope.intercept
: The estimated y-intercept.residuals
: Vector of differences between the predicted and observed values.
Details
Sen's slope estimator is a robust, nonparametric trend estimator based on the median of all pairwise slopes between data points. The corresponding intercept is the median of each \(y_i - mx_i\) where \(m\) is the estimated slope.
References
Sen, P.K. (1968). Estimates of the regression coefficient based on Kendall's tau. Journal of the American Statistical Association, 63(324), 1379–1389.
Examples
data <- rnorm(n = 100, mean = 100, sd = 10)
years <- seq(from = 1901, to = 2000)
eda_sens_trend(data, years)
#> $data
#> [1] 71.14720 114.04081 85.53392 97.67344 90.89083 103.29376 99.21390
#> [8] 98.90397 89.27138 103.95860 108.25451 108.57277 98.29088 101.00560
#> [15] 95.65229 95.56905 89.66521 122.50497 94.90634 107.83315 106.31107
#> [22] 111.51340 102.09891 98.66040 107.10639 102.32650 93.56602 82.17235
#> [29] 115.53949 97.62048 91.48151 103.99375 78.75553 109.02592 109.87513
#> [36] 91.57034 75.35796 83.06758 111.02988 110.79918 97.81132 115.99110
#> [43] 97.49414 114.96522 104.48972 101.82078 93.83436 86.25984 92.93219
#> [50] 108.05278 101.79365 100.54119 84.71055 104.00399 96.18705 100.58256
#> [57] 103.80280 101.53855 114.89921 104.92200 103.21021 101.94214 107.42460
#> [64] 116.84394 92.50584 104.87693 100.38928 91.57844 110.66950 112.50907
#> [71] 99.43985 111.01152 108.60272 94.35932 79.94742 102.48602 102.09311
#> [78] 105.64982 104.92798 97.24127 102.44770 101.24951 102.63553 93.00900
#> [85] 79.43679 102.37812 99.58353 106.73590 90.05232 106.93567 105.46208
#> [92] 113.96973 95.44503 104.04250 103.99922 76.23319 104.59000 111.99336
#> [99] 106.43052 102.14418
#>
#> $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
#>
#> $slope
#> [1] 3.842688
#>
#> $intercept
#> [1] 99.50288
#>
#> $residuals
#> [1] -28.39411147 14.46107059 -14.08424335 -1.98315489 -8.80418906
#> [6] 3.56031770 -0.55797637 -0.90633097 -10.57734432 4.07144507
#> [11] 8.32893103 8.60876081 -1.71155617 0.96473736 -4.42699849
#> [16] -4.54865981 -10.49093294 22.31039865 -5.32665070 7.56173095
#> [21] 6.00122076 11.16512696 1.71220418 -1.76472890 6.64283091
#> [26] 1.82452118 -6.97439124 -18.40648772 14.92222747 -3.03520959
#> [31] -9.21260971 3.26120821 -22.01543988 8.21651984 9.02730921
#> [36] -9.31590921 -25.56672035 -17.89552130 10.02834619 9.75922120
#> [41] -3.26706738 14.87428433 -3.66110199 13.77155209 3.25763108
#> [46] 0.55025778 -7.47458763 -15.08753832 -8.45360940 6.62855464
#> [51] 0.33099984 -0.95989488 -16.82895372 2.42605401 -5.42931041
#> [56] -1.07223366 2.10958088 -0.19309787 13.12914095 3.11350151
#> [61] 1.36328726 0.05678530 5.50082462 14.88173083 -9.49479528
#> [66] 2.83786979 -1.68820023 -10.53747372 8.51516540 10.31630230
#> [71] -2.79134258 8.74190230 6.29467803 -7.98715146 -22.43747678
#> [76] 0.06269405 -0.36863970 3.14964224 2.38937319 -5.33575954
#> [81] -0.16776431 -1.40437689 -0.05678530 -9.72174514 -23.33237616
#> [86] -0.42948044 -3.26249112 3.85144901 -12.87055837 3.97436293
#> [91] 2.46235038 10.93157667 -7.63155218 0.92749105 0.84578369
#> [96] -26.95867768 1.35970584 8.72463670 3.12337262 -1.20139653
#>