The gasoline series consists of weekly data for supplies of US nished motor gasoline product, from 2 February 1991 to 20 January 2017. The units are in “million barrels per day”. Consider only the data to the end of 2004.
a. Fit a harmonic regression with trend to the data. Experiment with changing the number Fourier terms. Plot the observed gasoline and tted values and comment on what you see.
b. Select the appropriate number of Fourier terms to include by minimising the AICc or CV value.
c. Check the residuals of the nal model using the checkresiduals() function. Even though the residuals fail the correlation tests, the results are probably not severe enough to make much dierence to the forecasts and prediction intervals. (Note that the correlations are relatively small, even though they are signicant.)
d. To forecast using harmonic regression, you will need to generate the future values of the Fourier terms. This can be done as follows.
where fit is the tted model using tslm() , K is the number of Fourier terms used in creating fit , and h is the forecast horizon required.
Forecast the next year of data.
e. Plot the forecasts along with the actual data for 2005. What do you find?