ETW3420 Principles of Forecasting and Applications
Principles of Forecasting and Applications
Copyright By PowCoder代写 加微信 powcoder
Topic 8 Pre-tutorial Activity
In this pre-tutorial activity, you will:
(i) Estimate an OLS regression and an OLS regression with ARIMA errors.
(ii) Forecast using an OLS regression with ARIMA errors.
(iii) Learn the appropriate R functions to do the above.
Question 1
Consider monthly sales and advertising data for an automotive parts company (data set
(a) Plot the data using autoplot. Why is it useful to set facets=TRUE?
autoplot(advert, facets=TRUE)
Because the data are on different scales, they should not be plotted in the same panel. Setting
facets=TRUE puts them in different panels.
(b) Fit a standard regression model yt = a+ bxt + ηt where yt denotes sales and xt denotes
advertising using the tslm() function.
(fit <- tslm(sales ~ advert, data=advert)) (c) Show that the residuals have significant autocorrelation. checkresiduals(fit) (d) What difference does it make if you use the Arima function instead: Arima(advert[,'sales'], xreg=advert[,'advert'], order=c(0,0,0)) • Note that in the above code, the first argument specified is the dependent variable; the second argument specifies the X-regressor; while the third argument specifies the ARIMA order of the error term. Since we assume, for now, that ηt is white noise, it corresponds to an ARIMA(0,0,0) process. (e) Refit the model using auto.arima(). How much difference does the error model make to the estimated parameters? What ARIMA model for the errors is selected? (fit <- auto.arima(advert[,'sales'], xreg=advert[,'advert'])) • Note how the auto.arima() function automatically selects an ARIMA process for ηt. Also note that the first and second arguments specified in the command refer to the dependent and independent variables, respectively. • From the output, there is first order differencing. The advert coefficient has changed a little. The error model is ARIMA(0,1,0). (f) Check the residuals of the fitted model. checkresiduals(fit) (g) Assuming the advertising budget for the next six months is exactly 10 units per month, produce sales forecasts with prediction intervals for the next six months. • To do this, you will need to specify the X-regressor representing these values as an xreg argument in the forecast() function. This is different from the newdata argument which you used in last week’s tutorial. (fc <- forecast(fit, xreg = rep(10,6))) autoplot(fc) + xlab("Month") + ylab("Sales") Question 1 程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com