library(tidyverse)
library(fpp3) # tsibble, feasts and fable: ACF(), PACF(), ARIMA(), forecast()ECON 4354/6354 — Homework 3
- Questions 1–3 are analytical. Show every step of your derivations; LaTeX math in the
.qmdworks well, but you can also submit scanned copy of handwritten answers. It is recommended to write code to verify your answers. - Question 4 is an empirical exercise. Use Quarto/Knitr chunks for all work, and discuss what you find.
- The questions are adapted from Diebold, Forecasting, Chapter 7.
Throughout, \(\varepsilon_t \sim WN(0, \sigma^2)\) is white noise and \(L\) is the lag operator, \(L y_t = y_{t-1}\).
0. Setup
1. Shapes of Correlograms
Consider the three processes
\(y_t = \dfrac{1}{1 - 1.05L - 0.09L^2}\,\varepsilon_t\)
\(y_t = (1 - 0.4L)\,\varepsilon_t\)
\(y_t = \dfrac{1}{1 - 0.7L}\,\varepsilon_t\)
For each process:
Find the inverse roots of its autoregressive and moving-average lag-operator polynomials, and state whether the process is covariance stationary and whether it is invertible.
Sketch or describe the expected shape of its autocorrelation and partial autocorrelation functions, and explain why.
2. The Autocovariance Function of the MA(1)
Let \(y_t = \varepsilon_t + \theta\varepsilon_{t-1}\).
Show that its autocovariance function is \[ \gamma(\tau) = E(y_t y_{t-\tau}) = \begin{cases} (1 + \theta^2)\,\sigma^2, & \tau = 0, \\ \theta\sigma^2, & \tau = 1, \\ 0, & \tau \geq 2, \end{cases} \] by expanding \(E\big[(\varepsilon_t + \theta\varepsilon_{t-1})(\varepsilon_{t-\tau} + \theta\varepsilon_{t-\tau-1})\big]\) into four expectations and evaluating each one. State which property of white noise each step uses. Why is \(E(y_t y_{t-\tau})\) the autocovariance here?
Deduce the autocorrelation function \(\rho(\tau)\), and show that \(|\rho(1)| \leq 1/2\) for every value of \(\theta\).
3. ARMA Algebra
Let \(\varepsilon_t \sim \text{iid}(0, \sigma^2)\), that is, independent white noise, and let \(\Omega_{t-1} = \{\varepsilon_{t-1}, \varepsilon_{t-2}, \ldots\}\). For each process below, derive
- the unconditional mean \(E(y_t)\) and variance \(\operatorname{var}(y_t)\);
- the autocovariance function \(\gamma(\tau)\) and autocorrelation function \(\rho(\tau)\), for all \(\tau \geq 0\);
- the conditional mean \(E(y_t \mid \Omega_{t-1})\) and variance \(\operatorname{var}(y_t \mid \Omega_{t-1})\).
\(y_t = \mu + \varepsilon_t + \theta_1\varepsilon_{t-1} + \theta_2\varepsilon_{t-2}\)
\(y_t = \phi y_{t-1} + \varepsilon_t + \theta\varepsilon_{t-1}\), with \(|\phi| < 1\) and \(|\theta| < 1\).
Hint for (b): either use the moving-average representation \(y_t = \sum_{j=0}^{\infty} \psi_j \varepsilon_{t-j}\), whose weights are \(\psi_0 = 1\) and \(\psi_j = (\phi + \theta)\,\phi^{j-1}\) for \(j \geq 1\), or multiply both sides of the model by \(y_{t-\tau}\) and take expectations.
4. Mechanics of Fitting ARMA Models
BankWire is a financial wire transfer system in a country responsible for much of the world’s finance. You have daily transfers over BankWire for a recent span of 200 business days, and your job is to model and forecast them.
The data
bw <- read_csv("data/hw3_bankwire.csv") |> as_tsibble(index = day)
glimpse(bw)Rows: 200
Columns: 2
$ day <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 1…
$ transfers <dbl> 11.553850, 13.682788, 12.483232, 10.833068, 10.845783, 11.66…
The file data/hw3_bankwire.csv holds 200 consecutive business days:
| Variable | Description |
|---|---|
day |
business day, numbered 1 to 200 (calendar dates are not available) |
transfers |
daily transfers over BankWire |
Useful functions:
gg_tsdisplay(bw, transfers, plot_type = "partial")draws the series with its ACF and PACF.model(ARIMA(transfers ~ 1 + pdq(p, 0, q) + PDQ(0, 0, 0)))fits an ARMA(\(p,q\)) with a mean. On the fitted model,report()andglance()give the estimates and AIC, AICc and BIC (BIC is the SIC),gg_arma()plots the inverse roots, andaugment(fit) |> features(.innov, ljung_box, lag = 10, dof = p + q)tests the residuals for serial correlation.forecast(h = 25)gives point and interval forecasts, whichhilo(95)extracts andautoplot()draws;accuracy()compares them with the realizations.- In base R,
arima(y, order = c(p, 0, q)),Box.test()andpredict(fit, n.ahead = 25)do the same jobs.
Keep \(d = 0\) in pdq(): left to itself, ARIMA() may difference the series, and the result is no longer an ARMA model. Watch out for common factors.
(a) Trend and seasonality
Is a trend or seasonality operative? Defend your answer. Business days come in weeks of five, so a day-of-week effect would be a pattern that repeats every five observations.
# TODO: plot the series and its correlogram, and check for a trend and for a
# five-day seasonal pattern.(b) A parsimonious ARMA model
Using all 200 days, find a parsimonious ARMA(\(p,q\)) model that fits well, and defend its adequacy.
# TODO: shortlist candidates from the correlogram, compare them by AIC and SIC,
# and check the residuals and inverse roots of the model you choose.(c) Using only the first 175 days
Repeat (b) using only days 1 to 175 for model selection and estimation. Must the selected model be the same as with all 200 days? Is yours?
# TODO: bw175 <- bw |> filter(day <= 175), then redo (b).(d) Forecasting days 176 to 200
Use your model from (c) to produce point forecasts and 95% interval forecasts for days 176 through 200. Plot them together with the history, and discuss the pattern of the forecasts.
# TODO: forecast 25 days ahead and plot the forecasts with their intervals.(e) Forecasts against realizations
Compare your forecasts with the realized values for days 176 to 200. Do the forecasts perform well? Why or why not? Judge them against at least one simple benchmark.
# TODO: add the realizations to your plot and compute measures of forecast
# accuracy for your model and for the benchmark.