1. Consider the pigs series — the number of pigs slaughtered in Victoria each month.

(a) Use the ses() function in R to find the optimal values of α and ℓ0, and generate forecasts for the next four months.

The optimal α and ℓ0 are 0.2971 and 77260.05, respectively. The four month forecast is reflected in the plot below.

spigs <- ses(pigs, h = 4)
summary(spigs)
## 
## Forecast method: Simple exponential smoothing
## 
## Model Information:
## 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 
## 
## Error measures:
##                    ME    RMSE      MAE       MPE     MAPE      MASE       ACF1
## Training set 385.8721 10253.6 7961.383 -0.922652 9.274016 0.7966249 0.01282239
## 
## Forecasts:
##          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
autoplot(spigs) + theme_fivethirtyeight()



(b)Compute a 95% prediction interval for the first forecast using ^y±1.96 where s is the standard deviation of the residuals. Compare your interval with the interval produced by R.

The two confidence intervals are (78679.97 - 118952.84) and (78611.97 - 119020.84). The second, R produced, interval is wider because the R factors in degrees of freedom when calculating variance.

Confidence Interval

##     Lower     Upper 
##  78679.97 118952.84


Confidence Interval Produced By R

##     Lower     Upper 
##  78611.97 119020.84

  1. 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.

The paperback and hardcover books have show a positive trend for the month (more sales at end of month). With only 30-days of data is difficult call out any weekly seasonality. It appears more hardcover books are sold during the period. Hardcover books also appear to have greater volatility.


(b) Use the ses() function to forecast each series, and plot the forecasts.


(c) Compute the RMSE values for the training data in each case.

The RMSE for paperback books is 33.6376868, that compares to 31.931015 for hardcover books. Despite appearing to be more volatile, hardcover books had a lower RMSE.


  1. 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.



(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.

SES Method Holt Method
Paperback 33.6376868 31.136923
Hardcover 31.931015 27.193578

The Holt method yield lover RMSE compared to the SES method.


## [1] 31.13692
## [1] 27.19358

(c) Compare the forecasts for the two series using both methods. Which do you think is best?
The hardcover series yield lower RMSE under both SEs and Holt methodologies. It appears to be the better forecast from that perspective and also passes the eye test when comparing the autoplot of the series. That said, we are not dealing with a lot of data, so its difficult to give a definitive answer.




(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.

Lower Limit Upper Limit
95% PI PB Holt fn 143.9129858 275.0205452
95% PI PB formula 148.4383964 270.4951346
95% PI HC Holt fn 192.9221708 307.4255737
95% PI HC formula 196.8744594 303.4732851

Enter commentary here!


  1. 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?

Review of Accuracy of Model



The table below indicates that the Box Cox Model yielded the best RMSE (26.393)

Model RMSE
Holt 26.5821882
———————- ——–
Holt Dampened 26.5401853
———————- ——–
Holt Box Cox 26.3937555
———————- ——–
HOlt Box Cos Dampened 26.5332106
———————- ——–


  1. Recall your retail time series data (from Exercise 3 in Section 2.10).

(a) Why is multiplicative seasonality necessary for this series?


(b) Apply Holt-Winters’ multiplicative method to the data. Experiment with making the trend damped.


(c) Compare the RMSE of the one-step forecasts from the two methods. Which do you prefer?


The RMSE of the Holt method with no dampening was 25.203811 compared to 25.1005865 for the Holt with Dampening method. The undampened approach yield the superior results.


(d) Check that the residuals from the best method look like white noise.


Owing to a p-value from the Ljung-Box test that approximates zero it seems there may be some autocorrelation in the model. This is consistent with residuals plot that appears to have decreasing variablility over time.


## 
##  Ljung-Box test
## 
## data:  Residuals from Holt-Winters' multiplicative method
## Q* = 250.64, df = 8, p-value < 2.2e-16
## 
## Model df: 16.   Total lags used: 24


(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?__


The RMSEs for the Holt winters was far superior to the Naive model (25/65 vs 72/109), the larege differences between training and test RMSE make speak to other challenges.


##                      ME     RMSE      MAE        MPE     MAPE      MASE
## Training set   2.658058 25.00649 18.25149  0.2228273 1.965971 0.2958851
## Test set     -49.514639 65.26190 52.87938 -2.2820578 2.442746 0.8572571
##                      ACF1 Theil's U
## Training set -0.006737509        NA
## Test set      0.438392290 0.5339184
##                    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
  1. 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?

The STL methodology outperformed the ETS as is evident from the plot below. The STL with decomposition looks to be the strongest performer.


## [1] -85.57854