ETW3420 Principles of Forecasting and Applications
Principles of Forecasting and Applications
Copyright By PowCoder代写 加微信 powcoder
Topic 4 Exercises
Question 1
Show that a 3 × 5 MA is equivalent to a 7-term weighted moving average with weights of
0.067, 0.133, 0.200, 0.200, 0.200, 0.133, and 0.067.
5-term moving average:
(yj−2 + yj−1 + yj + yj+1 + yj+2).
3-term moving average:
(zt−1 + zt + zt+1).
Question 2
The plastics data set consists of the monthly sales (in thousands) of product A for a
plastics manufacturer for five years.
(a) Plot the time series of sales of product A. Can you identify seasonal fluctuations and/or
a trend-cycle?
(b) Use a classical multiplicative decomposition to calculate the trend-cycle and seasonal
(c) Do the results support the graphical interpretation from part a? What can we learn
from this?
(d) Calculate the trend-cycle component by using an appropriate centred moving average
and confirm if the values obtained are identical with those obtained in Part(b)
ma(plastics, order = ___ , centre = ____)
(e) Compute and plot the seasonally adjusted data.
(f) Superimpose the time series plot with the seasonally adjusted data.
Question 3
We will use the a10 data (Total monthly scripts for pharmaceutical products falling under
ATC code A10, as recorded by the Australian Health Insurance Commission, July 1991 –
June 2008) for this exercise.
(a) Plot the data and determine if a Box-Cox transformation is necessary.
(b) Use an STL decomposition to calculate the trend-cycle and seasonal indices. (Experi-
ment with having fixed or changing seasonality.)
#STL with fixed seasonality
fit <- stl(y, s.window='periodic') autoplot(fit) #STL with changing seasonality fit2 <- stl(y, s.window = 9) autoplot(fit2) The seasonality looks fairly stable, so we’ll use a periodic s.window. (c) Compute and plot the seasonally adjusted data. (d) Use a drift method to produce forecasts of the seasonally adjusted data. (e) Use stlf to reseasonalize the results, giving forecasts for the original data. • Note that the first argument of the stlf() function is the variable in its level form. The subsequent lambda argument will take care of the Box-Cox transformation, and the reverse transformation. • This is what the stlf() function does: – It seasonally adjusts the data from an STL decomposition. – Using the forecasting method specified in the method argument, the seasonally adjusted data is forecasted. – The seasonal component from the last year of data is then added back into the forecasts of the seasonally adjusted data. – The result returned is hence the reseasonalized forecasts. (e) Do the residuals look uncorrelated? ## Warning in checkresiduals(fc): The fitted degrees of freedom is based on ## the model used for the seasonally adjusted data. (f) Compare forecasts from stlf with those from snaive, using a test set commencing from July 2006. Which is better? #Create train and test sets train <- window(a10, end = c(2006, 6)) test <- window(a10, start = c(2006, 7)) #(continue with the code) Question 4 (Self-Practice) Use stlf to produce forecasts of the writing and fancy series with either method="naive" or method="rwdrift", whichever is most appropriate. Use the lambda argument if you think a Box-Cox transformation is required. Question 1 Question 2 Question 3 Question 4 (Self-Practice) 程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com