Exercise

Evaluating forecast accuracy of seasonal methods

As you learned in the first chapter, the window() function specifies the start and end of a time series using the relevant times rather than the index values. Either of those two arguments can be formatted as a vector like c(year, period) which you have also previously used as an argument for ts(). Again, period refers to quarter here.

Here, you will use the Melbourne quarterly visitor numbers (visnights[, "VICMetro"]) to create three different training sets, omitting the last 1, 2 and 3 years, respectively. Inspect the pre-loaded visnights data in your console before beginning the exercise; this will help you determine the correct value to use for the keyword h (which specifies the number of values you want to forecast) in your forecasting methods.

Then for each training set, compute the next year of data, and finally compare the mean absolute percentage error (MAPE) of the forecasts using accuracy(). Why do you think that the MAPE vary so much?

Instructions

100 XP
  • Use window() to create three training sets from visnights[,"VICMetro"], omitting the last 1, 2 and 3 years; call these train1, train2, and train3, respectively. Set the end keyword accordingly.
  • Compute one year of forecasts for each training set using the snaive() method. Call these fc1, fc2, and fc3, respectively.
  • Following the structure of the sample code, compare the MAPE of the three sets of forecasts using the accuracy() function as your test set.