Consider the the number of pigs slaughtered in Victoria, available in
the aus_livestock dataset.
Use the ETS() function in R to estimate the
equivalent model for simple exponential smoothing. Find the optimal
values of \(\alpha\) and \(\ell_0\), and generate forecasts for the
next four months (To plot the forecasting, you can plot starting from
2010)
Compute a 95% prediction interval for the first forecast using \(\hat{y} \pm 1.96s\) where \(s\) is the standard deviation of the residuals. Compare your interval with the interval produced by R.
Data set global_economy contains the annual Exports from
many countries. Select one country to analyse.
Plot the Exports series and discuss the main features of the data. And give a short perspective of the fluctuations of the exports of your country.
Use an ETS(A,N,N) model to forecast the series, and plot the forecasts for the next 10 years
Compute the RMSE values for the training data.
Compare the results to those from an ETS(A,A,N) model. (Remember that the trended model is using one more parameter than the simpler model.) Discuss the merits of the two forecasting methods for this data set.
Compare the forecasts from both methods. Which do you think is best?
Forecast the Chinese GDP from the global_economy data
set using an ETS model. Experiment with the various options in the
ETS() 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 is doing to the forecasts. Assume h=20 when
forecasting, so you can clearly see the differences between the various
options when plotting the forecasts.
Find an ETS model for the Gas data from aus_production
and forecast the next few years (h=36). Why is multiplicative
seasonality necessary here? Experiment with making the trend damped.
Does it improve the forecasts (check the residuals properties before
forecasting)?
Recall your retail time series data (If not, just generate your series by choosing your set.seed)
set.seed(12345678)
myseries <- aus_retail %>%
filter(`Series ID` == sample(aus_retail$`Series ID`, 1))
myseries %>% autoplot(Turnover)
Why is multiplicative seasonality necessary for this series?
Apply Holt-Winters’ multiplicative method to the data. Experiment with making the trend damped. Forecast assuming h=36
Compare the RMSE of the one-step forecasts from the two methods. Which do you prefer?
Check that the residuals from the best method look like white noise.
Now find the test set RMSE, while training the model to the end of 2010. Can you beat the seasonal naive approach?
Compute the total domestic overnight trips across Australia from the
tourism dataset.
Plot the data and describe the main features of the series.
Decompose the series using STL and obtain the seasonally adjusted data.
Forecast the next two years of the series using an additive
damped trend method applied to the seasonally adjusted data. (This can
be specified using decomposition_model().)
For example, you can use the following code
stletsdamped <- decomposition_model(
STL(Trips),
ETS(season_adjust ~ error("A") + trend("Ad") + season("N")))
Forecast the next two years of the series using an appropriate model for holter linear method applied to the seasonally adjusted data (as before but without damped trend).
Now use ETS() to choose a seasonal model for the
data.
Compare the RMSE of the ETS model with the RMSE of the models you obtained using STL decomposition. Which gives the better in-sample fits?
Compare the forecasts from the three approaches? Which seems most reasonable?
Check the residuals of your preferred model.
For this exercise use the quarterly number of arrivals to Australia
from New Zealand, 1981 Q1 – 2012 Q3, from data set
aus_arrivals.
Make a time plot of your data and describe the main features of the series.
Create a training set that withholds the last two years of available data. Forecast the test set using an appropriate model for Holt-winter multiplicative method.
Why is multiplicative seasonality necessary here?
Forecast the two-year test set using each of the following methods (plot all the model without PI): i) an ETS model; ii) a ETS model applied to a log transformed series; iii) a seasonal naive method; iv) an STL decomposition applied to the log transformed data followed by an ETS model applied to the seasonally adjusted (transformed) data.
Which method gives the best forecasts? Does it pass the residual tests?
Compare the same four methods using time series cross-validation instead of using a training and test set. Do you come to the same conclusions(assume step-size and forecast = 3 to reduce computation time and initial fold size = 36)?
Apply cross-validation techniques to produce 1 year ahead ETS and
seasonal naive forecasts for Portland cement production (from
aus_production). initial size of 5 years, and increment the
window by one observation.
Compute the MSE of the resulting \(4\)-step-ahead errors. Comment on which forecasts are more accurate. Is this what you expected? (challenging)
Write your own function to implement simple exponential smoothing.
The function should take arguments y (the response data),
alpha (the smoothing parameter \(\alpha\)) and level (the
initial level \(\ell_0\)). It should
return the forecast of the next observation in the series. Does it give
the same forecast as ETS() in question 1?
Modify your function from the previous exercise to return the sum of
squared errors rather than the forecast of the next observation. Then
use the optim() function to find the optimal values of
\(\alpha\) and \(\ell_0\). Do you get the same values as the
ETS() function?
Combine your previous two functions to produce a function that both finds the optimal values of \(\alpha\) and \(\ell_0\), and produces a forecast of the next observation in the series.