Consider the pigs series — the number of pigs slaughtered in Victoria each month
str(pigs)
## Time-Series [1:188] from 1980 to 1996: 76378 71947 33873 96428 105084 ...
frequency(pigs)
## [1] 12
start(pigs)
## [1] 1980 1
end(pigs)
## [1] 1995 8
autoplot(pigs)
a. Use the ses() function in R to find the optimal values of \(\alpha\) and \(\ell_0\) and generate forecasts for the next four months
# simple exponential for next 4 months
fc <- ses(pigs, h=4)
# displays alpha and initial level
fc$model
## Simple exponential smoothing
##
## Call:
## ses(y = pigs, h = 4)
##
## Smoothing parameters:
## alpha = 0.2971
##
## Initial states:
## l = 77260.0561
##
## sigma: 10308.58
##
## AIC AICc BIC
## 4462.955 4463.086 4472.665
# forecast for next 4 months
forecast(fc)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Sep 1995 98816.41 85605.43 112027.4 78611.97 119020.8
## Oct 1995 98816.41 85034.52 112598.3 77738.83 119894.0
## Nov 1995 98816.41 84486.34 113146.5 76900.46 120732.4
## Dec 1995 98816.41 83958.37 113674.4 76092.99 121539.8
b. Compute a 95% prediction interval for the first forecast using \(\hat{y} ± 1.96s\) where \(s\) is the standard deviation of the residuals. Compare your interval with the interval produced by R
# plot the forecast with fitted values
autoplot(fc) + autolayer(fitted(fc), series="Fitted")
# mean
fc$mean[1]
## [1] 98816.41
# standard deviation of the residuals
sd(fc$residuals)
## [1] 10273.69
# lo 95, hi 95 interval by calculation
c(fc$mean[1] - 1.96*sd(fc$residuals), fc$mean[1] + 1.96*sd(fc$residuals))
## [1] 78679.97 118952.84
# first forecast with interval producted by R
forecast(fc, h=1)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Sep 1995 98816.41 85605.43 112027.4 78611.97 119020.8
The calculated RMSE appears to have a very slight narrower interval
Data set books contains the daily sales of paperback and hardcover books at the same store. The task is to forecast the next four days’ sales for paperback and hardcover books.
a. Plot the series and discuss the main features of the data
head(books)
## Time Series:
## Start = 1
## End = 6
## Frequency = 1
## Paperback Hardcover
## 1 199 139
## 2 172 128
## 3 111 172
## 4 209 139
## 5 161 191
## 6 119 168
autoplot(books)
The sales of both types of books seem trending upward. The peaks and troughs are not identifiable as having seasonal or cyclic pattern.
b. Use the ses() function to forecast each series, and plot the forecasts
Paperback
# paperback series forecast for next 4 days
p_ses <- ses(books[,"Paperback"], h=4)
p_ses
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 31 207.1097 162.4882 251.7311 138.8670 275.3523
## 32 207.1097 161.8589 252.3604 137.9046 276.3147
## 33 207.1097 161.2382 252.9811 136.9554 277.2639
## 34 207.1097 160.6259 253.5935 136.0188 278.2005
# plot forecast
autoplot(p_ses) + autolayer(fitted(p_ses), series="Fitted")
Hardcover
# hardcover series forecast for next 4 days
h_ses <- ses(books[,"Hardcover"], h=4)
h_ses
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 31 239.5601 197.2026 281.9176 174.7799 304.3403
## 32 239.5601 194.9788 284.1414 171.3788 307.7414
## 33 239.5601 192.8607 286.2595 168.1396 310.9806
## 34 239.5601 190.8347 288.2855 165.0410 314.0792
# plot forecast
autoplot(h_ses) + autolayer(fitted(h_ses), series="Fitted")
c. Compute the RMSE values for the training data in each case
Paperback
# RMSE for paperback series
sqrt(mean((p_ses$residuals)^2))
## [1] 33.63769
Hardcover
# RMSE for hardcover series
sqrt(mean((h_ses$residuals)^2))
## [1] 31.93101
We will continue with the daily sales of paperback and hardcover books in data set books.
a. Apply Holt’s linear method to the paperback and hardback series and compute four-day forecasts in each case
Paperback
# paperback series forecast for next 4 days
p_holt <- holt(books[,"Paperback"], h=4)
p_holt
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 31 209.4668 166.6035 252.3301 143.9130 275.0205
## 32 210.7177 167.8544 253.5811 145.1640 276.2715
## 33 211.9687 169.1054 254.8320 146.4149 277.5225
## 34 213.2197 170.3564 256.0830 147.6659 278.7735
# plot forecast
autoplot(p_holt) + autolayer(fitted(p_holt), series="Fitted")
Hardcover
# hardcover series forecast for next 4 days
h_holt <- holt(books[,"Hardcover"], h=4)
h_holt
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 31 250.1739 212.7390 287.6087 192.9222 307.4256
## 32 253.4765 216.0416 290.9113 196.2248 310.7282
## 33 256.7791 219.3442 294.2140 199.5274 314.0308
## 34 260.0817 222.6468 297.5166 202.8300 317.3334
# plot forecast
autoplot(h_holt) + autolayer(fitted(h_holt), series="Fitted")
b. Compare the RMSE measures of Holt’s method for the two series to those of simple exponential smoothing in the previous question. (Remember that Holt’s method is using one more parameter than SES.) Discuss the merits of the two forecasting methods for these data sets
Paperback
# RMSE for paperback series, holt
p_holt_rmse <- accuracy(p_holt)[2]
p_holt_rmse
## [1] 31.13692
Hardcover
# RMSE for hardcover series, holt
h_holt_rmse <- accuracy(h_holt)[2]
h_holt_rmse
## [1] 27.19358
On both paperback and hardcover series, Holt method performs better based on RMSE compared to SES since the trend was considered in using Holt.
c. Compare the forecasts for the two series using both methods. Which do you think is best?
Since the data appears to be trending, holt performs better in forecasting and keeping the upward trend pattern than the simple exponential smoothing which flats the forecast.
d. Calculate a 95% prediction interval for the first forecast for each series, using the RMSE values and assuming normal errors. Compare your intervals with those produced using ses and holt
Paperback
# mean
p_holt$mean[1]
## [1] 209.4668
# paperback: lo 95, hi 95 interval by calculation
c(p_holt$mean[1] - 1.96*p_holt_rmse,
p_holt$mean[1] + 1.96*p_holt_rmse)
## [1] 148.4384 270.4951
# paperback: lo 95, hi 95 interval produced by ses
c(p_ses$lower[1,"95%"],p_ses$upper[1,"95%"])
## 95% 95%
## 138.8670 275.3523
# paperback: lo 95, hi 95 interval produced by holt
c(p_holt$lower[1,"95%"],p_holt$upper[1,"95%"])
## 95% 95%
## 143.9130 275.0205
Hardcover
# mean
h_holt$mean[1]
## [1] 250.1739
# hardcover: lo 95, hi 95 interval by calculation
c(h_holt$mean[1] - 1.96*h_holt_rmse,
h_holt$mean[1] + 1.96*h_holt_rmse)
## [1] 196.8745 303.4733
# hardcover: lo 95, hi 95 interval produced by ses
c(h_ses$lower[1,"95%"],h_ses$upper[1,"95%"])
## 95% 95%
## 174.7799 304.3403
# hardcover: lo 95, hi 95 interval produced by holt
c(h_holt$lower[1,"95%"],h_holt$upper[1,"95%"])
## 95% 95%
## 192.9222 307.4256
On both paperback and hardcover series, the 95% interval appears narrower than SES, and could suggest that Holt likely would yield more accurate forecasts
For this exercise use data set eggs, the price of a dozen eggs in the United States from 1900–1993. Experiment with the various options in the holt() function to see how much the forecasts change with damped trend, or with a Box-Cox transformation. Try to develop an intuition of what each argument is doing to the forecasts.
[Hint: use h=100 when calling holt() so you can clearly see the differences between the various options when plotting the forecasts.]
Which model gives the best RMSE?
head(eggs)
## Time Series:
## Start = 1900
## End = 1905
## Frequency = 1
## [1] 276.79 315.42 314.87 321.25 314.54 317.92
autoplot(eggs)
holt1 <- holt(eggs, h = 100)
summary(holt1)
##
## Forecast method: Holt's method
##
## Model Information:
## Holt's method
##
## Call:
## holt(y = eggs, h = 100)
##
## Smoothing parameters:
## alpha = 0.8124
## beta = 1e-04
##
## Initial states:
## l = 314.7232
## b = -2.7222
##
## sigma: 27.1665
##
## AIC AICc BIC
## 1053.755 1054.437 1066.472
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 0.04499087 26.58219 19.18491 -1.142201 9.653791 0.9463626
## ACF1
## Training set 0.01348202
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 1994 59.78553313 24.970286 94.60078 6.540207 113.0309
## 1995 57.06372643 12.206005 101.92145 -11.540238 125.6677
## 1996 54.34191973 1.308668 107.37517 -26.765440 135.4493
## 1997 51.62011302 -8.488401 111.72863 -40.307926 143.5482
## 1998 48.89830632 -17.537664 115.33428 -52.706742 150.5034
## 1999 46.17649962 -26.035964 118.38896 -64.262933 156.6159
## 2000 43.45469292 -34.106500 121.01589 -75.164916 162.0743
## 2001 40.73288622 -41.832449 123.29822 -85.539898 167.0057
## 2002 38.01107951 -49.273098 125.29526 -95.478551 171.5007
## 2003 35.28927281 -56.472472 127.05102 -105.048206 175.6268
## 2004 32.56746611 -63.464327 128.59926 -114.300487 179.4354
## 2005 29.84565941 -70.275216 129.96654 -123.276007 182.9673
## 2006 27.12385271 -76.926479 131.17418 -132.007398 186.2551
## 2007 24.40204600 -83.435566 132.23966 -140.521350 189.3254
## 2008 21.68023930 -89.816966 133.17744 -148.840022 192.2005
## 2009 18.95843260 -96.082866 133.99973 -156.982051 194.8989
## 2010 16.23662590 -102.243631 134.71688 -164.963291 197.4365
## 2011 13.51481920 -108.308165 135.33780 -172.797358 199.8270
## 2012 10.79301249 -114.284184 135.87021 -180.496053 202.0821
## 2013 8.07120579 -120.178426 136.32084 -188.069681 204.2121
## 2014 5.34939909 -125.996817 136.69562 -195.527304 206.2261
## 2015 2.62759239 -131.744601 136.99979 -202.876944 208.1321
## 2016 -0.09421431 -137.426446 137.23802 -210.125737 209.9373
## 2017 -2.81602102 -143.046526 137.41448 -217.280071 211.6480
## 2018 -5.53782772 -148.608596 137.53294 -224.345686 213.2700
## 2019 -8.25963442 -154.116046 137.59678 -231.327766 214.8085
## 2020 -10.98144112 -159.571946 137.60906 -238.231008 216.2681
## 2021 -13.70324782 -164.979092 137.57260 -245.059687 217.6532
## 2022 -16.42505453 -170.340036 137.48993 -251.817706 218.9676
## 2023 -19.14686123 -175.657116 137.36339 -258.508640 220.2149
## 2024 -21.86866793 -180.932478 137.19514 -265.135773 221.3984
## 2025 -24.59047463 -186.168101 136.98715 -271.702130 222.5212
## 2026 -27.31228133 -191.365811 136.74125 -278.210504 223.5859
## 2027 -30.03408804 -196.527300 136.45912 -284.663482 224.5953
## 2028 -32.75589474 -201.654137 136.14235 -291.063466 225.5517
## 2029 -35.47770144 -206.747783 135.79238 -297.412688 226.4573
## 2030 -38.19950814 -211.809598 135.41058 -303.713228 227.3142
## 2031 -40.92131484 -216.840851 134.99822 -309.967029 228.1244
## 2032 -43.64312155 -221.842733 134.55649 -316.175908 228.8897
## 2033 -46.36492825 -226.816355 134.08650 -322.341569 229.6117
## 2034 -49.08673495 -231.762762 133.58929 -328.465610 230.2921
## 2035 -51.80854165 -236.682939 133.06586 -334.549533 230.9324
## 2036 -54.53034835 -241.577809 132.51711 -340.594753 231.5341
## 2037 -57.25215506 -246.448244 131.94393 -346.602603 232.0983
## 2038 -59.97396176 -251.295068 131.34714 -352.574344 232.6264
## 2039 -62.69576846 -256.119059 130.72752 -358.511164 233.1196
## 2040 -65.41757516 -260.920954 130.08580 -364.414190 233.5790
## 2041 -68.13938186 -265.701450 129.42269 -370.284491 234.0057
## 2042 -70.86118857 -270.461210 128.73883 -376.123079 234.4007
## 2043 -73.58299527 -275.200863 128.03487 -381.930915 234.7649
## 2044 -76.30480197 -279.921006 127.31140 -387.708914 235.0993
## 2045 -79.02660867 -284.622209 126.56899 -393.457946 235.4047
## 2046 -81.74841537 -289.305013 125.80818 -399.178839 235.6820
## 2047 -84.47022208 -293.969936 125.02949 -404.872385 235.9319
## 2048 -87.19202878 -298.617469 124.23341 -410.539337 236.1553
## 2049 -89.91383548 -303.248085 123.42041 -416.180415 236.3527
## 2050 -92.63564218 -307.862233 122.59095 -421.796308 236.5250
## 2051 -95.35744888 -312.460345 121.74545 -427.387675 236.6728
## 2052 -98.07925559 -317.042831 120.88432 -432.955146 236.7966
## 2053 -100.80106229 -321.610088 120.00796 -438.499326 236.8972
## 2054 -103.52286899 -326.162494 119.11676 -444.020793 236.9751
## 2055 -106.24467569 -330.700413 118.21106 -449.520103 237.0308
## 2056 -108.96648239 -335.224193 117.29123 -454.997790 237.0648
## 2057 -111.68828910 -339.734170 116.35759 -460.454367 237.0778
## 2058 -114.41009580 -344.230666 115.41047 -465.890327 237.0701
## 2059 -117.13190250 -348.713991 114.45019 -471.306143 237.0423
## 2060 -119.85370920 -353.184443 113.47702 -476.702272 236.9949
## 2061 -122.57551590 -357.642310 112.49128 -482.079153 236.9281
## 2062 -125.29732261 -362.087868 111.49322 -487.437211 236.8426
## 2063 -128.01912931 -366.521384 110.48313 -492.776852 236.7386
## 2064 -130.74093601 -370.943117 109.46124 -498.098471 236.6166
## 2065 -133.46274271 -375.353314 108.42783 -503.402447 236.4770
## 2066 -136.18454941 -379.752215 107.38312 -508.689149 236.3200
## 2067 -138.90635612 -384.140052 106.32734 -513.958929 236.1462
## 2068 -141.62816282 -388.517050 105.26072 -519.212132 235.9558
## 2069 -144.34996952 -392.883424 104.18349 -524.449088 235.7491
## 2070 -147.07177622 -397.239385 103.09583 -529.670117 235.5266
## 2071 -149.79358292 -401.585134 101.99797 -534.875530 235.2884
## 2072 -152.51538963 -405.920870 100.89009 -540.065628 235.0348
## 2073 -155.23719633 -410.246781 99.77239 -545.240700 234.7663
## 2074 -157.95900303 -414.563051 98.64505 -550.401029 234.4830
## 2075 -160.68080973 -418.869861 97.50824 -555.546889 234.1853
## 2076 -163.40261643 -423.167382 96.36215 -560.678543 233.8733
## 2077 -166.12442314 -427.455784 95.20694 -565.796249 233.5474
## 2078 -168.84622984 -431.735228 94.04277 -570.900257 233.2078
## 2079 -171.56803654 -436.005874 92.86980 -575.990809 232.8547
## 2080 -174.28984324 -440.267874 91.68819 -581.068139 232.4885
## 2081 -177.01164994 -444.521379 90.49808 -586.132476 232.1092
## 2082 -179.73345665 -448.766534 89.29962 -591.184043 231.7171
## 2083 -182.45526335 -453.003480 88.09295 -596.223054 231.3125
## 2084 -185.17707005 -457.232353 86.87821 -601.249720 230.8956
## 2085 -187.89887675 -461.453288 85.65553 -606.264245 230.4665
## 2086 -190.62068345 -465.666414 84.42505 -611.266828 230.0255
## 2087 -193.34249016 -469.871857 83.18688 -616.257661 229.5727
## 2088 -196.06429686 -474.069741 81.94115 -621.236934 229.1083
## 2089 -198.78610356 -478.260186 80.68798 -626.204828 228.6326
## 2090 -201.50791026 -482.443308 79.42749 -631.161524 228.1457
## 2091 -204.22971696 -486.619220 78.15979 -636.107193 227.6478
## 2092 -206.95152367 -490.788035 76.88499 -641.042007 227.1390
## 2093 -209.67333037 -494.949859 75.60320 -645.966131 226.6195
holt1
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 1994 59.78553313 24.970286 94.60078 6.540207 113.0309
## 1995 57.06372643 12.206005 101.92145 -11.540238 125.6677
## 1996 54.34191973 1.308668 107.37517 -26.765440 135.4493
## 1997 51.62011302 -8.488401 111.72863 -40.307926 143.5482
## 1998 48.89830632 -17.537664 115.33428 -52.706742 150.5034
## 1999 46.17649962 -26.035964 118.38896 -64.262933 156.6159
## 2000 43.45469292 -34.106500 121.01589 -75.164916 162.0743
## 2001 40.73288622 -41.832449 123.29822 -85.539898 167.0057
## 2002 38.01107951 -49.273098 125.29526 -95.478551 171.5007
## 2003 35.28927281 -56.472472 127.05102 -105.048206 175.6268
## 2004 32.56746611 -63.464327 128.59926 -114.300487 179.4354
## 2005 29.84565941 -70.275216 129.96654 -123.276007 182.9673
## 2006 27.12385271 -76.926479 131.17418 -132.007398 186.2551
## 2007 24.40204600 -83.435566 132.23966 -140.521350 189.3254
## 2008 21.68023930 -89.816966 133.17744 -148.840022 192.2005
## 2009 18.95843260 -96.082866 133.99973 -156.982051 194.8989
## 2010 16.23662590 -102.243631 134.71688 -164.963291 197.4365
## 2011 13.51481920 -108.308165 135.33780 -172.797358 199.8270
## 2012 10.79301249 -114.284184 135.87021 -180.496053 202.0821
## 2013 8.07120579 -120.178426 136.32084 -188.069681 204.2121
## 2014 5.34939909 -125.996817 136.69562 -195.527304 206.2261
## 2015 2.62759239 -131.744601 136.99979 -202.876944 208.1321
## 2016 -0.09421431 -137.426446 137.23802 -210.125737 209.9373
## 2017 -2.81602102 -143.046526 137.41448 -217.280071 211.6480
## 2018 -5.53782772 -148.608596 137.53294 -224.345686 213.2700
## 2019 -8.25963442 -154.116046 137.59678 -231.327766 214.8085
## 2020 -10.98144112 -159.571946 137.60906 -238.231008 216.2681
## 2021 -13.70324782 -164.979092 137.57260 -245.059687 217.6532
## 2022 -16.42505453 -170.340036 137.48993 -251.817706 218.9676
## 2023 -19.14686123 -175.657116 137.36339 -258.508640 220.2149
## 2024 -21.86866793 -180.932478 137.19514 -265.135773 221.3984
## 2025 -24.59047463 -186.168101 136.98715 -271.702130 222.5212
## 2026 -27.31228133 -191.365811 136.74125 -278.210504 223.5859
## 2027 -30.03408804 -196.527300 136.45912 -284.663482 224.5953
## 2028 -32.75589474 -201.654137 136.14235 -291.063466 225.5517
## 2029 -35.47770144 -206.747783 135.79238 -297.412688 226.4573
## 2030 -38.19950814 -211.809598 135.41058 -303.713228 227.3142
## 2031 -40.92131484 -216.840851 134.99822 -309.967029 228.1244
## 2032 -43.64312155 -221.842733 134.55649 -316.175908 228.8897
## 2033 -46.36492825 -226.816355 134.08650 -322.341569 229.6117
## 2034 -49.08673495 -231.762762 133.58929 -328.465610 230.2921
## 2035 -51.80854165 -236.682939 133.06586 -334.549533 230.9324
## 2036 -54.53034835 -241.577809 132.51711 -340.594753 231.5341
## 2037 -57.25215506 -246.448244 131.94393 -346.602603 232.0983
## 2038 -59.97396176 -251.295068 131.34714 -352.574344 232.6264
## 2039 -62.69576846 -256.119059 130.72752 -358.511164 233.1196
## 2040 -65.41757516 -260.920954 130.08580 -364.414190 233.5790
## 2041 -68.13938186 -265.701450 129.42269 -370.284491 234.0057
## 2042 -70.86118857 -270.461210 128.73883 -376.123079 234.4007
## 2043 -73.58299527 -275.200863 128.03487 -381.930915 234.7649
## 2044 -76.30480197 -279.921006 127.31140 -387.708914 235.0993
## 2045 -79.02660867 -284.622209 126.56899 -393.457946 235.4047
## 2046 -81.74841537 -289.305013 125.80818 -399.178839 235.6820
## 2047 -84.47022208 -293.969936 125.02949 -404.872385 235.9319
## 2048 -87.19202878 -298.617469 124.23341 -410.539337 236.1553
## 2049 -89.91383548 -303.248085 123.42041 -416.180415 236.3527
## 2050 -92.63564218 -307.862233 122.59095 -421.796308 236.5250
## 2051 -95.35744888 -312.460345 121.74545 -427.387675 236.6728
## 2052 -98.07925559 -317.042831 120.88432 -432.955146 236.7966
## 2053 -100.80106229 -321.610088 120.00796 -438.499326 236.8972
## 2054 -103.52286899 -326.162494 119.11676 -444.020793 236.9751
## 2055 -106.24467569 -330.700413 118.21106 -449.520103 237.0308
## 2056 -108.96648239 -335.224193 117.29123 -454.997790 237.0648
## 2057 -111.68828910 -339.734170 116.35759 -460.454367 237.0778
## 2058 -114.41009580 -344.230666 115.41047 -465.890327 237.0701
## 2059 -117.13190250 -348.713991 114.45019 -471.306143 237.0423
## 2060 -119.85370920 -353.184443 113.47702 -476.702272 236.9949
## 2061 -122.57551590 -357.642310 112.49128 -482.079153 236.9281
## 2062 -125.29732261 -362.087868 111.49322 -487.437211 236.8426
## 2063 -128.01912931 -366.521384 110.48313 -492.776852 236.7386
## 2064 -130.74093601 -370.943117 109.46124 -498.098471 236.6166
## 2065 -133.46274271 -375.353314 108.42783 -503.402447 236.4770
## 2066 -136.18454941 -379.752215 107.38312 -508.689149 236.3200
## 2067 -138.90635612 -384.140052 106.32734 -513.958929 236.1462
## 2068 -141.62816282 -388.517050 105.26072 -519.212132 235.9558
## 2069 -144.34996952 -392.883424 104.18349 -524.449088 235.7491
## 2070 -147.07177622 -397.239385 103.09583 -529.670117 235.5266
## 2071 -149.79358292 -401.585134 101.99797 -534.875530 235.2884
## 2072 -152.51538963 -405.920870 100.89009 -540.065628 235.0348
## 2073 -155.23719633 -410.246781 99.77239 -545.240700 234.7663
## 2074 -157.95900303 -414.563051 98.64505 -550.401029 234.4830
## 2075 -160.68080973 -418.869861 97.50824 -555.546889 234.1853
## 2076 -163.40261643 -423.167382 96.36215 -560.678543 233.8733
## 2077 -166.12442314 -427.455784 95.20694 -565.796249 233.5474
## 2078 -168.84622984 -431.735228 94.04277 -570.900257 233.2078
## 2079 -171.56803654 -436.005874 92.86980 -575.990809 232.8547
## 2080 -174.28984324 -440.267874 91.68819 -581.068139 232.4885
## 2081 -177.01164994 -444.521379 90.49808 -586.132476 232.1092
## 2082 -179.73345665 -448.766534 89.29962 -591.184043 231.7171
## 2083 -182.45526335 -453.003480 88.09295 -596.223054 231.3125
## 2084 -185.17707005 -457.232353 86.87821 -601.249720 230.8956
## 2085 -187.89887675 -461.453288 85.65553 -606.264245 230.4665
## 2086 -190.62068345 -465.666414 84.42505 -611.266828 230.0255
## 2087 -193.34249016 -469.871857 83.18688 -616.257661 229.5727
## 2088 -196.06429686 -474.069741 81.94115 -621.236934 229.1083
## 2089 -198.78610356 -478.260186 80.68798 -626.204828 228.6326
## 2090 -201.50791026 -482.443308 79.42749 -631.161524 228.1457
## 2091 -204.22971696 -486.619220 78.15979 -636.107193 227.6478
## 2092 -206.95152367 -490.788035 76.88499 -641.042007 227.1390
## 2093 -209.67333037 -494.949859 75.60320 -645.966131 226.6195
holt1_plot <- autoplot(holt1) +
autolayer(holt1$fitted, series="Fitted") +
labs(title = "Holt -no damped, no box-cox", x = accuracy(holt1)[2])
holt2 <- holt(eggs, damped = TRUE, h = 100)
summary(holt2)
##
## Forecast method: Damped Holt's method
##
## Model Information:
## Damped Holt's method
##
## Call:
## holt(y = eggs, h = 100, damped = TRUE)
##
## Smoothing parameters:
## alpha = 0.8462
## beta = 0.004
## phi = 0.8
##
## Initial states:
## l = 276.9842
## b = 4.9966
##
## sigma: 27.2755
##
## AIC AICc BIC
## 1055.458 1056.423 1070.718
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -2.891496 26.54019 19.2795 -2.907633 10.01894 0.9510287
## ACF1
## Training set -0.003195358
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 1994 62.84884 27.8938665 97.80381 9.389822 116.3079
## 1995 62.79968 16.9363788 108.66299 -7.342188 132.9416
## 1996 62.76036 8.0760016 117.44472 -20.872149 146.3929
## 1997 62.72890 0.4263979 125.03140 -32.554554 158.0124
## 1998 62.70373 -6.4067675 131.81423 -42.991656 168.3991
## 1999 62.68360 -12.6402008 138.00740 -52.514212 177.8814
## 2000 62.66749 -18.4083657 143.74335 -61.327332 186.6623
## 2001 62.65461 -23.8016345 149.11085 -69.568803 194.8780
## 2002 62.64430 -28.8842950 154.17289 -77.336605 202.6252
## 2003 62.63605 -33.7040638 158.97616 -84.703440 209.9755
## 2004 62.62945 -38.2975438 163.55645 -91.725068 216.9840
## 2005 62.62417 -42.6935603 167.94191 -98.445402 223.6938
## 2006 62.61995 -46.9153057 172.15521 -104.899769 230.1397
## 2007 62.61657 -50.9817746 176.21492 -111.117108 236.3503
## 2008 62.61387 -54.9087594 180.13650 -117.121483 242.3492
## 2009 62.61171 -58.7095595 183.93298 -122.933160 248.1566
## 2010 62.60998 -62.3954996 187.61546 -128.569404 253.7894
## 2011 62.60860 -65.9763173 191.19351 -134.045059 259.2623
## 2012 62.60749 -69.4604571 194.67544 -139.373005 264.5880
## 2013 62.60660 -72.8552982 198.06851 -144.564498 269.7777
## 2014 62.60590 -76.1673328 201.37913 -149.629443 274.8412
## 2015 62.60533 -79.4023080 204.61297 -154.576610 279.7873
## 2016 62.60488 -82.5653397 207.77509 -159.413810 284.6236
## 2017 62.60451 -85.6610050 210.87003 -164.148030 289.3571
## 2018 62.60422 -88.6934183 213.90187 -168.785552 293.9940
## 2019 62.60399 -91.6662933 216.87428 -173.332049 298.5400
## 2020 62.60381 -94.5829961 219.79061 -177.792663 303.0003
## 2021 62.60366 -97.4465882 222.65390 -182.172070 307.3794
## 2022 62.60354 -100.2598639 225.46694 -186.474541 311.6816
## 2023 62.60344 -103.0253816 228.23227 -190.703985 315.9109
## 2024 62.60337 -105.7454907 230.95223 -194.863993 320.0707
## 2025 62.60331 -108.4223544 233.62897 -198.957870 324.1645
## 2026 62.60326 -111.0579701 236.26449 -202.988671 328.1952
## 2027 62.60322 -113.6541863 238.86062 -206.959220 332.1657
## 2028 62.60319 -116.2127174 241.41909 -210.872140 336.0785
## 2029 62.60316 -118.7351575 243.94148 -214.729866 339.9362
## 2030 62.60314 -121.2229914 246.42928 -218.534669 343.7410
## 2031 62.60313 -123.6776050 248.88386 -222.288668 347.4949
## 2032 62.60311 -126.1002941 251.30652 -225.993844 351.2001
## 2033 62.60310 -128.4922724 253.69848 -229.652054 354.8583
## 2034 62.60310 -130.8546789 256.06087 -233.265039 358.4712
## 2035 62.60309 -133.1885838 258.39476 -236.834435 362.0406
## 2036 62.60308 -135.4949941 260.70116 -240.361782 365.5679
## 2037 62.60308 -137.7748593 262.98102 -243.848533 369.0547
## 2038 62.60308 -140.0290751 265.23523 -247.296057 372.5022
## 2039 62.60307 -142.2584882 267.46464 -250.705648 375.9118
## 2040 62.60307 -144.4638997 269.67004 -254.078533 379.2847
## 2041 62.60307 -146.6460685 271.85221 -257.415871 382.6220
## 2042 62.60307 -148.8057141 274.01185 -260.718763 385.9249
## 2043 62.60307 -150.9435200 276.14965 -263.988255 389.1944
## 2044 62.60307 -153.0601355 278.26627 -267.225338 392.4315
## 2045 62.60307 -155.1561786 280.36231 -270.430959 395.6371
## 2046 62.60307 -157.2322378 282.43837 -273.606018 398.8121
## 2047 62.60306 -159.2888738 284.49500 -276.751371 401.9575
## 2048 62.60306 -161.3266220 286.53275 -279.867837 405.0740
## 2049 62.60306 -163.3459932 288.55212 -282.956199 408.1623
## 2050 62.60306 -165.3474759 290.55360 -286.017203 411.2233
## 2051 62.60306 -167.3315372 292.53766 -289.051562 414.2577
## 2052 62.60306 -169.2986243 294.50475 -292.059962 417.2661
## 2053 62.60306 -171.2491656 296.45529 -295.043058 420.2492
## 2054 62.60306 -173.1835715 298.38970 -298.001476 423.2076
## 2055 62.60306 -175.1022361 300.30836 -300.935821 426.1419
## 2056 62.60306 -177.0055375 302.21166 -303.846669 429.0528
## 2057 62.60306 -178.8938390 304.09997 -306.734577 431.9407
## 2058 62.60306 -180.7674896 305.97362 -309.600078 434.8062
## 2059 62.60306 -182.6268253 307.83295 -312.443686 437.6498
## 2060 62.60306 -184.4721691 309.67830 -315.265896 440.4720
## 2061 62.60306 -186.3038323 311.50996 -318.067183 443.2733
## 2062 62.60306 -188.1221147 313.32824 -320.848006 446.0541
## 2063 62.60306 -189.9273054 315.13343 -323.608807 448.8149
## 2064 62.60306 -191.7196831 316.92581 -326.350012 451.5561
## 2065 62.60306 -193.4995169 318.70564 -329.072033 454.2782
## 2066 62.60306 -195.2670664 320.47319 -331.775267 456.9814
## 2067 62.60306 -197.0225826 322.22871 -334.460097 459.6662
## 2068 62.60306 -198.7663080 323.97243 -337.126895 462.3330
## 2069 62.60306 -200.4984769 325.70460 -339.776019 464.9821
## 2070 62.60306 -202.2193162 327.42544 -342.407816 467.6139
## 2071 62.60306 -203.9290453 329.13517 -345.022621 470.2287
## 2072 62.60306 -205.6278766 330.83400 -347.620759 472.8269
## 2073 62.60306 -207.3160160 332.52214 -350.202545 475.4087
## 2074 62.60306 -208.9936627 334.19979 -352.768284 477.9744
## 2075 62.60306 -210.6610101 335.86714 -355.318272 480.5244
## 2076 62.60306 -212.3182455 337.52437 -357.852795 483.0589
## 2077 62.60306 -213.9655507 339.17168 -360.372131 485.5783
## 2078 62.60306 -215.6031021 340.80923 -362.876550 488.0827
## 2079 62.60306 -217.2310709 342.43720 -365.366313 490.5724
## 2080 62.60306 -218.8496235 344.05575 -367.841676 493.0478
## 2081 62.60306 -220.4589213 345.66505 -370.302884 495.5090
## 2082 62.60306 -222.0591213 347.26525 -372.750179 497.9563
## 2083 62.60306 -223.6503761 348.85650 -375.183793 500.3899
## 2084 62.60306 -225.2328340 350.43896 -377.603954 502.8101
## 2085 62.60306 -226.8066394 352.01277 -380.010881 505.2170
## 2086 62.60306 -228.3719326 353.57806 -382.404791 507.6109
## 2087 62.60306 -229.9288503 355.13498 -384.785891 509.9920
## 2088 62.60306 -231.4775255 356.68365 -387.154385 512.3605
## 2089 62.60306 -233.0180877 358.22421 -389.510472 514.7166
## 2090 62.60306 -234.5506631 359.75679 -391.854344 517.0605
## 2091 62.60306 -236.0753747 361.28150 -394.186189 519.3923
## 2092 62.60306 -237.5923423 362.79847 -396.506191 521.7123
## 2093 62.60306 -239.1016828 364.30781 -398.814528 524.0207
holt2
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 1994 62.84884 27.8938665 97.80381 9.389822 116.3079
## 1995 62.79968 16.9363788 108.66299 -7.342188 132.9416
## 1996 62.76036 8.0760016 117.44472 -20.872149 146.3929
## 1997 62.72890 0.4263979 125.03140 -32.554554 158.0124
## 1998 62.70373 -6.4067675 131.81423 -42.991656 168.3991
## 1999 62.68360 -12.6402008 138.00740 -52.514212 177.8814
## 2000 62.66749 -18.4083657 143.74335 -61.327332 186.6623
## 2001 62.65461 -23.8016345 149.11085 -69.568803 194.8780
## 2002 62.64430 -28.8842950 154.17289 -77.336605 202.6252
## 2003 62.63605 -33.7040638 158.97616 -84.703440 209.9755
## 2004 62.62945 -38.2975438 163.55645 -91.725068 216.9840
## 2005 62.62417 -42.6935603 167.94191 -98.445402 223.6938
## 2006 62.61995 -46.9153057 172.15521 -104.899769 230.1397
## 2007 62.61657 -50.9817746 176.21492 -111.117108 236.3503
## 2008 62.61387 -54.9087594 180.13650 -117.121483 242.3492
## 2009 62.61171 -58.7095595 183.93298 -122.933160 248.1566
## 2010 62.60998 -62.3954996 187.61546 -128.569404 253.7894
## 2011 62.60860 -65.9763173 191.19351 -134.045059 259.2623
## 2012 62.60749 -69.4604571 194.67544 -139.373005 264.5880
## 2013 62.60660 -72.8552982 198.06851 -144.564498 269.7777
## 2014 62.60590 -76.1673328 201.37913 -149.629443 274.8412
## 2015 62.60533 -79.4023080 204.61297 -154.576610 279.7873
## 2016 62.60488 -82.5653397 207.77509 -159.413810 284.6236
## 2017 62.60451 -85.6610050 210.87003 -164.148030 289.3571
## 2018 62.60422 -88.6934183 213.90187 -168.785552 293.9940
## 2019 62.60399 -91.6662933 216.87428 -173.332049 298.5400
## 2020 62.60381 -94.5829961 219.79061 -177.792663 303.0003
## 2021 62.60366 -97.4465882 222.65390 -182.172070 307.3794
## 2022 62.60354 -100.2598639 225.46694 -186.474541 311.6816
## 2023 62.60344 -103.0253816 228.23227 -190.703985 315.9109
## 2024 62.60337 -105.7454907 230.95223 -194.863993 320.0707
## 2025 62.60331 -108.4223544 233.62897 -198.957870 324.1645
## 2026 62.60326 -111.0579701 236.26449 -202.988671 328.1952
## 2027 62.60322 -113.6541863 238.86062 -206.959220 332.1657
## 2028 62.60319 -116.2127174 241.41909 -210.872140 336.0785
## 2029 62.60316 -118.7351575 243.94148 -214.729866 339.9362
## 2030 62.60314 -121.2229914 246.42928 -218.534669 343.7410
## 2031 62.60313 -123.6776050 248.88386 -222.288668 347.4949
## 2032 62.60311 -126.1002941 251.30652 -225.993844 351.2001
## 2033 62.60310 -128.4922724 253.69848 -229.652054 354.8583
## 2034 62.60310 -130.8546789 256.06087 -233.265039 358.4712
## 2035 62.60309 -133.1885838 258.39476 -236.834435 362.0406
## 2036 62.60308 -135.4949941 260.70116 -240.361782 365.5679
## 2037 62.60308 -137.7748593 262.98102 -243.848533 369.0547
## 2038 62.60308 -140.0290751 265.23523 -247.296057 372.5022
## 2039 62.60307 -142.2584882 267.46464 -250.705648 375.9118
## 2040 62.60307 -144.4638997 269.67004 -254.078533 379.2847
## 2041 62.60307 -146.6460685 271.85221 -257.415871 382.6220
## 2042 62.60307 -148.8057141 274.01185 -260.718763 385.9249
## 2043 62.60307 -150.9435200 276.14965 -263.988255 389.1944
## 2044 62.60307 -153.0601355 278.26627 -267.225338 392.4315
## 2045 62.60307 -155.1561786 280.36231 -270.430959 395.6371
## 2046 62.60307 -157.2322378 282.43837 -273.606018 398.8121
## 2047 62.60306 -159.2888738 284.49500 -276.751371 401.9575
## 2048 62.60306 -161.3266220 286.53275 -279.867837 405.0740
## 2049 62.60306 -163.3459932 288.55212 -282.956199 408.1623
## 2050 62.60306 -165.3474759 290.55360 -286.017203 411.2233
## 2051 62.60306 -167.3315372 292.53766 -289.051562 414.2577
## 2052 62.60306 -169.2986243 294.50475 -292.059962 417.2661
## 2053 62.60306 -171.2491656 296.45529 -295.043058 420.2492
## 2054 62.60306 -173.1835715 298.38970 -298.001476 423.2076
## 2055 62.60306 -175.1022361 300.30836 -300.935821 426.1419
## 2056 62.60306 -177.0055375 302.21166 -303.846669 429.0528
## 2057 62.60306 -178.8938390 304.09997 -306.734577 431.9407
## 2058 62.60306 -180.7674896 305.97362 -309.600078 434.8062
## 2059 62.60306 -182.6268253 307.83295 -312.443686 437.6498
## 2060 62.60306 -184.4721691 309.67830 -315.265896 440.4720
## 2061 62.60306 -186.3038323 311.50996 -318.067183 443.2733
## 2062 62.60306 -188.1221147 313.32824 -320.848006 446.0541
## 2063 62.60306 -189.9273054 315.13343 -323.608807 448.8149
## 2064 62.60306 -191.7196831 316.92581 -326.350012 451.5561
## 2065 62.60306 -193.4995169 318.70564 -329.072033 454.2782
## 2066 62.60306 -195.2670664 320.47319 -331.775267 456.9814
## 2067 62.60306 -197.0225826 322.22871 -334.460097 459.6662
## 2068 62.60306 -198.7663080 323.97243 -337.126895 462.3330
## 2069 62.60306 -200.4984769 325.70460 -339.776019 464.9821
## 2070 62.60306 -202.2193162 327.42544 -342.407816 467.6139
## 2071 62.60306 -203.9290453 329.13517 -345.022621 470.2287
## 2072 62.60306 -205.6278766 330.83400 -347.620759 472.8269
## 2073 62.60306 -207.3160160 332.52214 -350.202545 475.4087
## 2074 62.60306 -208.9936627 334.19979 -352.768284 477.9744
## 2075 62.60306 -210.6610101 335.86714 -355.318272 480.5244
## 2076 62.60306 -212.3182455 337.52437 -357.852795 483.0589
## 2077 62.60306 -213.9655507 339.17168 -360.372131 485.5783
## 2078 62.60306 -215.6031021 340.80923 -362.876550 488.0827
## 2079 62.60306 -217.2310709 342.43720 -365.366313 490.5724
## 2080 62.60306 -218.8496235 344.05575 -367.841676 493.0478
## 2081 62.60306 -220.4589213 345.66505 -370.302884 495.5090
## 2082 62.60306 -222.0591213 347.26525 -372.750179 497.9563
## 2083 62.60306 -223.6503761 348.85650 -375.183793 500.3899
## 2084 62.60306 -225.2328340 350.43896 -377.603954 502.8101
## 2085 62.60306 -226.8066394 352.01277 -380.010881 505.2170
## 2086 62.60306 -228.3719326 353.57806 -382.404791 507.6109
## 2087 62.60306 -229.9288503 355.13498 -384.785891 509.9920
## 2088 62.60306 -231.4775255 356.68365 -387.154385 512.3605
## 2089 62.60306 -233.0180877 358.22421 -389.510472 514.7166
## 2090 62.60306 -234.5506631 359.75679 -391.854344 517.0605
## 2091 62.60306 -236.0753747 361.28150 -394.186189 519.3923
## 2092 62.60306 -237.5923423 362.79847 -396.506191 521.7123
## 2093 62.60306 -239.1016828 364.30781 -398.814528 524.0207
holt2_plot <- autoplot(holt2) +
autolayer(holt2$fitted, series="Fitted") +
labs(title = "Holt -with damped, no box-cox", x = accuracy(holt2)[2])
holt3 <- holt(eggs, damped = FALSE, lambda = "auto", h = 100)
summary(holt3)
##
## Forecast method: Holt's method
##
## Model Information:
## Holt's method
##
## Call:
## holt(y = eggs, h = 100, damped = FALSE, lambda = "auto")
##
## Box-Cox transformation: lambda= 0.3956
##
## Smoothing parameters:
## alpha = 0.809
## beta = 1e-04
##
## Initial states:
## l = 21.0322
## b = -0.1144
##
## sigma: 1.0549
##
## AIC AICc BIC
## 443.0310 443.7128 455.7475
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 0.7736844 26.39376 18.96387 -1.072416 9.620095 0.9354593
## ACF1
## Training set 0.03887152
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 1994 61.4107603 4.640814e+01 79.02212 3.947196e+01 89.44945
## 1995 60.0421240 4.147646e+01 82.90348 3.327908e+01 96.84743
## 1996 58.6920872 3.751269e+01 85.83783 2.853596e+01 102.79296
## 1997 57.3605616 3.414325e+01 88.19844 2.467300e+01 107.85505
## 1998 56.0474589 3.119333e+01 90.15981 2.142386e+01 112.29946
## 1999 54.7526902 2.856371e+01 91.82084 1.863743e+01 116.27667
## 2000 53.4761662 2.619126e+01 93.24432 1.621764e+01 119.88213
## 2001 52.2177974 2.403270e+01 94.47323 1.409858e+01 123.18111
## 2002 50.9774937 2.205666e+01 95.53860 1.223246e+01 126.22071
## 2003 49.7551646 2.023944e+01 96.46378 1.058319e+01 129.03638
## 2004 48.5507193 1.856257e+01 97.26691 9.122550e+00 131.65559
## 2005 47.3640666 1.701125e+01 97.96245 7.827917e+00 134.10027
## 2006 46.1951148 1.557337e+01 98.56214 6.680721e+00 136.38821
## 2007 45.0437717 1.423883e+01 99.07572 5.665431e+00 138.53416
## 2008 43.9099449 1.299909e+01 99.51139 4.768844e+00 140.55053
## 2009 42.7935413 1.184680e+01 99.87611 3.979562e+00 142.44785
## 2010 41.6944676 1.077559e+01 100.17588 3.287622e+00 144.23520
## 2011 40.6126299 9.779860e+00 100.41591 2.684205e+00 145.92049
## 2012 39.5479337 8.854646e+00 100.60079 2.161419e+00 147.51063
## 2013 38.5002844 7.995507e+00 100.73454 1.712125e+00 149.01174
## 2014 37.4695866 7.198443e+00 100.82076 1.329798e+00 150.42926
## 2015 36.4557446 6.459820e+00 100.86268 1.008416e+00 151.76806
## 2016 35.4586622 5.776316e+00 100.86319 7.423615e-01 153.03254
## 2017 34.4782425 5.144876e+00 100.82490 5.263381e-01 154.22665
## 2018 33.5143883 4.562675e+00 100.75020 3.552964e-01 155.35402
## 2019 32.5670019 4.027081e+00 100.64127 2.243584e-01 156.41793
## 2020 31.6359850 3.535636e+00 100.50010 1.287391e-01 157.42142
## 2021 30.7212388 3.086027e+00 100.32851 6.365231e-02 158.36726
## 2022 29.8226638 2.676069e+00 100.12820 2.417959e-02 159.25801
## 2023 28.9401603 2.303690e+00 99.90074 5.043607e-03 160.09606
## 2024 28.0736276 1.966911e+00 99.64756 4.087608e-05 160.88361
## 2025 27.2229649 1.663838e+00 99.37003 -2.009381e-03 161.62272
## 2026 26.3880704 1.392648e+00 99.06941 -1.480853e-02 162.31531
## 2027 25.5688420 1.151578e+00 98.74686 -4.423448e-02 162.96318
## 2028 24.7651768 9.389142e-01 98.40350 -9.420466e-02 163.56801
## 2029 23.9769715 7.529844e-01 98.04037 -1.677803e-01 164.13138
## 2030 23.2041220 5.921462e-01 97.65843 -2.674858e-01 164.65479
## 2031 22.4465236 4.547786e-01 97.25860 -3.954676e-01 165.13965
## 2032 21.7040710 3.392712e-01 96.84176 -5.535872e-01 165.58728
## 2033 20.9766582 2.440135e-01 96.40872 -7.434830e-01 165.99894
## 2034 20.2641786 1.673812e-01 95.96026 -9.666134e-01 166.37583
## 2035 19.5665248 1.077203e-01 95.49712 -1.224288e+00 166.71908
## 2036 18.8835888 6.332581e-02 95.01999 -1.517692e+00 167.02977
## 2037 18.2152618 3.241169e-02 94.52954 -1.847904e+00 167.30893
## 2038 17.5614344 1.306240e-02 94.02640 -2.215914e+00 167.55753
## 2039 16.9219962 3.144667e-03 93.51118 -2.622629e+00 167.77650
## 2040 16.2968364 9.146118e-05 92.98445 -3.068890e+00 167.96675
## 2041 15.6858432 -5.546778e-04 92.44676 -3.555477e+00 168.12912
## 2042 15.0889039 -5.531563e-03 91.89863 -4.083116e+00 168.26443
## 2043 14.5059053 -1.800422e-02 91.34058 -4.652485e+00 168.37347
## 2044 13.9367330 -4.001572e-02 90.77307 -5.264219e+00 168.45699
## 2045 13.3812721 -7.320011e-02 90.19658 -5.918915e+00 168.51571
## 2046 12.8394066 -1.189430e-01 89.61153 -6.617136e+00 168.55033
## 2047 12.3110197 -1.784566e-01 89.01837 -7.359412e+00 168.56151
## 2048 11.7959937 -2.528229e-01 88.41750 -8.146246e+00 168.54989
## 2049 11.2942098 -3.430209e-01 87.80930 -8.978115e+00 168.51610
## 2050 10.8055486 -4.499463e-01 87.19417 -9.855472e+00 168.46074
## 2051 10.3298892 -5.744249e-01 86.57246 -1.077875e+01 168.38438
## 2052 9.8671102 -7.172233e-01 85.94452 -1.174836e+01 168.28758
## 2053 9.4170888 -8.790568e-01 85.31069 -1.276469e+01 168.17087
## 2054 8.9797013 -1.060596e+00 84.67130 -1.382812e+01 168.03479
## 2055 8.5548230 -1.262474e+00 84.02666 -1.493901e+01 167.87982
## 2056 8.1423278 -1.485286e+00 83.37707 -1.609772e+01 167.70646
## 2057 7.7420887 -1.729598e+00 82.72284 -1.730456e+01 167.51519
## 2058 7.3539773 -1.995947e+00 82.06424 -1.855987e+01 167.30645
## 2059 6.9778642 -2.284847e+00 81.40155 -1.986395e+01 167.08070
## 2060 6.6136186 -2.596785e+00 80.73503 -2.121709e+01 166.83836
## 2061 6.2611083 -2.932230e+00 80.06494 -2.261960e+01 166.57985
## 2062 5.9202000 -3.291630e+00 79.39152 -2.407174e+01 166.30558
## 2063 5.5907588 -3.675416e+00 78.71503 -2.557380e+01 166.01594
## 2064 5.2726484 -4.084002e+00 78.03570 -2.712602e+01 165.71132
## 2065 4.9657312 -4.517788e+00 77.35374 -2.872866e+01 165.39208
## 2066 4.6698679 -4.977159e+00 76.66938 -3.038198e+01 165.05860
## 2067 4.3849175 -5.462487e+00 75.98284 -3.208621e+01 164.71121
## 2068 4.1107377 -5.974131e+00 75.29431 -3.384158e+01 164.35028
## 2069 3.8471841 -6.512440e+00 74.60401 -3.564833e+01 163.97613
## 2070 3.5941109 -7.077752e+00 73.91212 -3.750667e+01 163.58908
## 2071 3.3513701 -7.670394e+00 73.21884 -3.941682e+01 163.18947
## 2072 3.1188120 -8.290685e+00 72.52434 -4.137900e+01 162.77759
## 2073 2.8962849 -8.938933e+00 71.82881 -4.339340e+01 162.35374
## 2074 2.6836349 -9.615441e+00 71.13243 -4.546024e+01 161.91823
## 2075 2.4807060 -1.032050e+01 70.43535 -4.757970e+01 161.47135
## 2076 2.2873400 -1.105440e+01 69.73775 -4.975198e+01 161.01336
## 2077 2.1033762 -1.181741e+01 69.03978 -5.197728e+01 160.54455
## 2078 1.9286514 -1.260982e+01 68.34160 -5.425577e+01 160.06519
## 2079 1.7629999 -1.343187e+01 67.64336 -5.658764e+01 159.57553
## 2080 1.6062531 -1.428385e+01 66.94521 -5.897306e+01 159.07584
## 2081 1.4582396 -1.516598e+01 66.24729 -6.141222e+01 158.56635
## 2082 1.3187848 -1.607854e+01 65.54975 -6.390528e+01 158.04733
## 2083 1.1877111 -1.702175e+01 64.85271 -6.645242e+01 157.51901
## 2084 1.0648371 -1.799587e+01 64.15631 -6.905379e+01 156.98161
## 2085 0.9499781 -1.900111e+01 63.46067 -7.170957e+01 156.43538
## 2086 0.8429454 -2.003772e+01 62.76593 -7.441992e+01 155.88054
## 2087 0.7435459 -2.110591e+01 62.07221 -7.718498e+01 155.31730
## 2088 0.6515824 -2.220590e+01 61.37962 -8.000493e+01 154.74588
## 2089 0.5668525 -2.333792e+01 60.68829 -8.287991e+01 154.16649
## 2090 0.4891490 -2.450218e+01 59.99832 -8.581007e+01 153.57934
## 2091 0.4182588 -2.569888e+01 59.30982 -8.879557e+01 152.98463
## 2092 0.3539627 -2.692823e+01 58.62291 -9.183655e+01 152.38256
## 2093 0.2960349 -2.819043e+01 57.93769 -9.493316e+01 151.77332
holt3
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 1994 61.4107603 4.640814e+01 79.02212 3.947196e+01 89.44945
## 1995 60.0421240 4.147646e+01 82.90348 3.327908e+01 96.84743
## 1996 58.6920872 3.751269e+01 85.83783 2.853596e+01 102.79296
## 1997 57.3605616 3.414325e+01 88.19844 2.467300e+01 107.85505
## 1998 56.0474589 3.119333e+01 90.15981 2.142386e+01 112.29946
## 1999 54.7526902 2.856371e+01 91.82084 1.863743e+01 116.27667
## 2000 53.4761662 2.619126e+01 93.24432 1.621764e+01 119.88213
## 2001 52.2177974 2.403270e+01 94.47323 1.409858e+01 123.18111
## 2002 50.9774937 2.205666e+01 95.53860 1.223246e+01 126.22071
## 2003 49.7551646 2.023944e+01 96.46378 1.058319e+01 129.03638
## 2004 48.5507193 1.856257e+01 97.26691 9.122550e+00 131.65559
## 2005 47.3640666 1.701125e+01 97.96245 7.827917e+00 134.10027
## 2006 46.1951148 1.557337e+01 98.56214 6.680721e+00 136.38821
## 2007 45.0437717 1.423883e+01 99.07572 5.665431e+00 138.53416
## 2008 43.9099449 1.299909e+01 99.51139 4.768844e+00 140.55053
## 2009 42.7935413 1.184680e+01 99.87611 3.979562e+00 142.44785
## 2010 41.6944676 1.077559e+01 100.17588 3.287622e+00 144.23520
## 2011 40.6126299 9.779860e+00 100.41591 2.684205e+00 145.92049
## 2012 39.5479337 8.854646e+00 100.60079 2.161419e+00 147.51063
## 2013 38.5002844 7.995507e+00 100.73454 1.712125e+00 149.01174
## 2014 37.4695866 7.198443e+00 100.82076 1.329798e+00 150.42926
## 2015 36.4557446 6.459820e+00 100.86268 1.008416e+00 151.76806
## 2016 35.4586622 5.776316e+00 100.86319 7.423615e-01 153.03254
## 2017 34.4782425 5.144876e+00 100.82490 5.263381e-01 154.22665
## 2018 33.5143883 4.562675e+00 100.75020 3.552964e-01 155.35402
## 2019 32.5670019 4.027081e+00 100.64127 2.243584e-01 156.41793
## 2020 31.6359850 3.535636e+00 100.50010 1.287391e-01 157.42142
## 2021 30.7212388 3.086027e+00 100.32851 6.365231e-02 158.36726
## 2022 29.8226638 2.676069e+00 100.12820 2.417959e-02 159.25801
## 2023 28.9401603 2.303690e+00 99.90074 5.043607e-03 160.09606
## 2024 28.0736276 1.966911e+00 99.64756 4.087608e-05 160.88361
## 2025 27.2229649 1.663838e+00 99.37003 -2.009381e-03 161.62272
## 2026 26.3880704 1.392648e+00 99.06941 -1.480853e-02 162.31531
## 2027 25.5688420 1.151578e+00 98.74686 -4.423448e-02 162.96318
## 2028 24.7651768 9.389142e-01 98.40350 -9.420466e-02 163.56801
## 2029 23.9769715 7.529844e-01 98.04037 -1.677803e-01 164.13138
## 2030 23.2041220 5.921462e-01 97.65843 -2.674858e-01 164.65479
## 2031 22.4465236 4.547786e-01 97.25860 -3.954676e-01 165.13965
## 2032 21.7040710 3.392712e-01 96.84176 -5.535872e-01 165.58728
## 2033 20.9766582 2.440135e-01 96.40872 -7.434830e-01 165.99894
## 2034 20.2641786 1.673812e-01 95.96026 -9.666134e-01 166.37583
## 2035 19.5665248 1.077203e-01 95.49712 -1.224288e+00 166.71908
## 2036 18.8835888 6.332581e-02 95.01999 -1.517692e+00 167.02977
## 2037 18.2152618 3.241169e-02 94.52954 -1.847904e+00 167.30893
## 2038 17.5614344 1.306240e-02 94.02640 -2.215914e+00 167.55753
## 2039 16.9219962 3.144667e-03 93.51118 -2.622629e+00 167.77650
## 2040 16.2968364 9.146118e-05 92.98445 -3.068890e+00 167.96675
## 2041 15.6858432 -5.546778e-04 92.44676 -3.555477e+00 168.12912
## 2042 15.0889039 -5.531563e-03 91.89863 -4.083116e+00 168.26443
## 2043 14.5059053 -1.800422e-02 91.34058 -4.652485e+00 168.37347
## 2044 13.9367330 -4.001572e-02 90.77307 -5.264219e+00 168.45699
## 2045 13.3812721 -7.320011e-02 90.19658 -5.918915e+00 168.51571
## 2046 12.8394066 -1.189430e-01 89.61153 -6.617136e+00 168.55033
## 2047 12.3110197 -1.784566e-01 89.01837 -7.359412e+00 168.56151
## 2048 11.7959937 -2.528229e-01 88.41750 -8.146246e+00 168.54989
## 2049 11.2942098 -3.430209e-01 87.80930 -8.978115e+00 168.51610
## 2050 10.8055486 -4.499463e-01 87.19417 -9.855472e+00 168.46074
## 2051 10.3298892 -5.744249e-01 86.57246 -1.077875e+01 168.38438
## 2052 9.8671102 -7.172233e-01 85.94452 -1.174836e+01 168.28758
## 2053 9.4170888 -8.790568e-01 85.31069 -1.276469e+01 168.17087
## 2054 8.9797013 -1.060596e+00 84.67130 -1.382812e+01 168.03479
## 2055 8.5548230 -1.262474e+00 84.02666 -1.493901e+01 167.87982
## 2056 8.1423278 -1.485286e+00 83.37707 -1.609772e+01 167.70646
## 2057 7.7420887 -1.729598e+00 82.72284 -1.730456e+01 167.51519
## 2058 7.3539773 -1.995947e+00 82.06424 -1.855987e+01 167.30645
## 2059 6.9778642 -2.284847e+00 81.40155 -1.986395e+01 167.08070
## 2060 6.6136186 -2.596785e+00 80.73503 -2.121709e+01 166.83836
## 2061 6.2611083 -2.932230e+00 80.06494 -2.261960e+01 166.57985
## 2062 5.9202000 -3.291630e+00 79.39152 -2.407174e+01 166.30558
## 2063 5.5907588 -3.675416e+00 78.71503 -2.557380e+01 166.01594
## 2064 5.2726484 -4.084002e+00 78.03570 -2.712602e+01 165.71132
## 2065 4.9657312 -4.517788e+00 77.35374 -2.872866e+01 165.39208
## 2066 4.6698679 -4.977159e+00 76.66938 -3.038198e+01 165.05860
## 2067 4.3849175 -5.462487e+00 75.98284 -3.208621e+01 164.71121
## 2068 4.1107377 -5.974131e+00 75.29431 -3.384158e+01 164.35028
## 2069 3.8471841 -6.512440e+00 74.60401 -3.564833e+01 163.97613
## 2070 3.5941109 -7.077752e+00 73.91212 -3.750667e+01 163.58908
## 2071 3.3513701 -7.670394e+00 73.21884 -3.941682e+01 163.18947
## 2072 3.1188120 -8.290685e+00 72.52434 -4.137900e+01 162.77759
## 2073 2.8962849 -8.938933e+00 71.82881 -4.339340e+01 162.35374
## 2074 2.6836349 -9.615441e+00 71.13243 -4.546024e+01 161.91823
## 2075 2.4807060 -1.032050e+01 70.43535 -4.757970e+01 161.47135
## 2076 2.2873400 -1.105440e+01 69.73775 -4.975198e+01 161.01336
## 2077 2.1033762 -1.181741e+01 69.03978 -5.197728e+01 160.54455
## 2078 1.9286514 -1.260982e+01 68.34160 -5.425577e+01 160.06519
## 2079 1.7629999 -1.343187e+01 67.64336 -5.658764e+01 159.57553
## 2080 1.6062531 -1.428385e+01 66.94521 -5.897306e+01 159.07584
## 2081 1.4582396 -1.516598e+01 66.24729 -6.141222e+01 158.56635
## 2082 1.3187848 -1.607854e+01 65.54975 -6.390528e+01 158.04733
## 2083 1.1877111 -1.702175e+01 64.85271 -6.645242e+01 157.51901
## 2084 1.0648371 -1.799587e+01 64.15631 -6.905379e+01 156.98161
## 2085 0.9499781 -1.900111e+01 63.46067 -7.170957e+01 156.43538
## 2086 0.8429454 -2.003772e+01 62.76593 -7.441992e+01 155.88054
## 2087 0.7435459 -2.110591e+01 62.07221 -7.718498e+01 155.31730
## 2088 0.6515824 -2.220590e+01 61.37962 -8.000493e+01 154.74588
## 2089 0.5668525 -2.333792e+01 60.68829 -8.287991e+01 154.16649
## 2090 0.4891490 -2.450218e+01 59.99832 -8.581007e+01 153.57934
## 2091 0.4182588 -2.569888e+01 59.30982 -8.879557e+01 152.98463
## 2092 0.3539627 -2.692823e+01 58.62291 -9.183655e+01 152.38256
## 2093 0.2960349 -2.819043e+01 57.93769 -9.493316e+01 151.77332
holt3_plot <- autoplot(holt3) +
autolayer(holt3$fitted, series="Fitted") +
labs(title = "Holt -no damped, with box-cox", x = accuracy(holt3)[2])
holt4 <- holt(eggs, damped = TRUE, lambda = "auto", h = 100)
holt4
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 1994 62.64655 47.27973262 80.69832 4.017989e+01 91.39126
## 1995 62.38988 42.92322722 86.41174 3.434621e+01 101.08240
## 1996 62.13895 39.55414540 91.14596 3.000254e+01 109.28536
## 1997 61.89363 36.76017601 95.31306 2.652069e+01 116.62820
## 1998 61.65379 34.35554959 99.09862 2.361805e+01 123.39337
## 1999 61.41930 32.23747696 102.60524 2.113849e+01 129.73689
## 2000 61.19001 30.34192101 105.89676 1.898490e+01 135.75574
## 2001 60.96582 28.62573829 109.01614 1.709192e+01 141.51512
## 2002 60.74659 27.05819232 111.99394 1.541311e+01 147.06137
## 2003 60.53221 25.61644715 114.85283 1.391398e+01 152.42884
## 2004 60.32256 24.28297202 117.61016 1.256811e+01 157.64382
## 2005 60.11752 23.04395071 120.27958 1.135471e+01 162.72698
## 2006 59.91700 21.88825720 122.87206 1.025706e+01 167.69492
## 2007 59.72089 20.80676914 125.39657 9.261488e+00 172.56120
## 2008 59.52907 19.79189192 127.86054 8.356605e+00 177.33707
## 2009 59.34145 18.83721946 130.27024 7.532834e+00 182.03200
## 2010 59.15793 17.93728641 132.63098 6.782011e+00 186.65403
## 2011 58.97841 17.08738337 134.94734 6.097110e+00 191.21007
## 2012 58.80280 16.28341653 137.22327 5.472033e+00 195.70610
## 2013 58.63101 15.52179931 139.46222 4.901442e+00 200.14734
## 2014 58.46296 14.79936752 141.66722 4.380631e+00 204.53837
## 2015 58.29854 14.11331203 143.84097 3.905428e+00 208.88326
## 2016 58.13769 13.46112475 145.98583 3.472108e+00 213.18561
## 2017 57.98031 12.84055481 148.10395 3.077331e+00 217.44863
## 2018 57.82633 12.24957272 150.19722 2.718085e+00 221.67523
## 2019 57.67568 11.68634066 152.26738 2.391643e+00 225.86800
## 2020 57.52826 11.14918787 154.31598 2.095523e+00 230.02931
## 2021 57.38401 10.63658995 156.34444 1.827459e+00 234.16130
## 2022 57.24287 10.14715132 158.35403 1.585375e+00 238.26592
## 2023 57.10474 9.67959041 160.34595 1.367360e+00 242.34495
## 2024 56.96958 9.23272695 162.32127 1.171649e+00 246.40003
## 2025 56.83731 8.80547104 164.28097 9.966082e-01 250.43266
## 2026 56.70786 8.39681370 166.22596 8.407190e-01 254.44422
## 2027 56.58117 8.00581871 168.15709 7.025648e-01 258.43599
## 2028 56.45719 7.63161542 170.07514 5.808207e-01 262.40914
## 2029 56.33584 7.27339254 171.98082 4.742430e-01 266.36478
## 2030 56.21708 6.93039260 173.87480 3.816600e-01 270.30390
## 2031 56.10083 6.60190708 175.75769 3.019643e-01 274.22747
## 2032 55.98705 6.28727217 177.63009 2.341044e-01 278.13635
## 2033 55.87569 5.98586488 179.49252 1.770781e-01 282.03138
## 2034 55.76668 5.69709965 181.34550 1.299253e-01 285.91330
## 2035 55.65997 5.42042531 183.18948 9.172068e-02 289.78285
## 2036 55.55552 5.15532234 185.02491 6.156653e-02 293.64068
## 2037 55.45327 4.90130040 186.85221 3.858416e-02 297.48744
## 2038 55.35318 4.65789612 188.67175 2.190372e-02 301.32371
## 2039 55.25520 4.42467111 190.48392 1.065036e-02 305.15005
## 2040 55.15928 4.20121008 192.28903 3.922915e-03 308.96698
## 2041 55.06537 3.98711929 194.08743 7.540037e-04 312.77499
## 2042 54.97344 3.78202495 195.87941 1.700210e-06 316.57455
## 2043 54.88343 3.58557191 197.66526 -4.439016e-04 320.36609
## 2044 54.79531 3.39742238 199.44524 -2.892414e-03 324.15002
## 2045 54.70904 3.21725481 201.21963 -8.310487e-03 327.92675
## 2046 54.62457 3.04476280 202.98864 -1.734558e-02 331.69663
## 2047 54.54187 2.87965417 204.75252 -3.049319e-02 335.46001
## 2048 54.46089 2.72165005 206.51148 -4.815086e-02 339.21723
## 2049 54.38161 2.57048405 208.26573 -7.064573e-02 342.96860
## 2050 54.30398 2.42590154 210.01545 -9.825115e-02 346.71442
## 2051 54.22796 2.28765891 211.76084 -1.311978e-01 350.45496
## 2052 54.15353 2.15552294 213.50207 -1.696814e-01 354.19050
## 2053 54.08065 2.02927018 215.23930 -2.138689e-01 357.92129
## 2054 54.00928 1.90868643 216.97269 -2.639028e-01 361.64757
## 2055 53.93940 1.79356618 218.70239 -3.199046e-01 365.36957
## 2056 53.87097 1.68371211 220.42855 -3.819780e-01 369.08751
## 2057 53.80395 1.57893472 222.15130 -4.502112e-01 372.80159
## 2058 53.73833 1.47905181 223.87077 -5.246786e-01 376.51202
## 2059 53.67406 1.38388814 225.58708 -6.054428e-01 380.21898
## 2060 53.61112 1.29327505 227.30035 -6.925559e-01 383.92266
## 2061 53.54949 1.20705011 229.01069 -7.860607e-01 387.62321
## 2062 53.48913 1.12505679 230.71821 -8.859916e-01 391.32081
## 2063 53.43002 1.04714415 232.42301 -9.923760e-01 395.01561
## 2064 53.37213 0.97316658 234.12519 -1.105234e+00 398.70776
## 2065 53.31543 0.90298349 235.82484 -1.224582e+00 402.39740
## 2066 53.25990 0.83645909 237.52205 -1.350427e+00 406.08466
## 2067 53.20552 0.77346211 239.21690 -1.482777e+00 409.76968
## 2068 53.15226 0.71386560 240.90948 -1.621630e+00 413.45258
## 2069 53.10009 0.65754669 242.59986 -1.766984e+00 417.13347
## 2070 53.04900 0.60438643 244.28811 -1.918833e+00 420.81247
## 2071 52.99896 0.55426953 245.97431 -2.077168e+00 424.48968
## 2072 52.94994 0.50708420 247.65853 -2.241975e+00 428.16522
## 2073 52.90194 0.46272201 249.34083 -2.413241e+00 431.83916
## 2074 52.85492 0.42107764 251.02127 -2.590949e+00 435.51162
## 2075 52.80886 0.38204880 252.69991 -2.775080e+00 439.18268
## 2076 52.76375 0.34553601 254.37680 -2.965613e+00 442.85242
## 2077 52.71956 0.31144248 256.05201 -3.162526e+00 446.52093
## 2078 52.67628 0.27967396 257.72559 -3.365797e+00 450.18828
## 2079 52.63389 0.25013860 259.39758 -3.575400e+00 453.85456
## 2080 52.59236 0.22274678 261.06804 -3.791308e+00 457.51984
## 2081 52.55168 0.19741102 262.73700 -4.013497e+00 461.18417
## 2082 52.51184 0.17404582 264.40452 -4.241937e+00 464.84764
## 2083 52.47281 0.15256753 266.07064 -4.476600e+00 468.51030
## 2084 52.43457 0.13289421 267.73539 -4.717457e+00 472.17221
## 2085 52.39712 0.11494553 269.39882 -4.964479e+00 475.83344
## 2086 52.36043 0.09864257 271.06097 -5.217634e+00 479.49403
## 2087 52.32450 0.08390776 272.72187 -5.476893e+00 483.15405
## 2088 52.28929 0.07066465 274.38155 -5.742224e+00 486.81354
## 2089 52.25480 0.05883783 276.04005 -6.013596e+00 490.47255
## 2090 52.22102 0.04835272 277.69741 -6.290976e+00 494.13113
## 2091 52.18792 0.03913540 279.35364 -6.574335e+00 497.78932
## 2092 52.15550 0.03111240 281.00879 -6.863638e+00 501.44717
## 2093 52.12374 0.02421049 282.66288 -7.158854e+00 505.10472
holt4_plot <- autoplot(holt4) +
autolayer(holt4$fitted, series="Fitted") +
labs(title = "Holt -with damped, with box-cox", x = accuracy(holt4)[2])
autoplot(eggs) +
autolayer(holt1,
series = paste("Not damped, not tranformed. RMSE: ",round(accuracy(holt1)[2],2)),
PI=F) +
autolayer(holt2,
series = paste("Damped, not tranformed. RMSE: ",round(accuracy(holt2)[2],2)),
PI=F) +
autolayer(holt3,
series = paste("Not damped, Tranformed. RMSE: ",round(accuracy(holt3)[2],2)),
PI=F) +
autolayer(holt4,
series = paste("Damped, Tranformed. RMSE: ",round(accuracy(holt4)[2],2)),
PI=F)
grid.arrange(holt1_plot, holt2_plot, holt3_plot, holt4_plot, nrow = 2)
Based on RMSE, it appears that non-damped box cox transformed data is the best model.
Recall your retail time series data (from Exercise 3 in Section 2.10).
retaildata <- readxl::read_excel("retail.xlsx", skip=1)
#Chose col B Turnover New South Wales Supermarket and grocery stores
myts <- ts(retaildata[,"A3349335T"],
frequency=12, start=c(1982,4))
autoplot(myts)
a. Why is multiplicative seasonality necessary for this series?
It appears that multiplicative is more appropriate due to seasonal variation which seems getting larger as time moves forward.
b. Apply Holt-Winters’ multiplicative method to the data. Experiment with making the trend damped
hw1 <- hw(myts, seasonal = "multiplicative", damped = FALSE)
hw2 <- hw(myts, seasonal = "multiplicative", damped = TRUE)
autoplot(myts) +
autolayer(hw1,
series = "Holt Winters - not damped, multiplicative", PI=F) +
autolayer(hw2,
series = "Holt Winters - damped, multiplicative", PI=F)
c. Compare the RMSE of the one-step forecasts from the two methods. Which do you prefer?
accuracy(forecast(hw1, h=1))
## ME RMSE MAE MPE MAPE MASE
## Training set 0.9212824 25.20381 18.77683 0.06856226 1.979315 0.3016982
## ACF1
## Training set -0.1217931
accuracy(forecast(hw2, h=1))
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 2.9059 25.10059 18.74334 0.2366077 1.993423 0.3011601 -0.1394101
Based on RMSE, there’s little difference/improvement with damped method for one-step forecast. In this particular series, we’d prefer the damped method
d. Check that the residuals from the best method look like white noise
checkresiduals(hw2)
##
## Ljung-Box test
##
## data: Residuals from Damped Holt-Winters' multiplicative method
## Q* = 285.62, df = 7, p-value < 2.2e-16
##
## Model df: 17. Total lags used: 24
Our ACF plot and Box test suggest residuals that are distinguisable frow white noise. Greater than 5% of the verticals lie outside of the blue region.
e. Now find the test set RMSE, while training the model to the end of 2010. Can you beat the seasonal naïve approach from Exercise 8 in Section 3.7?
myts.train <- window(myts, end=c(2010,12))
myts.test <- window(myts, start=2011)
fc_snaive <- snaive(myts.train)
fc_hw <- hw(myts.train, seasonal = "multiplicative", damped = TRUE)
autoplot(myts) +
autolayer(myts.train, series="Training") +
autolayer(myts.test, series="Test") +
autolayer(fc_snaive, series="Seasonal Naive") +
autolayer(fc_hw, series="Holt Winter")
accuracy(fc_snaive,myts.test)
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 61.56787 72.20702 61.68438 6.388722 6.404105 1.000000 0.6018274
## Test set 97.44583 109.62545 100.02917 4.629852 4.751209 1.621629 0.2686595
## Theil's U
## Training set NA
## Test set 0.9036205
accuracy(fc_hw,myts.test)
## ME RMSE MAE MPE MAPE MASE
## Training set 4.089724 25.68057 18.92510 0.371369 2.057716 0.3068053
## Test set -27.787782 41.08034 32.12435 -1.279976 1.487404 0.5207858
## ACF1 Theil's U
## Training set -0.05009924 NA
## Test set 0.13519074 0.3334222
The Holt-Winter damped method has remarkably improved on the RMSE, beating the naive method previously used.
For the same retail data, try an STL decomposition applied to the Box-Cox transformed series, followed by ETS on the seasonally adjusted data. How does that compare with your best previous forecasts on the test set?
myts2 <- ts(
data=retaildata$A3349335T,
frequency=12,
start=c(1982,4)
)
myts2.train <- window(myts2, end=c(2010,12))
lambda <- BoxCox.lambda(myts2.train)
lambda
## [1] 0.1894047
# BoxCox
myts2.train_bc <- BoxCox(myts2.train,lambda)
bc_stl_seasadj_ets <- myts2.train_bc %>%
stl(t.window=13, s.window="periodic", robust=TRUE) %>%
seasadj() %>%
ets(model="ZZZ")
autoplot(bc_stl_seasadj_ets)
summary(bc_stl_seasadj_ets)
## ETS(A,A,N)
##
## Call:
## ets(y = ., model = "ZZZ")
##
## Smoothing parameters:
## alpha = 0.2235
## beta = 1e-04
##
## Initial states:
## l = 10.3101
## b = 0.0199
##
## sigma: 0.0898
##
## AIC AICc BIC
## 358.6010 358.7780 377.8187
##
## Training set error measures:
## ME RMSE MAE MPE MAPE
## Training set -8.760858e-05 0.08922863 0.06786454 0.000878857 0.5056621
## MASE ACF1
## Training set 0.2850912 -0.100562
fc_bsse = forecast(bc_stl_seasadj_ets,h=36, lambda = lambda)
accuracy(fc_bsse)
## ME RMSE MAE MPE MAPE
## Training set -8.760858e-05 0.08922863 0.06786454 0.000878857 0.5056621
## MASE ACF1
## Training set 0.2850912 -0.100562
It appears this model (transformed-stl-seasonallyadjusted-ets) has better RMSE than the Holt-Winter damped model