Chapter 7

1a

library(fpp)
## Loading required package: forecast
## Warning: package 'forecast' was built under R version 3.3.2
## Loading required package: fma
## Warning: package 'fma' was built under R version 3.3.2
## Loading required package: expsmooth
## Loading required package: lmtest
## Warning: package 'lmtest' was built under R version 3.3.2
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 3.3.2
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: tseries
## Warning: package 'tseries' was built under R version 3.3.2
data(books)

str(books)
##  Time-Series [1:30, 1:2] from 1 to 30: 199 172 111 209 161 119 195 195 131 183 ...
##  - attr(*, "dimnames")=List of 2
##   ..$ : NULL
##   ..$ : chr [1:2] "Paperback" "Hardcover"
books
## Time Series:
## Start = 1 
## End = 30 
## Frequency = 1 
##    Paperback Hardcover
##  1       199       139
##  2       172       128
##  3       111       172
##  4       209       139
##  5       161       191
##  6       119       168
##  7       195       170
##  8       195       145
##  9       131       184
## 10       183       135
## 11       143       218
## 12       141       198
## 13       168       230
## 14       201       222
## 15       155       206
## 16       243       240
## 17       225       189
## 18       167       222
## 19       237       158
## 20       202       178
## 21       186       217
## 22       176       261
## 23       232       238
## 24       195       240
## 25       190       214
## 26       182       200
## 27       222       201
## 28       217       283
## 29       188       220
## 30       247       259
plot(books, main="Daily Sales", xlab="Days")

myts = ts(books, start=1, frequency = 30)
plot(myts)

1b

As alpha increased, SSE increased. So, it looks like a lower alpha is better for this model.

myses1= ses(books[,1], inital = "simple", alpha = .1)
sum((books[,1] - fitted(myses1))^2)
## [1] 34759.28
myses2= ses(books[,1], inital = "simple", alpha = .3)
sum((books[,1] - fitted(myses2))^2)
## [1] 35511.3
myses3= ses(books[,1], inital = "simple", alpha = .5)
sum((books[,1] - fitted(myses3))^2)
## [1] 40860.79
myses4= ses(books[,1], inital = "simple", alpha = .7)
sum((books[,1] - fitted(myses4))^2)
## [1] 48631.17
myses5= ses(books[,1], inital = "simple", alpha = .9)
sum((books[,1] - fitted(myses5))^2)
## [1] 58758.99
summary(myses1)
## 
## Forecast method: Simple exponential smoothing
## 
## Model Information:
## Simple exponential smoothing 
## 
## Call:
##  ses(y = books[, 1], alpha = 0.1, inital = "simple") 
## 
##   Smoothing parameters:
##     alpha = 0.1 
## 
##   Initial states:
##     l = 175.0081 
## 
##   sigma:  34.0388
## 
##      AIC     AICc      BIC 
## 317.6861 318.1305 320.4884 
## 
## Error measures:
##                    ME     RMSE      MAE       MPE     MAPE      MASE
## Training set 8.226668 34.03884 27.26858 0.8710995 15.27151 0.6876425
##                    ACF1
## Training set -0.1227671
## 
## Forecasts:
##    Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 31       199.6881 156.0655 243.3106 132.9732 266.4030
## 32       199.6881 155.8480 243.5282 132.6404 266.7357
## 33       199.6881 155.6315 243.7447 132.3093 267.0668
## 34       199.6881 155.4160 243.9601 131.9798 267.3963
## 35       199.6881 155.2016 244.1745 131.6519 267.7242
## 36       199.6881 154.9883 244.3879 131.3256 268.0505
## 37       199.6881 154.7759 244.6002 131.0009 268.3753
## 38       199.6881 154.5646 244.8116 130.6776 268.6985
## 39       199.6881 154.3542 245.0219 130.3559 269.0202
## 40       199.6881 154.1448 245.2313 130.0357 269.3405
summary(myses2)
## 
## Forecast method: Simple exponential smoothing
## 
## Model Information:
## Simple exponential smoothing 
## 
## Call:
##  ses(y = books[, 1], alpha = 0.3, inital = "simple") 
## 
##   Smoothing parameters:
##     alpha = 0.3 
## 
##   Initial states:
##     l = 172.0801 
## 
##   sigma:  34.4051
## 
##      AIC     AICc      BIC 
## 318.3282 318.7726 321.1306 
## 
## Error measures:
##                    ME     RMSE      MAE        MPE     MAPE      MASE
## Training set 4.732443 34.40509 29.51915 -0.8336159 16.65111 0.7443959
##                    ACF1
## Training set -0.2877607
## 
## Forecasts:
##    Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 31       214.6721 170.5802 258.7640 147.2393 282.1048
## 32       214.6721 168.6388 260.7054 144.2702 285.0739
## 33       214.6721 166.7760 262.5681 141.4214 287.9228
## 34       214.6721 164.9830 264.3611 138.6792 290.6649
## 35       214.6721 163.2525 266.0916 136.0327 293.3115
## 36       214.6721 161.5784 267.7657 133.4723 295.8718
## 37       214.6721 159.9555 269.3887 130.9902 298.3539
## 38       214.6721 158.3793 270.9648 128.5797 300.7644
## 39       214.6721 156.8461 272.4980 126.2349 303.1093
## 40       214.6721 155.3525 273.9916 123.9506 305.3935
summary(myses3)
## 
## Forecast method: Simple exponential smoothing
## 
## Model Information:
## Simple exponential smoothing 
## 
## Call:
##  ses(y = books[, 1], alpha = 0.5, inital = "simple") 
## 
##   Smoothing parameters:
##     alpha = 0.5 
## 
##   Initial states:
##     l = 179.2119 
## 
##   sigma:  36.9056
## 
##      AIC     AICc      BIC 
## 322.5378 322.9822 325.3402 
## 
## Error measures:
##                   ME     RMSE      MAE       MPE     MAPE      MASE
## Training set 2.94017 36.90564 32.15609 -1.909183 18.22476 0.8108926
##                    ACF1
## Training set -0.3605069
## 
## Forecasts:
##    Point Forecast    Lo 80    Hi 80     Lo 95    Hi 95
## 31       223.3145 176.0180 270.6109 150.98073 295.6482
## 32       223.3145 170.4354 276.1935 142.44290 304.1860
## 33       223.3145 165.3883 281.2406 134.72410 311.9048
## 34       223.3145 160.7471 285.8818 127.62593 319.0030
## 35       223.3145 156.4271 290.2018 121.01912 325.6098
## 36       223.3145 152.3697 294.2592 114.81387 331.8151
## 37       223.3145 148.5322 298.0968 108.94479 337.6841
## 38       223.3145 144.8821 301.7468 103.36254 343.2664
## 39       223.3145 141.3946 305.2344  98.02877 348.6002
## 40       223.3145 138.0495 308.5794  92.91298 353.7159
summary(myses4)
## 
## Forecast method: Simple exponential smoothing
## 
## Model Information:
## Simple exponential smoothing 
## 
## Call:
##  ses(y = books[, 1], alpha = 0.7, inital = "simple") 
## 
##   Smoothing parameters:
##     alpha = 0.7 
## 
##   Initial states:
##     l = 187.5869 
## 
##   sigma:  40.2621
## 
##      AIC     AICc      BIC 
## 327.7606 328.2050 330.5630 
## 
## Error measures:
##                    ME     RMSE      MAE       MPE     MAPE      MASE
## Training set 2.102948 40.26213 34.39505 -2.467751 19.47748 0.8673535
##                    ACF1
## Training set -0.4140537
## 
## Forecasts:
##    Point Forecast    Lo 80    Hi 80     Lo 95    Hi 95
## 31       231.7488 180.1508 283.3468 152.83650 310.6612
## 32       231.7488 168.7654 294.7322 135.42406 328.0736
## 33       231.7488 159.1440 304.3536 120.70934 342.7883
## 34       231.7488 150.6562 312.8414 107.72837 355.7693
## 35       231.7488 142.9763 320.5214  95.98293 367.5147
## 36       231.7488 135.9098 327.5879  85.17569 378.3220
## 37       231.7488 129.3297 334.1679  75.11234 388.3853
## 38       231.7488 123.1476 340.3500  65.65760 397.8401
## 39       231.7488 117.2989 346.1987  56.71282 406.7848
## 40       231.7488 111.7350 351.7627  48.20344 415.2942
summary(myses5)
## 
## Forecast method: Simple exponential smoothing
## 
## Model Information:
## Simple exponential smoothing 
## 
## Call:
##  ses(y = books[, 1], alpha = 0.9, inital = "simple") 
## 
##   Smoothing parameters:
##     alpha = 0.9 
## 
##   Initial states:
##     l = 195.7983 
## 
##   sigma:  44.2564
## 
##      AIC     AICc      BIC 
## 333.4360 333.8804 336.2384 
## 
## Error measures:
##                   ME     RMSE      MAE       MPE     MAPE      MASE
## Training set 1.68862 44.25645 36.91328 -2.740708 20.71661 0.9308567
##                   ACF1
## Training set -0.458707
## 
## Forecasts:
##    Point Forecast     Lo 80    Hi 80     Lo 95    Hi 95
## 31       241.3911 184.67417 298.1080 154.65005 328.1321
## 32       241.3911 165.08628 317.6959 124.69295 358.0892
## 33       241.3911 149.58674 333.1954 100.98845 381.7937
## 34       241.3911 136.34989 346.4323  80.74443 402.0377
## 35       241.3911 124.60381 358.1784  62.78035 420.0018
## 36       241.3911 113.93567 368.8465  46.46484 436.3173
## 37       241.3911 104.09397 378.6882  31.41326 451.3689
## 38       241.3911  94.91203 387.8701  17.37070 465.4115
## 39       241.3911  86.27265 396.5095   4.15791 478.6243
## 40       241.3911  78.08970 404.6925  -8.35684 491.1390
alpha = c(0.1, 0.3, 0.5, 0.7, 0.9)
sse.paper = c(34759.28 ,35511.3, 40860.79,48631.17, 58758.99)
plot(alpha, sse.paper)

1c

SES selected .1685 for alpha. Indeed, SSE is minimized at this value comapres toalpha of .1 and .3 that I tested.

myses6= ses(books[,1], inital = "simple", h=4)
sum((books[,1] - fitted(myses6))^2)
## [1] 33944.82
summary(myses6)
## 
## Forecast method: Simple exponential smoothing
## 
## Model Information:
## Simple exponential smoothing 
## 
## Call:
##  ses(y = books[, 1], h = 4, inital = "simple") 
## 
##   Smoothing parameters:
##     alpha = 0.1685 
## 
##   Initial states:
##     l = 170.8257 
## 
##   sigma:  33.6377
## 
##      AIC     AICc      BIC 
## 318.9747 319.8978 323.1783 
## 
## Error measures:
##                    ME     RMSE     MAE       MPE     MAPE      MASE
## Training set 7.176212 33.63769 27.8431 0.4737524 15.57782 0.7021303
##                    ACF1
## Training set -0.2117579
## 
## Forecasts:
##    Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 31       207.1098 164.0013 250.2182 141.1811 273.0384
## 32       207.1098 163.3934 250.8261 140.2513 273.9682
## 33       207.1098 162.7937 251.4258 139.3342 274.8853
## 34       207.1098 162.2021 252.0174 138.4294 275.7901

1d

There doesn’t seem to be any difference between simple and optimal. They both chose the same alpha, have the same SSE, the same forecast, and the same error measures.

myses7= ses(books[,1], inital = "optimal", h=4)
sum((books[,1] - fitted(myses7))^2)
## [1] 33944.82
summary(myses7)
## 
## Forecast method: Simple exponential smoothing
## 
## Model Information:
## Simple exponential smoothing 
## 
## Call:
##  ses(y = books[, 1], h = 4, inital = "optimal") 
## 
##   Smoothing parameters:
##     alpha = 0.1685 
## 
##   Initial states:
##     l = 170.8257 
## 
##   sigma:  33.6377
## 
##      AIC     AICc      BIC 
## 318.9747 319.8978 323.1783 
## 
## Error measures:
##                    ME     RMSE     MAE       MPE     MAPE      MASE
## Training set 7.176212 33.63769 27.8431 0.4737524 15.57782 0.7021303
##                    ACF1
## Training set -0.2117579
## 
## Forecasts:
##    Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 31       207.1098 164.0013 250.2182 141.1811 273.0384
## 32       207.1098 163.3934 250.8261 140.2513 273.9682
## 33       207.1098 162.7937 251.4258 139.3342 274.8853
## 34       207.1098 162.2021 252.0174 138.4294 275.7901

1e

SES chose an alpha of .3282, which minimized SSE at 30587.69.

myses8= ses(books[,2], inital = "simple", alpha = .1)
sum((books[,2] - fitted(myses8))^2)
## [1] 38390.67
myses9= ses(books[,2], inital = "simple", alpha = .3)
sum((books[,2] - fitted(myses9))^2)
## [1] 30634.58
myses10= ses(books[,2], inital = "simple", alpha = .5)
sum((books[,2] - fitted(myses10))^2)
## [1] 31682.57
myses11= ses(books[,2], inital = "simple", alpha = .7)
sum((books[,2] - fitted(myses11))^2)
## [1] 34993.93
myses12= ses(books[,2], inital = "simple", alpha = .9)
sum((books[,2] - fitted(myses12))^2)
## [1] 41209.05
summary(myses8)
## 
## Forecast method: Simple exponential smoothing
## 
## Model Information:
## Simple exponential smoothing 
## 
## Call:
##  ses(y = books[, 2], alpha = 0.1, inital = "simple") 
## 
##   Smoothing parameters:
##     alpha = 0.1 
## 
##   Initial states:
##     l = 176.3386 
## 
##   sigma:  35.7727
## 
##      AIC     AICc      BIC 
## 320.6671 321.1115 323.4695 
## 
## Error measures:
##                    ME     RMSE      MAE    MPE     MAPE      MASE
## Training set 14.10376 35.77274 29.38268 4.0492 14.69128 0.8766438
##                   ACF1
## Training set 0.1640383
## 
## Forecasts:
##    Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 31       218.6499 172.8053 264.4945 148.5366 288.7632
## 32       218.6499 172.5766 264.7232 148.1869 289.1129
## 33       218.6499 172.3491 264.9507 147.8390 289.4608
## 34       218.6499 172.1227 265.1771 147.4927 289.8071
## 35       218.6499 171.8974 265.4024 147.1481 290.1517
## 36       218.6499 171.6732 265.6267 146.8052 290.4946
## 37       218.6499 171.4500 265.8498 146.4639 290.8359
## 38       218.6499 171.2279 266.0719 146.1242 291.1756
## 39       218.6499 171.0068 266.2930 145.7860 291.5138
## 40       218.6499 170.7867 266.5131 145.4495 291.8503
summary(myses9)
## 
## Forecast method: Simple exponential smoothing
## 
## Model Information:
## Simple exponential smoothing 
## 
## Call:
##  ses(y = books[, 2], alpha = 0.3, inital = "simple") 
## 
##   Smoothing parameters:
##     alpha = 0.3 
## 
##   Initial states:
##     l = 150.8405 
## 
##   sigma:  31.9555
## 
##      AIC     AICc      BIC 
## 313.8965 314.3410 316.6989 
## 
## Error measures:
##                    ME     RMSE      MAE      MPE     MAPE      MASE
## Training set 9.712011 31.95548 27.00503 2.873589 13.50611 0.8057058
##                    ACF1
## Training set -0.1222506
## 
## Forecasts:
##    Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 31       238.2486 197.2961 279.2012 175.6171 300.8802
## 32       238.2486 195.4929 281.0044 172.8593 303.6380
## 33       238.2486 193.7627 282.7346 170.2133 306.2840
## 34       238.2486 192.0974 284.3999 167.6664 308.8309
## 35       238.2486 190.4901 286.0072 165.2083 311.2890
## 36       238.2486 188.9352 287.5621 162.8302 313.6671
## 37       238.2486 187.4278 289.0695 160.5249 315.9724
## 38       238.2486 185.9639 290.5334 158.2860 318.2113
## 39       238.2486 184.5398 291.9575 156.1081 320.3892
## 40       238.2486 183.1526 293.3447 153.9865 322.5108
summary(myses10)
## 
## Forecast method: Simple exponential smoothing
## 
## Model Information:
## Simple exponential smoothing 
## 
## Call:
##  ses(y = books[, 2], alpha = 0.5, inital = "simple") 
## 
##   Smoothing parameters:
##     alpha = 0.5 
## 
##   Initial states:
##     l = 142.8628 
## 
##   sigma:  32.4975
## 
##      AIC     AICc      BIC 
## 314.9057 315.3501 317.7080 
## 
## Error measures:
##                   ME     RMSE      MAE      MPE     MAPE      MASE
## Training set 6.85818 32.49747 26.09717 1.594604 13.06966 0.7786192
##                    ACF1
## Training set -0.2600558
## 
## Forecasts:
##    Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 31       245.7355 204.0883 287.3827 182.0416 309.4294
## 32       245.7355 199.1725 292.2985 174.5236 316.9474
## 33       245.7355 194.7283 296.7427 167.7268 323.7443
## 34       245.7355 190.6415 300.8296 161.4764 329.9946
## 35       245.7355 186.8375 304.6335 155.6588 335.8122
## 36       245.7355 183.2647 308.2063 150.1947 341.2763
## 37       245.7355 179.8855 311.5855 145.0267 346.4444
## 38       245.7355 176.6715 314.7996 140.1112 351.3598
## 39       245.7355 173.6005 317.8705 135.4145 356.0565
## 40       245.7355 170.6550 320.8160 130.9098 360.5613
summary(myses11)
## 
## Forecast method: Simple exponential smoothing
## 
## Model Information:
## Simple exponential smoothing 
## 
## Call:
##  ses(y = books[, 2], alpha = 0.7, inital = "simple") 
## 
##   Smoothing parameters:
##     alpha = 0.7 
## 
##   Initial states:
##     l = 139.1194 
## 
##   sigma:  34.1535
## 
##      AIC     AICc      BIC 
## 317.8879 318.3323 320.6903 
## 
## Error measures:
##                    ME     RMSE      MAE       MPE     MAPE      MASE
## Training set 5.318163 34.15354 26.70369 0.8527317 13.44728 0.7967149
##                    ACF1
## Training set -0.4073303
## 
## Forecasts:
##    Point Forecast    Lo 80    Hi 80     Lo 95    Hi 95
## 31       250.8008 207.0313 294.5704 183.86113 317.7406
## 32       250.8008 197.3733 304.2284 169.09051 332.5112
## 33       250.8008 189.2117 312.3900 156.60832 344.9934
## 34       250.8008 182.0116 319.5901 145.59683 356.0049
## 35       250.8008 175.4969 326.1048 135.63341 365.9683
## 36       250.8008 169.5026 332.0991 126.46584 375.1358
## 37       250.8008 163.9208 337.6809 117.92931 383.6724
## 38       250.8008 158.6766 342.9250 109.90905 391.6926
## 39       250.8008 153.7153 347.8864 102.32138 399.2803
## 40       250.8008 148.9955 352.6062  95.10304 406.4986
summary(myses12)
## 
## Forecast method: Simple exponential smoothing
## 
## Model Information:
## Simple exponential smoothing 
## 
## Call:
##  ses(y = books[, 2], alpha = 0.9, inital = "simple") 
## 
##   Smoothing parameters:
##     alpha = 0.9 
## 
##   Initial states:
##     l = 138.3216 
## 
##   sigma:  37.0626
## 
##      AIC     AICc      BIC 
## 322.7924 323.2368 325.5948 
## 
## Error measures:
##                    ME     RMSE      MAE       MPE     MAPE     MASE
## Training set 4.345423 37.06258 30.13287 0.3000509 15.26412 0.899026
##                    ACF1
## Training set -0.5486737
## 
## Forecasts:
##    Point Forecast    Lo 80    Hi 80     Lo 95    Hi 95
## 31       255.6481 208.1505 303.1457 183.00674 328.2894
## 32       255.6481 191.7466 319.5496 157.91915 353.3770
## 33       255.6481 178.7665 332.5297 138.06780 373.2283
## 34       255.6481 167.6813 343.6149 121.11444 390.1817
## 35       255.6481 157.8445 353.4516 106.07041 405.2257
## 36       255.6481 148.9105 362.3857  92.40698 418.8892
## 37       255.6481 140.6685 370.6276  79.80202 431.4941
## 38       255.6481 132.9791 378.3170  68.04207 443.2541
## 39       255.6481 125.7440 385.5521  56.97702 454.3191
## 40       255.6481 118.8912 392.4049  46.49653 464.7996
myses13= ses(books[,2], inital = "simple", h=4)
sum((books[,2] - fitted(myses13))^2)
## [1] 30587.69
summary(myses13)
## 
## Forecast method: Simple exponential smoothing
## 
## Model Information:
## Simple exponential smoothing 
## 
## Call:
##  ses(y = books[, 2], h = 4, inital = "simple") 
## 
##   Smoothing parameters:
##     alpha = 0.3283 
## 
##   Initial states:
##     l = 149.2836 
## 
##   sigma:  31.931
## 
##      AIC     AICc      BIC 
## 315.8506 316.7737 320.0542 
## 
## Error measures:
##                    ME     RMSE     MAE      MPE     MAPE      MASE
## Training set 9.166918 31.93101 26.7731 2.636328 13.39479 0.7987858
##                    ACF1
## Training set -0.1417817
## 
## Forecasts:
##    Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 31       239.5602 198.6390 280.4815 176.9766 302.1439
## 32       239.5602 196.4905 282.6299 173.6908 305.4297
## 33       239.5602 194.4443 284.6762 170.5613 308.5591
## 34       239.5602 192.4869 286.6336 167.5677 311.5527
myses14= ses(books[,2], inital = "optimal", h=4)
sum((books[,2] - fitted(myses14))^2)
## [1] 30587.69
summary(myses14)
## 
## Forecast method: Simple exponential smoothing
## 
## Model Information:
## Simple exponential smoothing 
## 
## Call:
##  ses(y = books[, 2], h = 4, inital = "optimal") 
## 
##   Smoothing parameters:
##     alpha = 0.3283 
## 
##   Initial states:
##     l = 149.2836 
## 
##   sigma:  31.931
## 
##      AIC     AICc      BIC 
## 315.8506 316.7737 320.0542 
## 
## Error measures:
##                    ME     RMSE     MAE      MPE     MAPE      MASE
## Training set 9.166918 31.93101 26.7731 2.636328 13.39479 0.7987858
##                    ACF1
## Training set -0.1417817
## 
## Forecasts:
##    Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 31       239.5602 198.6390 280.4815 176.9766 302.1439
## 32       239.5602 196.4905 282.6299 173.6908 305.4297
## 33       239.5602 194.4443 284.6762 170.5613 308.5591
## 34       239.5602 192.4869 286.6336 167.5677 311.5527
alpha = c(0.1, 0.3, 0.5, 0.7, 0.9)
sse.hard = c(38390.67 ,30634.58, 31682.57,34993.93, 41209.05)
plot(alpha, sse.hard)

2a

The holt models have higher SSE

myholt.paper = holt(books[,1], initial = "simple", h=4)
sum((books[,1] - fitted(myholt.paper))^2)
## [1] 46917.39
myholt.hard = holt(books[,2], initial = "simple", h=4)
sum((books[,2] - fitted(myholt.hard))^2)
## [1] 36842.1

2b

The holt forecasts have higher error measures across the board for both paperback and hard copy.

summary(myses7)
## 
## Forecast method: Simple exponential smoothing
## 
## Model Information:
## Simple exponential smoothing 
## 
## Call:
##  ses(y = books[, 1], h = 4, inital = "optimal") 
## 
##   Smoothing parameters:
##     alpha = 0.1685 
## 
##   Initial states:
##     l = 170.8257 
## 
##   sigma:  33.6377
## 
##      AIC     AICc      BIC 
## 318.9747 319.8978 323.1783 
## 
## Error measures:
##                    ME     RMSE     MAE       MPE     MAPE      MASE
## Training set 7.176212 33.63769 27.8431 0.4737524 15.57782 0.7021303
##                    ACF1
## Training set -0.2117579
## 
## Forecasts:
##    Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 31       207.1098 164.0013 250.2182 141.1811 273.0384
## 32       207.1098 163.3934 250.8261 140.2513 273.9682
## 33       207.1098 162.7937 251.4258 139.3342 274.8853
## 34       207.1098 162.2021 252.0174 138.4294 275.7901
summary(myholt.paper)
## 
## Forecast method: Holt's method
## 
## Model Information:
## Holt's method 
## 
## Call:
##  holt(y = books[, 1], h = 4, initial = "simple") 
## 
##   Smoothing parameters:
##     alpha = 0.2984 
##     beta  = 0.4984 
## 
##   Initial states:
##     l = 199 
##     b = -27 
## 
##   sigma:  39.5463
## Error measures:
##                    ME     RMSE     MAE      MPE     MAPE      MASE
## Training set 7.769844 39.54634 33.5377 1.633306 18.19621 0.8457332
##                    ACF1
## Training set -0.1088681
## 
## Forecasts:
##    Point Forecast    Lo 80    Hi 80     Lo 95    Hi 95
## 31       222.0201 171.3394 272.7007 144.51068 299.5295
## 32       229.6904 164.8872 294.4935 130.58245 328.7983
## 33       237.3606 145.1175 329.6038  96.28696 378.4343
## 34       245.0309 115.5211 374.5407  46.96280 443.0991
summary(myholt.hard)
## 
## Forecast method: Holt's method
## 
## Model Information:
## Holt's method 
## 
## Call:
##  holt(y = books[, 2], h = 4, initial = "simple") 
## 
##   Smoothing parameters:
##     alpha = 0.439 
##     beta  = 0.1574 
## 
##   Initial states:
##     l = 139 
##     b = -11 
## 
##   sigma:  35.0438
## Error measures:
##                    ME     RMSE      MAE      MPE     MAPE      MASE
## Training set 7.193267 35.04383 27.99174 2.423793 14.18241 0.8351445
##                     ACF1
## Training set -0.07743714
## 
## Forecasts:
##    Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 31       250.7889 205.8784 295.6993 182.1042 319.4735
## 32       254.7003 202.4087 306.9918 174.7273 334.6733
## 33       258.6117 196.3181 320.9052 163.3419 353.8815
## 34       262.5231 187.9903 337.0558 148.5350 376.5111
summary(myses14)
## 
## Forecast method: Simple exponential smoothing
## 
## Model Information:
## Simple exponential smoothing 
## 
## Call:
##  ses(y = books[, 2], h = 4, inital = "optimal") 
## 
##   Smoothing parameters:
##     alpha = 0.3283 
## 
##   Initial states:
##     l = 149.2836 
## 
##   sigma:  31.931
## 
##      AIC     AICc      BIC 
## 315.8506 316.7737 320.0542 
## 
## Error measures:
##                    ME     RMSE     MAE      MPE     MAPE      MASE
## Training set 9.166918 31.93101 26.7731 2.636328 13.39479 0.7987858
##                    ACF1
## Training set -0.1417817
## 
## Forecasts:
##    Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 31       239.5602 198.6390 280.4815 176.9766 302.1439
## 32       239.5602 196.4905 282.6299 173.6908 305.4297
## 33       239.5602 194.4443 284.6762 170.5613 308.5591
## 34       239.5602 192.4869 286.6336 167.5677 311.5527

2c

The intervals calculated in R tend to be skewed a bit lower and are slightly wider.

## Paperback
247-1.96*32
## [1] 184.28
247+1.96*32
## [1] 309.72
# interval = 184-310
##Hardcover
259-1.96*27
## [1] 206.08
259+1.96*27
## [1] 311.92
# interval = 206-311

##Paper
summary(myses7)
## 
## Forecast method: Simple exponential smoothing
## 
## Model Information:
## Simple exponential smoothing 
## 
## Call:
##  ses(y = books[, 1], h = 4, inital = "optimal") 
## 
##   Smoothing parameters:
##     alpha = 0.1685 
## 
##   Initial states:
##     l = 170.8257 
## 
##   sigma:  33.6377
## 
##      AIC     AICc      BIC 
## 318.9747 319.8978 323.1783 
## 
## Error measures:
##                    ME     RMSE     MAE       MPE     MAPE      MASE
## Training set 7.176212 33.63769 27.8431 0.4737524 15.57782 0.7021303
##                    ACF1
## Training set -0.2117579
## 
## Forecasts:
##    Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 31       207.1098 164.0013 250.2182 141.1811 273.0384
## 32       207.1098 163.3934 250.8261 140.2513 273.9682
## 33       207.1098 162.7937 251.4258 139.3342 274.8853
## 34       207.1098 162.2021 252.0174 138.4294 275.7901
# interval = 141-273
summary(myholt.paper)
## 
## Forecast method: Holt's method
## 
## Model Information:
## Holt's method 
## 
## Call:
##  holt(y = books[, 1], h = 4, initial = "simple") 
## 
##   Smoothing parameters:
##     alpha = 0.2984 
##     beta  = 0.4984 
## 
##   Initial states:
##     l = 199 
##     b = -27 
## 
##   sigma:  39.5463
## Error measures:
##                    ME     RMSE     MAE      MPE     MAPE      MASE
## Training set 7.769844 39.54634 33.5377 1.633306 18.19621 0.8457332
##                    ACF1
## Training set -0.1088681
## 
## Forecasts:
##    Point Forecast    Lo 80    Hi 80     Lo 95    Hi 95
## 31       222.0201 171.3394 272.7007 144.51068 299.5295
## 32       229.6904 164.8872 294.4935 130.58245 328.7983
## 33       237.3606 145.1175 329.6038  96.28696 378.4343
## 34       245.0309 115.5211 374.5407  46.96280 443.0991
# interval = 144-299

##Hardcopy
summary(myholt.hard)
## 
## Forecast method: Holt's method
## 
## Model Information:
## Holt's method 
## 
## Call:
##  holt(y = books[, 2], h = 4, initial = "simple") 
## 
##   Smoothing parameters:
##     alpha = 0.439 
##     beta  = 0.1574 
## 
##   Initial states:
##     l = 139 
##     b = -11 
## 
##   sigma:  35.0438
## Error measures:
##                    ME     RMSE      MAE      MPE     MAPE      MASE
## Training set 7.193267 35.04383 27.99174 2.423793 14.18241 0.8351445
##                     ACF1
## Training set -0.07743714
## 
## Forecasts:
##    Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 31       250.7889 205.8784 295.6993 182.1042 319.4735
## 32       254.7003 202.4087 306.9918 174.7273 334.6733
## 33       258.6117 196.3181 320.9052 163.3419 353.8815
## 34       262.5231 187.9903 337.0558 148.5350 376.5111
# interval = 182-319
summary(myses14)
## 
## Forecast method: Simple exponential smoothing
## 
## Model Information:
## Simple exponential smoothing 
## 
## Call:
##  ses(y = books[, 2], h = 4, inital = "optimal") 
## 
##   Smoothing parameters:
##     alpha = 0.3283 
## 
##   Initial states:
##     l = 149.2836 
## 
##   sigma:  31.931
## 
##      AIC     AICc      BIC 
## 315.8506 316.7737 320.0542 
## 
## Error measures:
##                    ME     RMSE     MAE      MPE     MAPE      MASE
## Training set 9.166918 31.93101 26.7731 2.636328 13.39479 0.7987858
##                    ACF1
## Training set -0.1417817
## 
## Forecasts:
##    Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 31       239.5602 198.6390 280.4815 176.9766 302.1439
## 32       239.5602 196.4905 282.6299 173.6908 305.4297
## 33       239.5602 194.4443 284.6762 170.5613 308.5591
## 34       239.5602 192.4869 286.6336 167.5677 311.5527
# interval = 178-302

3a

It looks like there is a general upward trend with a dip around 2000-2001.The data appear to be seasonal with strong sales earlier in the year and a dip in the last quarter.

data(ukcars)
str(ukcars)
##  Time-Series [1:113] from 1977 to 2005: 330 371 271 344 358 ...
head(ukcars)
##         Qtr1    Qtr2    Qtr3    Qtr4
## 1977 330.371 371.051 270.670 343.880
## 1978 358.491 362.822
tail(ukcars)
##         Qtr1    Qtr2    Qtr3    Qtr4
## 2003                         408.740
## 2004 445.458 428.202 379.048 394.042
## 2005 432.796
plot(ukcars)

3b

plot(decompose(ukcars))

cars.seasonal <- seasadj(stl(ukcars, t.window=NULL, s.window='periodic', robust=TRUE))

3c

fit1 <- holt(cars.seasonal, h=8, damped = TRUE)
summary(fit1)
## 
## Forecast method: Damped Holt's method
## 
## Model Information:
## Damped Holt's method 
## 
## Call:
##  holt(y = cars.seasonal, h = 8, damped = TRUE) 
## 
##   Smoothing parameters:
##     alpha = 0.5666 
##     beta  = 3e-04 
##     phi   = 0.9117 
## 
##   Initial states:
##     l = 346.0865 
##     b = -9.7583 
## 
##   sigma:  25.2032
## 
##      AIC     AICc      BIC 
## 1275.490 1276.283 1291.854 
## 
## Error measures:
##                    ME     RMSE     MAE       MPE     MAPE      MASE
## Training set 2.518454 25.20318 20.5804 0.3038991 6.585405 0.6707052
##                   ACF1
## Training set 0.0353549
## 
## Forecasts:
##         Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 2005 Q2       407.4117 375.1125 439.7109 358.0144 456.8090
## 2005 Q3       407.4110 370.2834 444.5387 350.6292 464.1929
## 2005 Q4       407.4104 366.0103 448.8105 344.0944 470.7264
## 2006 Q1       407.4099 362.1359 452.6838 338.1693 476.6504
## 2006 Q2       407.4094 358.5654 456.2533 332.7090 482.1097
## 2006 Q3       407.4089 355.2367 459.5811 327.6184 487.1994
## 2006 Q4       407.4085 352.1062 462.7108 322.8309 491.9860
## 2007 Q1       407.4081 349.1421 465.6741 318.2979 496.5182
fit1.rmse = 25.20
fit1.rmse
## [1] 25.2
plot(fit1)

3d

fit2 <- holt(cars.seasonal, h=8)
summary(fit2)
## 
## Forecast method: Holt's method
## 
## Model Information:
## Holt's method 
## 
## Call:
##  holt(y = cars.seasonal, h = 8) 
## 
##   Smoothing parameters:
##     alpha = 0.6012 
##     beta  = 1e-04 
## 
##   Initial states:
##     l = 343.3854 
##     b = 0.6617 
## 
##   sigma:  25.3907
## 
##      AIC     AICc      BIC 
## 1275.166 1275.726 1288.803 
## 
## Error measures:
##                      ME     RMSE      MAE        MPE     MAPE      MASE
## Training set -0.1407116 25.39072 20.14514 -0.5931913 6.500319 0.6565204
##                    ACF1
## Training set 0.02953472
## 
## Forecasts:
##         Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 2005 Q2       408.3701 375.8306 440.9096 358.6052 458.1350
## 2005 Q3       409.0302 371.0610 446.9993 350.9614 467.0990
## 2005 Q4       409.6903 366.9747 452.4058 344.3625 475.0181
## 2006 Q1       410.3503 363.3641 457.3366 338.4911 482.2096
## 2006 Q2       411.0104 360.1093 461.9116 333.1638 488.8570
## 2006 Q3       411.6705 357.1336 466.2074 328.2635 495.0774
## 2006 Q4       412.3306 354.3845 470.2766 323.7098 500.9514
## 2007 Q1       412.9906 351.8241 474.1572 319.4445 506.5368
fit2.rmse = 25.39
fit2.rmse
## [1] 25.39
plot(fit2)

3e

fit3 = ets(ukcars, model = "ZZZ")
fcast3 = forecast(fit3, h=8)
summary (fcast3)
## 
## Forecast method: ETS(A,N,A)
## 
## Model Information:
## ETS(A,N,A) 
## 
## Call:
##  ets(y = ukcars, model = "ZZZ") 
## 
##   Smoothing parameters:
##     alpha = 0.6267 
##     gamma = 1e-04 
## 
##   Initial states:
##     l = 313.0916 
##     s=-1.1271 -44.606 21.5553 24.1778
## 
##   sigma:  25.2579
## 
##      AIC     AICc      BIC 
## 1277.980 1279.047 1297.072 
## 
## Error measures:
##                    ME     RMSE      MAE        MPE     MAPE      MASE
## Training set 1.324962 25.25792 20.12508 -0.1634983 6.609629 0.6558666
##                    ACF1
## Training set 0.01909295
## 
## Forecasts:
##         Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## 2005 Q2       428.4742 396.1049 460.8436 378.9696 477.9789
## 2005 Q3       362.3149 324.1146 400.5151 303.8926 420.7371
## 2005 Q4       405.7943 362.5421 449.0464 339.6458 471.9428
## 2006 Q1       431.1052 383.3310 478.8793 358.0409 504.1694
## 2006 Q2       428.4742 376.5719 480.3766 349.0964 507.8521
## 2006 Q3       362.3149 306.5892 418.0405 277.0899 447.5398
## 2006 Q4       405.7943 346.4914 465.0972 315.0983 496.4902
## 2007 Q1       431.1052 368.4278 493.7825 335.2484 526.9619
summary(fit3)
## ETS(A,N,A) 
## 
## Call:
##  ets(y = ukcars, model = "ZZZ") 
## 
##   Smoothing parameters:
##     alpha = 0.6267 
##     gamma = 1e-04 
## 
##   Initial states:
##     l = 313.0916 
##     s=-1.1271 -44.606 21.5553 24.1778
## 
##   sigma:  25.2579
## 
##      AIC     AICc      BIC 
## 1277.980 1279.047 1297.072 
## 
## Training set error measures:
##                    ME     RMSE      MAE        MPE     MAPE      MASE
## Training set 1.324962 25.25792 20.12508 -0.1634983 6.609629 0.6558666
##                    ACF1
## Training set 0.01909295
fit3.rmse = 25.23
fit3.rmse
## [1] 25.23
plot(fcast3)

3f

The model using an STL decomposition and additive damped trend had the lowest RMSE at 25.2.

fit1.rmse
## [1] 25.2
fit2.rmse
## [1] 25.39
fit3.rmse
## [1] 25.23

3g

The forecast for the ets model looks for most reasonable because it captures the seasonal trend best.

plot(fit1)

plot(fit2)

plot(fcast3)

4a

It looks like there is a general upward trend. The data appear to be seasonal with spikes in visitors at the end of the year.

data("visitors")
visitors
##        Jan   Feb   Mar   Apr   May   Jun   Jul   Aug   Sep   Oct   Nov
## 1985                          75.7  75.4  83.1  82.9  77.3 105.7 121.9
## 1986  98.0 118.0 129.5 110.6  91.7  94.8 109.5 105.1  95.0 130.3 156.7
## 1987 139.7 147.8 145.2 132.7 120.7 116.5 142.0 140.4 128.0 165.7 183.1
## 1988 161.3 180.4 185.2 160.5 157.1 163.8 203.3 196.9 179.6 207.3 208.0
## 1989 168.9 191.1 180.0 160.1 136.6 142.7 175.4 161.4 149.9 174.1 192.7
## 1990 176.2 192.8 189.1 181.1 149.9 157.3 185.3 178.2 162.7 190.6 198.6
## 1991 177.4 190.6 189.2 168.0 161.4 172.2 208.3 199.3 197.4 216.0 223.9
## 1992 196.1 238.2 217.8 203.8 175.2 176.9 219.3 199.1 190.0 229.3 255.0
## 1993 242.8 245.5 257.9 226.3 213.4 204.6 244.6 239.9 224.0 267.2 285.9
## 1994 250.5 304.3 307.4 255.1 214.9 230.9 282.5 265.4 254.0 301.6 311.0
## 1995 303.8 319.1 313.5 294.2 244.8 261.4 329.7 304.9 268.6 320.7 342.9
## 1996 317.2 392.7 365.6 333.2 261.5 306.9 358.2 329.2 309.2 350.4 375.6
## 1997 342.9 408.0 390.9 325.9 289.1 308.2 397.4 330.4 330.9 366.5 379.5
## 1998 346.2 353.6 338.6 341.1 283.4 304.2 372.3 323.7 323.9 354.8 367.9
## 1999 351.0 398.6 389.0 334.1 298.1 317.1 388.5 355.6 353.1 397.0 416.7
## 2000 360.8 434.6 411.9 405.6 319.3 347.9 429.0 372.9 403.0 426.5 459.9
## 2001 416.6 429.2 428.7 405.4 330.2 370.0 446.9 384.6 366.3 378.5 376.2
## 2002 379.3 437.2 446.5 360.3 329.9 339.4 418.2 371.9 358.6 428.9 437.0
## 2003 396.6 427.5 392.5 321.5 260.9 308.3 415.5 362.2 385.6 435.3 473.3
## 2004 420.2 454.8 432.3 402.8 341.3 367.3 472.0 405.8 395.6 449.9 479.9
## 2005 462.4 501.6 504.7 409.5                                          
##        Dec
## 1985 150.0
## 1986 190.1
## 1987 222.8
## 1988 245.8
## 1989 247.4
## 1990 253.1
## 1991 266.8
## 1992 302.4
## 1993 344.0
## 1994 384.0
## 1995 422.3
## 1996 465.2
## 1997 448.3
## 1998 457.6
## 1999 460.8
## 2000 559.9
## 2001 523.2
## 2002 534.0
## 2003 566.6
## 2004 593.1
## 2005
str(visitors)
##  Time-Series [1:240] from 1985 to 2005: 75.7 75.4 83.1 82.9 77.3 ...
head(visitors)
##        May   Jun   Jul   Aug   Sep   Oct
## 1985  75.7  75.4  83.1  82.9  77.3 105.7
tail(visitors)
##        Jan   Feb   Mar   Apr May Jun Jul Aug Sep Oct   Nov   Dec
## 2004                                                 479.9 593.1
## 2005 462.4 501.6 504.7 409.5
plot(visitors)

myts = ts(visitors, start=c(1985, 5), frequency = 12)
plot(myts)

plot(decompose(myts))

4b

fit1 <- hw(myts, h = 24, seasonal = "multiplicative")
plot(fit1)

4c

variance is increasing in the time series (the seasonal spikes are becoming larger); therefore, multiplicative is necessary.

4d

fit2 = hw(myts, h = 24, seasonal = "multiplicative", damped = TRUE)
fit3 = hw(myts, h = 24, seasonal = "multiplicative", exponential = TRUE)

plot(fit2)

plot(fit3)

4e

Damped holt-winters’ multiplicative has the lowest RMSE, so I prefer that method.

summary(fit1)
## 
## Forecast method: Holt-Winters' multiplicative method
## 
## Model Information:
## Holt-Winters' multiplicative method 
## 
## Call:
##  hw(y = myts, h = 24, seasonal = "multiplicative") 
## 
##   Smoothing parameters:
##     alpha = 0.4154 
##     beta  = 0.0063 
##     gamma = 1e-04 
## 
##   Initial states:
##     l = 90.826 
##     b = 3.0992 
##     s=0.932 1.0506 1.0811 0.9771 1.3085 1.0715
##            1.0229 0.9074 0.9401 1.0494 0.8568 0.8026
## 
##   sigma:  0.055
## 
##      AIC     AICc      BIC 
## 2633.589 2636.346 2692.760 
## 
## Error measures:
##                      ME    RMSE      MAE        MPE     MAPE      MASE
## Training set -0.9498442 14.8295 10.96716 -0.8150922 4.271167 0.4050069
##                   ACF1
## Training set 0.2223887
## 
## Forecasts:
##          Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## May 2005       369.3175 343.3002 395.3348 329.5275 409.1076
## Jun 2005       395.5080 365.2767 425.7393 349.2733 441.7427
## Jul 2005       485.9444 446.0391 525.8497 424.9145 546.9743
## Aug 2005       436.7465 398.5070 474.9859 378.2643 495.2287
## Sep 2005       422.9069 383.6657 462.1481 362.8927 482.9211
## Oct 2005       478.2627 431.4628 525.0627 406.6885 549.8370
## Nov 2005       502.5833 450.9301 554.2365 423.5865 581.5800
## Dec 2005       615.6455 549.4181 681.8728 514.3595 716.9314
## Jan 2006       461.1564 409.3845 512.9284 381.9781 540.3348
## Feb 2006       511.8202 452.0068 571.6335 420.3436 603.2968
## Mar 2006       498.9206 438.3614 559.4798 406.3033 591.5378
## Apr 2006       443.9647 388.1032 499.8261 358.5320 529.3974
## May 2006       383.5190 333.5830 433.4550 307.1484 459.8896
## Jun 2006       410.6680 355.4225 465.9134 326.1774 495.1585
## Jul 2006       504.5116 434.4881 574.5350 397.4199 611.6032
## Aug 2006       453.3808 388.5399 518.2217 354.2152 552.5464
## Sep 2006       438.9632 374.3497 503.5767 340.1454 537.7811
## Oct 2006       496.3635 421.2456 571.4814 381.4806 611.2464
## Nov 2006       521.5446 440.4747 602.6146 397.5588 645.5305
## Dec 2006       638.7996 536.9011 740.6982 482.9592 794.6400
## Jan 2007       478.4461 400.1915 556.7008 358.7660 598.1263
## Feb 2007       530.9496 441.9744 619.9248 394.8738 667.0255
## Mar 2007       517.5100 428.7206 606.2994 381.7183 653.3017
## Apr 2007       460.4553 379.6266 541.2840 336.8384 584.0721
## RMSE = 14.83
summary(fit2)
## 
## Forecast method: Damped Holt-Winters' multiplicative method
## 
## Model Information:
## Damped Holt-Winters' multiplicative method 
## 
## Call:
##  hw(y = myts, h = 24, seasonal = "multiplicative", damped = TRUE) 
## 
##   Smoothing parameters:
##     alpha = 0.6306 
##     beta  = 0.0071 
##     gamma = 1e-04 
##     phi   = 0.9797 
## 
##   Initial states:
##     l = 85.7688 
##     b = 3.4912 
##     s=0.9328 1.0558 1.0829 0.9805 1.3187 1.0838
##            1.029 0.9097 0.9317 1.0447 0.8442 0.7861
## 
##   sigma:  0.0542
## 
##      AIC     AICc      BIC 
## 2624.818 2627.913 2687.469 
## 
## Error measures:
##                     ME     RMSE      MAE        MPE     MAPE      MASE
## Training set 0.9123468 14.44801 10.64909 0.07071844 4.064322 0.3932608
##                    ACF1
## Training set 0.01740636
## 
## Forecasts:
##          Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## May 2005       355.5226 330.8178 380.2275 317.7398 393.3054
## Jun 2005       382.1616 350.6620 413.6613 333.9871 430.3362
## Jul 2005       473.4585 429.0426 517.8745 405.5302 541.3868
## Aug 2005       422.7207 378.6914 466.7499 355.3837 490.0576
## Sep 2005       413.1132 366.1242 460.1022 341.2498 484.9767
## Oct 2005       467.7761 410.3573 525.1949 379.9617 555.5906
## Nov 2005       493.1745 428.4256 557.9233 394.1496 592.1993
## Dec 2005       600.6053 516.8496 684.3611 472.5120 728.6986
## Jan 2006       446.9945 381.1536 512.8354 346.2995 547.6895
## Feb 2006       494.1338 417.6065 570.6611 377.0955 611.1722
## Mar 2006       482.2060 403.9860 560.4260 362.5788 601.8331
## Apr 2006       426.4016 354.1904 498.6127 315.9642 536.8390
## May 2006       359.6485 296.2392 423.0578 262.6723 456.6247
## Jun 2006       386.5021 315.7314 457.2729 278.2676 494.7366
## Jul 2006       478.7214 387.8801 569.5626 339.7917 617.6511
## Aug 2006       427.3196 343.4452 511.1939 299.0448 555.5943
## Sep 2006       417.5121 332.8892 502.1350 288.0925 546.9316
## Oct 2006       472.6513 373.8771 571.4254 321.5892 623.7133
## Nov 2006       498.2053 391.0042 605.4063 334.2554 662.1551
## Dec 2006       606.6022 472.3745 740.8299 401.3187 811.8857
## Jan 2007       451.3631 348.7700 553.9561 294.4605 608.2656
## Feb 2007       498.8610 382.5092 615.2128 320.9163 676.8057
## Mar 2007       486.7215 370.3466 603.0964 308.7414 664.7016
## Apr 2007       430.3102 324.9295 535.6910 269.1443 591.4762
## RMSE = 14.45
summary(fit3)
## 
## Forecast method: Holt-Winters' multiplicative method with exponential trend
## 
## Model Information:
## Holt-Winters' multiplicative method with exponential trend 
## 
## Call:
##  hw(y = myts, h = 24, seasonal = "multiplicative", exponential = TRUE) 
## 
##   Smoothing parameters:
##     alpha = 0.5722 
##     beta  = 0.0013 
##     gamma = 1e-04 
## 
##   Initial states:
##     l = 91.0884 
##     b = 1.0025 
##     s=0.9278 1.0475 1.0821 0.9815 1.3152 1.0813
##            1.0294 0.9145 0.9348 1.0438 0.8497 0.7923
## 
##   sigma:  0.0556
## 
##      AIC     AICc      BIC 
## 2633.767 2636.524 2692.938 
## 
## Error measures:
##                     ME     RMSE      MAE       MPE   MAPE      MASE
## Training set 0.6442177 14.49416 10.62951 0.2554469 4.0328 0.3925378
##                    ACF1
## Training set 0.07595792
## 
## Forecasts:
##          Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## May 2005       363.2966 337.8208 389.2569 324.0181 402.6745
## Jun 2005       391.2661 359.7358 424.2852 343.0844 443.5193
## Jul 2005       482.6967 438.4085 527.6502 416.8981 553.2191
## Aug 2005       434.1673 390.6843 479.5231 369.7809 506.2813
## Sep 2005       426.5256 381.6490 474.7344 357.4167 499.7084
## Oct 2005       482.2232 427.2975 539.0342 399.4156 571.2708
## Nov 2005       508.6900 448.2696 570.2105 416.8343 609.4965
## Dec 2005       621.3098 543.6344 703.7494 504.3156 750.2256
## Jan 2006       465.6513 402.9775 529.5631 375.6443 567.5558
## Feb 2006       515.5859 443.5447 590.0541 410.6985 635.5637
## Mar 2006       501.2247 429.3370 577.9802 393.6555 624.4987
## Apr 2006       445.8398 378.7841 514.6424 346.1670 559.1440
## May 2006       382.3303 323.2775 443.3297 296.6568 478.7673
## Jun 2006       411.7651 346.2099 480.8804 315.1182 523.4737
## Jul 2006       507.9859 426.1445 595.2707 385.8457 646.3177
## Aug 2006       456.9141 379.7601 536.9984 346.3457 590.0385
## Sep 2006       448.8719 370.5287 530.0068 334.7876 582.0881
## Oct 2006       507.4876 417.6135 599.5998 380.7881 661.4887
## Nov 2006       535.3411 437.0597 637.4196 394.6617 699.8991
## Dec 2006       653.8613 532.4577 783.5988 477.7632 862.8027
## Jan 2007       490.0476 396.8402 588.4244 357.3015 651.6451
## Feb 2007       542.5983 437.8088 655.2925 389.6924 732.5259
## Mar 2007       527.4847 420.3169 639.4311 380.2899 714.9302
## Apr 2007       469.1980 373.9863 570.7325 333.6416 641.1310
## RMSE = 14.49

4f

fit1= hw(myts, seasonal = "multiplicative")
fit2= ets(myts, model="ZZZ")
lambda = BoxCox.lambda(myts)
boxcox_visitors = BoxCox(myts, lambda)
fit3 = ets(boxcox_visitors, model='AAZ')
fit4 = snaive(boxcox_visitors)
decomposed = decompose(boxcox_visitors)
seasonal_visitors = decomposed$seasonal
fit5 = ets(seasonal_visitors, mode="ZZZ")


plot(fit1)

plot(fit2)

plot(fit3)

plot(fit4)

plot(fit5)

4g

The additive ETS model applied to a Box-Cox transformed series performed best by all error measures.

fit1.forecast = forecast(fit1, h=24)
fit1.accuracy = accuracy(fit1)

fit2.forecast = forecast(fit2, h=24)
fit2.accuracy = accuracy(fit2)

fit3.forecast = forecast(fit3, h=24)
fit3.accuracy = accuracy(fit3)

fit4.forecast = forecast(fit4, h=24)
fit4.accuracy = accuracy(fit4)

fit5.forecast = forecast(fit5, h=24)
fit5.accuracy = accuracy(fit5)

plot(fit1.forecast)

plot(fit2.forecast)

plot(fit3.forecast)

plot(fit4.forecast)

plot(fit5.forecast)

fit1.accuracy
##                      ME    RMSE      MAE        MPE     MAPE      MASE
## Training set -0.9498442 14.8295 10.96716 -0.8150922 4.271167 0.4050069
##                   ACF1
## Training set 0.2223887
fit2.accuracy
##                     ME     RMSE      MAE        MPE     MAPE      MASE
## Training set -1.536043 15.86105 11.53405 -0.7017724 4.076346 0.4259416
##                      ACF1
## Training set -0.004687451
fit3.accuracy
##                      ME      RMSE       MAE        MPE     MAPE      MASE
## Training set 0.01356641 0.2404272 0.1885684 0.05848444 1.417893 0.3854267
##                    ACF1
## Training set 0.00306484
fit4.accuracy
##                     ME      RMSE       MAE      MPE     MAPE MASE
## Training set 0.3486245 0.5883754 0.4892459 2.717695 3.768233    1
##                   ACF1
## Training set 0.7406243
fit5.accuracy
##                        ME         RMSE          MAE          MPE
## Training set 3.469447e-18 2.663427e-17 1.572816e-17 7.054592e-15
##                      MAPE MASE      ACF1
## Training set 7.054592e-15  Inf 0.1748418