STLM for Time Series Data
STL (Seasonal and Trend decomposition using Loess)
분해는 다양한 상황에서 사용할 수 있는 강력한 시계열 분해 기법이다.\[\begin{align} Y_{t} = S_{t} + A_{t} \end{align}\]
Seasonal naive method
을 이용하여 예측한다.
시계열 모형
을 이용하여 적합한 후 예측한다.
pacman::p_load("forecast", "dplyr", "ggplot2", "xts")
# In Mac
# guess_encoding("Amtrak.csv")
# Amtrak.data <- read.csv("Amtrak.csv", fileEncoding="EUC-KR")
Amtrak.data <- data.table::fread(paste(getwd(),"Amtrak.csv", sep="/"))
ridership.ts <- ts(Amtrak.data$Ridership, start=c(1991,1), end=c(2004,3), freq=12)
stl()
을 이용하여 데이터를 추세와 계절성, 불규칙 성분으로 나눌 수 있다.
mstl()
을 이용한다.ridership.ts %>%
stl( s.window = "periodic", robust = TRUE) %>%
autoplot()
train.ts %>%
stl( s.window = "periodic", robust = TRUE) %>%
autoplot()
stlm(y, s.window, robust, method=c("ets", "arima"), modelfunction, xreg )
계절 성분을 추출
하기 위한 모수로 계절패턴이 시간에 따라 일정하다고 판단되면 "periodic" 혹은 7이상의 수
를, 계절패턴이 시간의 흐름에 따라 변화된다고 판단되면 최근 데이터만 사용하도록 작은 수
를 입력method=arima
일 때, auto.arima
에 사용될 예측변수STLM.fit <- train.ts %>%
stlm(method = "arima") # 시계열을 분해하고 추세 + 오차 성분에 ARIMA 모형 적합NASTLM.fit
$stl
Data Trend Seasonal12 Remainder
Jan 1991 1708.917 1869.425 -189.19036235 28.6823492
Feb 1991 1620.586 1860.032 -240.97648277 1.5299997
Mar 1991 1972.715 1850.640 59.47573708 62.5993099
Apr 1991 1811.665 1841.247 54.32026362 -83.9026866
May 1991 1974.964 1833.126 87.92725969 53.9112002
Jun 1991 1862.356 1825.004 15.43986583 21.9124768
Jul 1991 1939.860 1816.882 134.89706721 -11.9188417
Aug 1991 2013.264 1809.662 204.56513119 -0.9632646
Sep 1991 1595.657 1802.442 -118.81826378 -87.9672285
Oct 1991 1724.924 1795.223 -7.40863825 -62.8902130
Nov 1991 1675.667 1790.281 -20.94370798 -93.6705180
Dec 1991 1813.863 1785.340 24.79248866 3.7309106
Jan 1992 1614.827 1780.398 -191.21787993 25.6469044
Feb 1992 1557.088 1782.084 -242.86167620 17.8658592
Mar 1992 1891.223 1783.770 57.11434230 50.3389993
Apr 1992 1955.981 1785.455 52.32761168 118.1978885
May 1992 1884.714 1792.392 86.53558379 5.7868514
Jun 1992 1623.042 1799.328 18.02650317 -194.3121330
Jul 1992 1903.309 1806.264 137.23971099 -40.1944058
Aug 1992 1996.712 1810.635 205.52731962 -19.4506939
Sep 1992 1703.897 1815.007 -118.04720664 6.9371530
Oct 1992 1810.000 1819.379 -5.77494231 -3.6037907
Nov 1992 1861.601 1824.082 -19.81673954 57.3360665
Dec 1992 1875.122 1828.785 25.36770427 20.9696827
Jan 1993 1705.259 1833.488 -193.28231677 65.0537637
Feb 1993 1618.535 1832.976 -244.76075685 30.3198177
Mar 1993 1836.709 1832.464 54.76209234 -50.5174176
Apr 1993 1957.043 1831.953 50.37489760 74.7153910
May 1993 1917.185 1824.316 85.21463880 7.6548541
Jun 1993 1882.398 1816.678 20.71240377 45.0072934
Jul 1993 1933.009 1809.041 139.71015039 -15.7422489
Aug 1993 1996.167 1803.023 206.62923467 -13.4857245
Sep 1993 1672.841 1797.006 -117.12449191 -7.0403892
Oct 1993 1752.827 1790.988 -4.00487339 -34.1563991
Nov 1993 1720.377 1785.162 -18.56868270 -46.2161648
Dec 1993 1734.292 1779.335 26.01683361 -71.0602561
Jan 1994 1563.365 1773.509 -197.00000572 -13.1439918
Feb 1994 1573.959 1771.119 -247.73735656 50.5773637
Mar 1994 1902.639 1768.729 49.97940839 83.9306035
Apr 1994 1833.888 1766.339 48.15868582 19.3903308
May 1994 1831.049 1766.404 81.00765957 -16.3629183
Jun 1994 1775.755 1766.470 26.53471329 -17.2492473
Jul 1994 1867.508 1766.535 144.13221697 -43.1590263
Aug 1994 1906.608 1762.661 207.17254576 -63.2255956
Sep 1994 1685.632 1758.787 -114.36830731 41.2130170
Oct 1994 1778.546 1754.914 -0.07266117 23.7051303
Nov 1994 1775.995 1749.467 -14.82948167 41.3573998
Dec 1994 1783.350 1744.021 26.10229938 13.2270676
Jan 1995 1548.415 1738.574 -201.27320995 11.1140259
Feb 1995 1496.925 1731.409 -251.17599096 16.6917413
Mar 1995 1798.316 1724.244 44.82817034 29.2435145
Apr 1995 1732.895 1717.079 45.69108517 -29.8754659
May 1995 1772.345 1706.265 76.66645667 -10.5865380
Jun 1995 1761.207 1695.451 32.34238400 33.4138340
Jul 1995 1791.655 1684.636 148.65922959 -41.6407122
Aug 1995 1874.820 1672.804 207.92632695 -5.9100643
Sep 1995 1571.309 1660.971 -111.29612856 21.6341366
Oct 1995 1646.948 1649.138 4.25149256 -6.4417392
Nov 1995 1672.631 1643.456 -10.62239173 39.7971276
Dec 1995 1656.845 1637.774 26.68919498 -7.6184765
Jan 1996 1381.758 1632.092 -211.19675387 -39.1375451
Feb 1996 1360.852 1632.056 -256.65974275 -14.5442294
Mar 1996 1558.575 1632.020 39.06808759 -112.5127329
Apr 1996 1608.420 1631.983 43.40202892 -66.9653473
May 1996 1696.696 1633.187 74.74753041 -11.2382773
Jun 1996 1693.183 1634.390 43.50061072 15.2922138
Jul 1996 1835.516 1635.594 154.22029199 45.7021040
Aug 1996 1942.573 1639.940 205.25246627 97.3802366
Sep 1996 1551.401 1644.287 -112.82659359 19.9406033
Oct 1996 1686.508 1648.634 8.61394077 29.2603758
Nov 1996 1576.204 1654.812 -4.36281377 -74.2448027
Dec 1996 1700.433 1660.990 28.83447595 10.6089745
Jan 1997 1396.588 1667.167 -221.10947723 -49.4700054
Feb 1997 1371.690 1674.183 -262.20632769 -40.2871085
Mar 1997 1707.522 1681.199 33.17151797 -6.8489077
Apr 1997 1654.604 1688.215 40.89953687 -74.5108801
May 1997 1762.903 1697.524 72.53821941 -7.1590928
Jun 1997 1775.800 1706.832 54.29382991 14.6737666
Jul 1997 1934.219 1716.141 159.34172405 58.7363423
Aug 1997 2008.055 1724.314 202.08217460 81.6591503
Sep 1997 1615.924 1732.486 -114.91029023 -1.6521264
Oct 1997 1773.910 1740.659 12.40428662 20.8465553
Nov 1997 1732.368 1745.449 1.30579108 -14.3865379
Dec 1997 1796.626 1750.238 30.42698977 15.9606746
Jan 1998 1570.330 1755.028 -225.90148892 41.2035645
Feb 1998 1412.691 1756.809 -265.26911818 -78.8487419
Mar 1998 1754.641 1758.590 31.74134781 -35.6901436
Apr 1998 1824.932 1760.371 39.73118317 24.8300854
May 1998 1843.289 1764.807 72.25711918 6.2252753
Jun 1998 1825.964 1769.242 57.20137054 -0.4798502
Jul 1998 1968.172 1773.678 161.19016460 33.3034817
Aug 1998 1921.645 1778.645 201.54046795 -58.5409442
Sep 1998 1669.597 1783.613 -116.06624706 2.0506483
Oct 1998 1791.474 1788.580 13.59987420 -10.7055955
Nov 1998 1816.714 1790.702 2.83586667 23.1762232
Dec 1998 1846.754 1792.824 31.55389937 22.3760017
Jan 1999 1599.427 1794.946 -230.08088577 34.5615980
Feb 1999 1548.804 1794.879 -267.77730157 21.7024877
Mar 1999 1832.333 1794.811 30.80777703 6.7138830
Apr 1999 1839.720 1794.744 38.96556087 6.0105730
May 1999 1846.498 1794.890 72.28488236 -20.6771395
Jun 1999 1864.852 1795.037 60.31819758 9.4971542
Jul 1999 1965.743 1795.183 163.14831457 7.4116462
Aug 1999 1949.002 1800.483 201.02781763 -52.5087951
Sep 1999 1607.373 1805.783 -117.27380063 -81.1361151
Oct 1999 1803.664 1811.083 14.69649365 -22.1153476
Nov 1999 1850.309 1821.753 4.21960273 24.3367827
Dec 1999 1836.435 1832.422 32.52198973 -28.5093649
Jan 2000 1541.660 1843.092 -231.90745241 -69.5246834
Feb 2000 1616.928 1856.209 -269.24638671 29.9658371
Mar 2000 1919.538 1869.325 30.13971435 20.0733223
Apr 2000 1971.493 1882.441 38.53807534 50.5135476
May 2000 1992.301 1892.662 72.18977901 27.4496434
Jun 2000 2009.763 1902.882 62.07186899 44.8093528
Jul 2000 2053.996 1913.102 164.61003399 -23.7160128
Aug 2000 2097.471 1921.113 200.34665261 -23.9885243
Sep 2000 1823.706 1929.124 -118.39331328 12.9755487
Oct 2000 1976.997 1937.135 15.24166220 24.6206804
Nov 2000 1981.408 1944.599 5.27794847 31.5312464
Dec 2000 2000.153 1952.063 33.16263684 14.9274104
Jan 2001 1683.148 1959.527 -233.59204193 -42.7870585
Feb 2001 1663.404 1966.423 -270.57813703 -32.4413187
Mar 2001 2007.928 1973.320 29.60434419 5.0038448
$model
Series: x
ARIMA(0,1,1)
Coefficients:
ma1
-0.4457
s.e. 0.0958
sigma^2 estimated as 2772: log likelihood=-656.29
AIC=1316.59 AICc=1316.69 BIC=1322.2
$modelfunction
function (x, ...)
{
return(auto.arima(x, xreg = xreg, seasonal = FALSE, ...))
}
<bytecode: 0x000000001df79378>
<environment: 0x000000001df747a8>
$lambda
NULL
$x
Jan Feb Mar Apr May Jun Jul
1991 1708.917 1620.586 1972.715 1811.665 1974.964 1862.356 1939.860
1992 1614.827 1557.088 1891.223 1955.981 1884.714 1623.042 1903.309
1993 1705.259 1618.535 1836.709 1957.043 1917.185 1882.398 1933.009
1994 1563.365 1573.959 1902.639 1833.888 1831.049 1775.755 1867.508
1995 1548.415 1496.925 1798.316 1732.895 1772.345 1761.207 1791.655
1996 1381.758 1360.852 1558.575 1608.420 1696.696 1693.183 1835.516
1997 1396.588 1371.690 1707.522 1654.604 1762.903 1775.800 1934.219
1998 1570.330 1412.691 1754.641 1824.932 1843.289 1825.964 1968.172
1999 1599.427 1548.804 1832.333 1839.720 1846.498 1864.852 1965.743
2000 1541.660 1616.928 1919.538 1971.493 1992.301 2009.763 2053.996
2001 1683.148 1663.404 2007.928
Aug Sep Oct Nov Dec
1991 2013.264 1595.657 1724.924 1675.667 1813.863
1992 1996.712 1703.897 1810.000 1861.601 1875.122
1993 1996.167 1672.841 1752.827 1720.377 1734.292
1994 1906.608 1685.632 1778.546 1775.995 1783.350
1995 1874.820 1571.309 1646.948 1672.631 1656.845
1996 1942.573 1551.401 1686.508 1576.204 1700.433
1997 2008.055 1615.924 1773.910 1732.368 1796.626
1998 1921.645 1669.597 1791.474 1816.714 1846.754
1999 1949.002 1607.373 1803.664 1850.309 1836.435
2000 2097.471 1823.706 1976.997 1981.408 2000.153
2001
$series
[1] "."
$m
[1] 12
$fitted
Jan Feb Mar Apr May Jun Jul
1991 1707.019 1653.965 1935.239 1950.685 1907.082 1872.238 1986.216
1992 1566.174 1541.498 1850.115 1868.114 1951.026 1845.761 1841.524
1993 1655.950 1631.803 1923.972 1871.216 1953.629 1868.926 1995.391
1994 1531.971 1498.635 1838.103 1872.054 1883.748 1800.065 1904.188
1995 1567.148 1506.862 1797.358 1798.752 1793.224 1737.327 1866.880
1996 1437.651 1361.207 1656.738 1606.661 1638.982 1639.725 1780.076
1997 1429.504 1370.162 1666.387 1696.916 1705.101 1718.896 1855.485
1998 1529.770 1512.884 1754.359 1762.505 1829.633 1822.147 1928.251
1999 1576.695 1551.599 1848.635 1847.757 1876.621 1847.958 1960.152
2000 1575.599 1519.448 1872.866 1907.134 1976.459 1975.122 2096.861
2001 1731.301 1667.624 1965.467
Aug Sep Oct Nov Dec
1991 2030.189 1697.424 1752.425 1723.647 1742.788
1992 1944.058 1649.669 1791.999 1787.935 1873.952
1993 2027.733 1686.482 1792.041 1755.741 1780.725
1994 1946.897 1603.024 1763.108 1756.908 1808.420
1995 1884.451 1559.890 1681.767 1647.593 1698.783
1996 1861.838 1588.509 1689.381 1674.812 1653.352
1997 1941.867 1661.562 1763.580 1758.207 1773.006
1998 1990.729 1634.830 1783.767 1777.275 1827.854
1999 2001.131 1653.935 1760.096 1773.769 1844.496
2000 2108.838 1783.798 1939.553 1950.344 1995.447
2001
$residuals
Jan Feb Mar Apr May
1991 1.8981062 -33.3786402 37.4762140 -139.0198321 67.8820236
1992 48.6532203 15.5901256 41.1076892 87.8669254 -66.3116196
1993 49.3086704 -13.2680885 -87.2625969 85.8271988 -36.4435195
1994 31.3941839 75.3241187 64.5361068 -38.1657533 -52.6989121
1995 -18.7333517 -9.9369007 0.9578418 -65.8569932 -20.8786307
1996 -55.8933383 -0.3553487 -98.1632136 1.7585259 57.7142948
1997 -32.9164750 1.5275790 41.1350148 -42.3116448 57.8015051
1998 40.5601758 -100.1932093 0.2822075 62.4269479 13.6555105
1999 22.7319447 -2.7946812 -16.3017018 -8.0366497 -30.1233536
2000 -33.9386052 97.4800870 46.6719540 64.3588940 15.8418346
2001 -48.1528733 -4.2202235 42.4605141
Jun Jul Aug Sep Oct
1991 -9.8824339 -46.3562339 -16.9250070 -101.7671497 -27.5014269
1992 -222.7188111 61.7853215 52.6538572 54.2279879 18.0008065
1993 13.4719171 -62.3821501 -31.5655638 -13.6414274 -39.2137679
1994 -24.3095969 -36.6795853 -40.2888641 82.6076186 15.4375696
1995 23.8802142 -75.2251450 -9.6308553 11.4188667 -34.8190940
1996 53.4578796 55.4401429 80.7351687 -37.1082980 -2.8731521
1997 56.9042202 78.7340058 66.1882491 -45.6376312 10.3301784
1998 3.8171750 39.9205671 -69.0842233 34.7670403 7.7069695
1999 16.8943414 5.5908955 -52.1285732 -46.5617180 43.5675843
2000 34.6408075 -42.8653377 -11.3672186 39.9084589 37.4437079
2001
Nov Dec
1991 -47.9796450 71.0746949
1992 73.6659746 1.1703730
1993 -35.3642418 -46.4327871
1994 19.0865322 -25.0696826
1995 25.0375925 -41.9380286
1996 -98.6078441 47.0810003
1997 -25.8392189 23.6199486
1998 39.4390972 18.9004504
1999 76.5404907 -8.0613636
2000 31.0638277 4.7058357
2001
attr(,"class")
[1] "stlm"
추세 + 오차 성분에 ETS, ARIMA 등과 같은 모형을 적합
시킨 후 forecast
함수를 이용해 예측하고 계절 성분은 Seasonal naive method을 이용해 예측
한다.STLM.forecast <- forecast(STLM.fit, h = n.test) # 추세 + 오차 성분을 예측하고 Seasonal naive method(같은 시즌의 마지막 관측값=예측)를 이용하여 Seasonal 예측하여 더함NASTLM.forecast$mean
Jan Feb Mar Apr May Jun Jul
2001 1997.937 2031.588 2021.470 2124.009
2002 1725.806 1688.820 1989.003 1997.937 2031.588 2021.470 2124.009
2003 1725.806 1688.820 1989.003 1997.937 2031.588 2021.470 2124.009
2004 1725.806 1688.820 1989.003
Aug Sep Oct Nov Dec
2001 2159.745 1841.005 1974.640 1964.676 1992.561
2002 2159.745 1841.005 1974.640 1964.676 1992.561
2003 2159.745 1841.005 1974.640 1964.676 1992.561
2004
plot(STLM.forecast)
accuracy(test.ts, STLM.forecast$mean)
ME RMSE MAE MPE MAPE ACF1
Test set -33.93849 83.56457 69.78618 -1.79913 3.621365 0.699746
Theil's U
Test set 0.5298629
# Month 변수 생성생성
xts(ridership.ts, order = as.Date(ridership.ts))
[,1]
1991-01-01 1708.917
1991-02-01 1620.586
1991-03-01 1972.715
1991-04-01 1811.665
1991-05-01 1974.964
1991-06-01 1862.356
1991-07-01 1939.860
1991-08-01 2013.264
1991-09-01 1595.657
1991-10-01 1724.924
1991-11-01 1675.667
1991-12-01 1813.863
1992-01-01 1614.827
1992-02-01 1557.088
1992-03-01 1891.223
1992-04-01 1955.981
1992-05-01 1884.714
1992-06-01 1623.042
1992-07-01 1903.309
1992-08-01 1996.712
1992-09-01 1703.897
1992-10-01 1810.000
1992-11-01 1861.601
1992-12-01 1875.122
1993-01-01 1705.259
1993-02-01 1618.535
1993-03-01 1836.709
1993-04-01 1957.043
1993-05-01 1917.185
1993-06-01 1882.398
1993-07-01 1933.009
1993-08-01 1996.167
1993-09-01 1672.841
1993-10-01 1752.827
1993-11-01 1720.377
1993-12-01 1734.292
1994-01-01 1563.365
1994-02-01 1573.959
1994-03-01 1902.639
1994-04-01 1833.888
1994-05-01 1831.049
1994-06-01 1775.755
1994-07-01 1867.508
1994-08-01 1906.608
1994-09-01 1685.632
1994-10-01 1778.546
1994-11-01 1775.995
1994-12-01 1783.350
1995-01-01 1548.415
1995-02-01 1496.925
1995-03-01 1798.316
1995-04-01 1732.895
1995-05-01 1772.345
1995-06-01 1761.207
1995-07-01 1791.655
1995-08-01 1874.820
1995-09-01 1571.309
1995-10-01 1646.948
1995-11-01 1672.631
1995-12-01 1656.845
1996-01-01 1381.758
1996-02-01 1360.852
1996-03-01 1558.575
1996-04-01 1608.420
1996-05-01 1696.696
1996-06-01 1693.183
1996-07-01 1835.516
1996-08-01 1942.573
1996-09-01 1551.401
1996-10-01 1686.508
1996-11-01 1576.204
1996-12-01 1700.433
1997-01-01 1396.588
1997-02-01 1371.690
1997-03-01 1707.522
1997-04-01 1654.604
1997-05-01 1762.903
1997-06-01 1775.800
1997-07-01 1934.219
1997-08-01 2008.055
1997-09-01 1615.924
1997-10-01 1773.910
1997-11-01 1732.368
1997-12-01 1796.626
1998-01-01 1570.330
1998-02-01 1412.691
1998-03-01 1754.641
1998-04-01 1824.932
1998-05-01 1843.289
1998-06-01 1825.964
1998-07-01 1968.172
1998-08-01 1921.645
1998-09-01 1669.597
1998-10-01 1791.474
1998-11-01 1816.714
1998-12-01 1846.754
1999-01-01 1599.427
1999-02-01 1548.804
1999-03-01 1832.333
1999-04-01 1839.720
1999-05-01 1846.498
1999-06-01 1864.852
1999-07-01 1965.743
1999-08-01 1949.002
1999-09-01 1607.373
1999-10-01 1803.664
1999-11-01 1850.309
1999-12-01 1836.435
2000-01-01 1541.660
2000-02-01 1616.928
2000-03-01 1919.538
2000-04-01 1971.493
2000-05-01 1992.301
2000-06-01 2009.763
2000-07-01 2053.996
2000-08-01 2097.471
2000-09-01 1823.706
2000-10-01 1976.997
2000-11-01 1981.408
2000-12-01 2000.153
2001-01-01 1683.148
2001-02-01 1663.404
2001-03-01 2007.928
2001-04-01 2023.792
2001-05-01 2047.008
2001-06-01 2072.913
2001-07-01 2126.717
2001-08-01 2202.638
2001-09-01 1707.693
2001-10-01 1950.716
2001-11-01 1973.614
2001-12-01 1984.729
2002-01-01 1759.629
2002-02-01 1770.595
2002-03-01 2019.912
2002-04-01 2048.398
2002-05-01 2068.763
2002-06-01 1994.267
2002-07-01 2075.258
2002-08-01 2026.560
2002-09-01 1734.155
2002-10-01 1916.771
2002-11-01 1858.345
2002-12-01 1996.352
2003-01-01 1778.033
2003-02-01 1749.489
2003-03-01 2066.466
2003-04-01 2098.899
2003-05-01 2104.911
2003-06-01 2129.671
2003-07-01 2223.349
2003-08-01 2174.360
2003-09-01 1931.406
2003-10-01 2121.470
2003-11-01 2076.054
2003-12-01 2140.677
2004-01-01 1831.508
2004-02-01 1838.006
2004-03-01 2132.446
Month <- as.Date(ridership.ts) %>% # Date 추출NAlubridate::month() # Month 추출NA# 퓨리에 항과 합치기
Train.Xreg <- cbind("Month"= Month[1:length(train.ts)],
fourier(train.ts, K=2)) # K : sine, cosine 쌍의 개수/시계열 데이터의 계절 주기가 2개 이상일 때, K는 계절 주기 수만큼 필요NATest.Xreg <- cbind("Month"= Month[-(1:length(train.ts))],
fourier(train.ts, K=2, h=n.test))
STLM.fit2 <- train.ts %>%
stlm(method = "arima", xreg = Train.Xreg) # 시계열을 분해하고 추세 + 오차 성분에 DHR 모형 적합 => 예측 변수에 Fourier Terms 포함되서NASTLM.fit2
$stl
Data Trend Seasonal12 Remainder
Jan 1991 1708.917 1869.425 -189.19036235 28.6823492
Feb 1991 1620.586 1860.032 -240.97648277 1.5299997
Mar 1991 1972.715 1850.640 59.47573708 62.5993099
Apr 1991 1811.665 1841.247 54.32026362 -83.9026866
May 1991 1974.964 1833.126 87.92725969 53.9112002
Jun 1991 1862.356 1825.004 15.43986583 21.9124768
Jul 1991 1939.860 1816.882 134.89706721 -11.9188417
Aug 1991 2013.264 1809.662 204.56513119 -0.9632646
Sep 1991 1595.657 1802.442 -118.81826378 -87.9672285
Oct 1991 1724.924 1795.223 -7.40863825 -62.8902130
Nov 1991 1675.667 1790.281 -20.94370798 -93.6705180
Dec 1991 1813.863 1785.340 24.79248866 3.7309106
Jan 1992 1614.827 1780.398 -191.21787993 25.6469044
Feb 1992 1557.088 1782.084 -242.86167620 17.8658592
Mar 1992 1891.223 1783.770 57.11434230 50.3389993
Apr 1992 1955.981 1785.455 52.32761168 118.1978885
May 1992 1884.714 1792.392 86.53558379 5.7868514
Jun 1992 1623.042 1799.328 18.02650317 -194.3121330
Jul 1992 1903.309 1806.264 137.23971099 -40.1944058
Aug 1992 1996.712 1810.635 205.52731962 -19.4506939
Sep 1992 1703.897 1815.007 -118.04720664 6.9371530
Oct 1992 1810.000 1819.379 -5.77494231 -3.6037907
Nov 1992 1861.601 1824.082 -19.81673954 57.3360665
Dec 1992 1875.122 1828.785 25.36770427 20.9696827
Jan 1993 1705.259 1833.488 -193.28231677 65.0537637
Feb 1993 1618.535 1832.976 -244.76075685 30.3198177
Mar 1993 1836.709 1832.464 54.76209234 -50.5174176
Apr 1993 1957.043 1831.953 50.37489760 74.7153910
May 1993 1917.185 1824.316 85.21463880 7.6548541
Jun 1993 1882.398 1816.678 20.71240377 45.0072934
Jul 1993 1933.009 1809.041 139.71015039 -15.7422489
Aug 1993 1996.167 1803.023 206.62923467 -13.4857245
Sep 1993 1672.841 1797.006 -117.12449191 -7.0403892
Oct 1993 1752.827 1790.988 -4.00487339 -34.1563991
Nov 1993 1720.377 1785.162 -18.56868270 -46.2161648
Dec 1993 1734.292 1779.335 26.01683361 -71.0602561
Jan 1994 1563.365 1773.509 -197.00000572 -13.1439918
Feb 1994 1573.959 1771.119 -247.73735656 50.5773637
Mar 1994 1902.639 1768.729 49.97940839 83.9306035
Apr 1994 1833.888 1766.339 48.15868582 19.3903308
May 1994 1831.049 1766.404 81.00765957 -16.3629183
Jun 1994 1775.755 1766.470 26.53471329 -17.2492473
Jul 1994 1867.508 1766.535 144.13221697 -43.1590263
Aug 1994 1906.608 1762.661 207.17254576 -63.2255956
Sep 1994 1685.632 1758.787 -114.36830731 41.2130170
Oct 1994 1778.546 1754.914 -0.07266117 23.7051303
Nov 1994 1775.995 1749.467 -14.82948167 41.3573998
Dec 1994 1783.350 1744.021 26.10229938 13.2270676
Jan 1995 1548.415 1738.574 -201.27320995 11.1140259
Feb 1995 1496.925 1731.409 -251.17599096 16.6917413
Mar 1995 1798.316 1724.244 44.82817034 29.2435145
Apr 1995 1732.895 1717.079 45.69108517 -29.8754659
May 1995 1772.345 1706.265 76.66645667 -10.5865380
Jun 1995 1761.207 1695.451 32.34238400 33.4138340
Jul 1995 1791.655 1684.636 148.65922959 -41.6407122
Aug 1995 1874.820 1672.804 207.92632695 -5.9100643
Sep 1995 1571.309 1660.971 -111.29612856 21.6341366
Oct 1995 1646.948 1649.138 4.25149256 -6.4417392
Nov 1995 1672.631 1643.456 -10.62239173 39.7971276
Dec 1995 1656.845 1637.774 26.68919498 -7.6184765
Jan 1996 1381.758 1632.092 -211.19675387 -39.1375451
Feb 1996 1360.852 1632.056 -256.65974275 -14.5442294
Mar 1996 1558.575 1632.020 39.06808759 -112.5127329
Apr 1996 1608.420 1631.983 43.40202892 -66.9653473
May 1996 1696.696 1633.187 74.74753041 -11.2382773
Jun 1996 1693.183 1634.390 43.50061072 15.2922138
Jul 1996 1835.516 1635.594 154.22029199 45.7021040
Aug 1996 1942.573 1639.940 205.25246627 97.3802366
Sep 1996 1551.401 1644.287 -112.82659359 19.9406033
Oct 1996 1686.508 1648.634 8.61394077 29.2603758
Nov 1996 1576.204 1654.812 -4.36281377 -74.2448027
Dec 1996 1700.433 1660.990 28.83447595 10.6089745
Jan 1997 1396.588 1667.167 -221.10947723 -49.4700054
Feb 1997 1371.690 1674.183 -262.20632769 -40.2871085
Mar 1997 1707.522 1681.199 33.17151797 -6.8489077
Apr 1997 1654.604 1688.215 40.89953687 -74.5108801
May 1997 1762.903 1697.524 72.53821941 -7.1590928
Jun 1997 1775.800 1706.832 54.29382991 14.6737666
Jul 1997 1934.219 1716.141 159.34172405 58.7363423
Aug 1997 2008.055 1724.314 202.08217460 81.6591503
Sep 1997 1615.924 1732.486 -114.91029023 -1.6521264
Oct 1997 1773.910 1740.659 12.40428662 20.8465553
Nov 1997 1732.368 1745.449 1.30579108 -14.3865379
Dec 1997 1796.626 1750.238 30.42698977 15.9606746
Jan 1998 1570.330 1755.028 -225.90148892 41.2035645
Feb 1998 1412.691 1756.809 -265.26911818 -78.8487419
Mar 1998 1754.641 1758.590 31.74134781 -35.6901436
Apr 1998 1824.932 1760.371 39.73118317 24.8300854
May 1998 1843.289 1764.807 72.25711918 6.2252753
Jun 1998 1825.964 1769.242 57.20137054 -0.4798502
Jul 1998 1968.172 1773.678 161.19016460 33.3034817
Aug 1998 1921.645 1778.645 201.54046795 -58.5409442
Sep 1998 1669.597 1783.613 -116.06624706 2.0506483
Oct 1998 1791.474 1788.580 13.59987420 -10.7055955
Nov 1998 1816.714 1790.702 2.83586667 23.1762232
Dec 1998 1846.754 1792.824 31.55389937 22.3760017
Jan 1999 1599.427 1794.946 -230.08088577 34.5615980
Feb 1999 1548.804 1794.879 -267.77730157 21.7024877
Mar 1999 1832.333 1794.811 30.80777703 6.7138830
Apr 1999 1839.720 1794.744 38.96556087 6.0105730
May 1999 1846.498 1794.890 72.28488236 -20.6771395
Jun 1999 1864.852 1795.037 60.31819758 9.4971542
Jul 1999 1965.743 1795.183 163.14831457 7.4116462
Aug 1999 1949.002 1800.483 201.02781763 -52.5087951
Sep 1999 1607.373 1805.783 -117.27380063 -81.1361151
Oct 1999 1803.664 1811.083 14.69649365 -22.1153476
Nov 1999 1850.309 1821.753 4.21960273 24.3367827
Dec 1999 1836.435 1832.422 32.52198973 -28.5093649
Jan 2000 1541.660 1843.092 -231.90745241 -69.5246834
Feb 2000 1616.928 1856.209 -269.24638671 29.9658371
Mar 2000 1919.538 1869.325 30.13971435 20.0733223
Apr 2000 1971.493 1882.441 38.53807534 50.5135476
May 2000 1992.301 1892.662 72.18977901 27.4496434
Jun 2000 2009.763 1902.882 62.07186899 44.8093528
Jul 2000 2053.996 1913.102 164.61003399 -23.7160128
Aug 2000 2097.471 1921.113 200.34665261 -23.9885243
Sep 2000 1823.706 1929.124 -118.39331328 12.9755487
Oct 2000 1976.997 1937.135 15.24166220 24.6206804
Nov 2000 1981.408 1944.599 5.27794847 31.5312464
Dec 2000 2000.153 1952.063 33.16263684 14.9274104
Jan 2001 1683.148 1959.527 -233.59204193 -42.7870585
Feb 2001 1663.404 1966.423 -270.57813703 -32.4413187
Mar 2001 2007.928 1973.320 29.60434419 5.0038448
$model
Series: x
Regression with ARIMA(0,1,1) errors
Coefficients:
ma1 Month S1-12 C1-12 S2-12 C2-12
-0.4497 0.3528 6.5749 0.1468 -0.8428 -0.1513
s.e. 0.0958 2.2538 11.8652 8.6959 7.0494 6.1778
sigma^2 estimated as 2881: log likelihood=-656.06
AIC=1326.11 AICc=1327.1 BIC=1345.74
$modelfunction
function (x, ...)
{
return(auto.arima(x, xreg = xreg, seasonal = FALSE, ...))
}
<bytecode: 0x000000001df79378>
<environment: 0x0000000021429380>
$lambda
NULL
$x
Jan Feb Mar Apr May Jun Jul
1991 1708.917 1620.586 1972.715 1811.665 1974.964 1862.356 1939.860
1992 1614.827 1557.088 1891.223 1955.981 1884.714 1623.042 1903.309
1993 1705.259 1618.535 1836.709 1957.043 1917.185 1882.398 1933.009
1994 1563.365 1573.959 1902.639 1833.888 1831.049 1775.755 1867.508
1995 1548.415 1496.925 1798.316 1732.895 1772.345 1761.207 1791.655
1996 1381.758 1360.852 1558.575 1608.420 1696.696 1693.183 1835.516
1997 1396.588 1371.690 1707.522 1654.604 1762.903 1775.800 1934.219
1998 1570.330 1412.691 1754.641 1824.932 1843.289 1825.964 1968.172
1999 1599.427 1548.804 1832.333 1839.720 1846.498 1864.852 1965.743
2000 1541.660 1616.928 1919.538 1971.493 1992.301 2009.763 2053.996
2001 1683.148 1663.404 2007.928
Aug Sep Oct Nov Dec
1991 2013.264 1595.657 1724.924 1675.667 1813.863
1992 1996.712 1703.897 1810.000 1861.601 1875.122
1993 1996.167 1672.841 1752.827 1720.377 1734.292
1994 1906.608 1685.632 1778.546 1775.995 1783.350
1995 1874.820 1571.309 1646.948 1672.631 1656.845
1996 1942.573 1551.401 1686.508 1576.204 1700.433
1997 2008.055 1615.924 1773.910 1732.368 1796.626
1998 1921.645 1669.597 1791.474 1816.714 1846.754
1999 1949.002 1607.373 1803.664 1850.309 1836.435
2000 2097.471 1823.706 1976.997 1981.408 2000.153
2001
$series
[1] "."
$m
[1] 12
$fitted
Jan Feb Mar Apr May Jun Jul
1991 1707.022 1656.520 1938.323 1951.936 1905.934 1867.692 1980.642
1992 1566.709 1544.400 1853.324 1869.445 1949.013 1841.362 1836.870
1993 1656.440 1634.683 1927.286 1873.109 1951.877 1864.525 1989.788
1994 1532.935 1501.799 1841.190 1873.236 1882.174 1795.808 1898.802
1995 1567.850 1510.110 1800.824 1800.360 1791.952 1733.079 1861.305
1996 1438.473 1364.658 1660.257 1608.691 1637.628 1635.125 1774.223
1997 1430.157 1373.445 1669.823 1698.349 1703.657 1714.254 1849.600
1998 1530.378 1515.852 1758.061 1764.222 1827.896 1817.551 1922.600
1999 1577.205 1554.594 1851.959 1849.370 1875.120 1843.643 1954.575
2000 1576.150 1522.689 1875.898 1908.363 1974.495 1970.415 2091.036
2001 1731.852 1670.922 1968.933
Aug Sep Oct Nov Dec
1991 2026.019 1695.968 1754.140 1727.190 1747.429
1992 1939.868 1647.924 1792.958 1790.956 1877.869
1993 2023.614 1685.108 1793.439 1759.189 1785.272
1994 1942.773 1601.682 1764.135 1759.970 1812.574
1995 1880.396 1558.456 1683.038 1650.966 1703.054
1996 1857.135 1586.421 1690.552 1678.012 1658.041
1997 1937.055 1659.483 1764.789 1761.372 1777.387
1998 1986.179 1633.411 1784.951 1780.438 1831.972
1999 1996.751 1652.525 1761.611 1776.936 1848.468
2000 2104.542 1782.262 1940.664 1953.355 1999.531
2001
$residuals
Jan Feb Mar Apr May
1991 1.8951444 -35.9342939 34.3921238 -140.2709388 69.0303375
1992 48.1184483 12.6878965 37.8992221 86.5361615 -64.2987132
1993 48.8185660 -16.1475997 -90.5766313 83.9339150 -34.6917757
1994 30.4300226 72.1595366 61.4493162 -39.3477975 -51.1247876
1995 -19.4354071 -13.1847277 -2.5084679 -67.4648032 -19.6070855
1996 -56.7153406 -3.8062111 -101.6823903 -0.2707505 59.0675815
1997 -33.5694391 -1.7550756 37.6990398 -43.7446149 59.2461481
1998 39.9515853 -103.1611071 -3.4203350 60.7101875 15.3927553
1999 22.2224217 -5.7895558 -19.6255969 -9.6496607 -28.6221622
2000 -34.4903046 94.2388727 43.6395936 63.1296543 17.8060806
2001 -48.7036550 -7.5180553 38.9946523
Jun Jul Aug Sep Oct
1991 -5.3360756 -40.7822269 -12.7554470 -100.3107426 -29.2160465
1992 -218.3196866 66.4394283 56.8436188 55.9726347 17.0416870
1993 17.8734265 -56.7793330 -27.4473255 -12.2668492 -40.6116199
1994 -20.0531867 -31.2936088 -36.1650211 83.9497180 14.4112788
1995 28.1282156 -69.6496043 -5.5764121 12.8527606 -36.0897242
1996 58.0579705 61.2926975 85.4384433 -35.0200449 -4.0442003
1997 61.5457460 84.6190219 70.9995815 -43.5591466 9.1205158
1998 8.4131697 45.5721124 -64.5336145 36.1855347 6.5230907
1999 21.2085288 11.1681731 -47.7491011 -45.1521589 42.0533821
2000 39.3476621 -37.0402662 -7.0707223 41.4442434 36.3332055
2001
Nov Dec
1991 -51.5228862 66.4343665
1992 70.6450618 -2.7469887
1993 -38.8120180 -50.9795675
1994 16.0251266 -29.2242369
1995 21.6646633 -46.2088060
1996 -101.8078164 42.3919190
1997 -29.0035829 19.2388415
1998 36.2758040 14.7817327
1999 73.3725220 -12.0333268
2000 28.0528425 0.6220116
2001
attr(,"class")
[1] "stlm"
STLM.forecast2 <- forecast(STLM.fit2, h = n.test,
newxreg = Test.Xreg)
STLM.forecast2$mean
Jan Feb Mar Apr May Jun Jul
2001 1999.378 2030.771 2016.893 2115.862
2002 1722.372 1688.243 1990.391 1999.378 2030.771 2016.893 2115.862
2003 1722.372 1688.243 1990.391 1999.378 2030.771 2016.893 2115.862
2004 1722.372 1688.243 1990.391
Aug Sep Oct Nov Dec
2001 2149.749 1831.360 1966.957 1959.655 1990.394
2002 2149.749 1831.360 1966.957 1959.655 1990.394
2003 2149.749 1831.360 1966.957 1959.655 1990.394
2004
plot(STLM.forecast2)
accuracy(STLM.forecast2$mean, test.ts)
ME RMSE MAE MPE MAPE ACF1
Test set 38.04171 83.77231 70.30234 1.821433 3.555029 0.694755
Theil's U
Test set 0.4885911
Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".