-
Notifications
You must be signed in to change notification settings - Fork 0
/
2023_03.qmd
344 lines (257 loc) · 12.4 KB
/
2023_03.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
---
title: "March 2023"
author:
- name: "Tomasz Woźniak"
affiliations:
- University of Melbourne
orcid: 0000-0003-2212-2378
execute:
freeze: auto
---
```{r interest data}
#| echo: false
#| message: false
#| warning: false
# download daily interest rates
icr_dwnld = readrba::read_rba(series_id = "FIRMMCRTD") # Cash Rate Target
icr_tmp = xts::xts(icr_dwnld$value, icr_dwnld$date)
dates_tmp = xts::xts(as.Date(icr_dwnld$date), icr_dwnld$date)
by1m_dwnld = readrba::read_rba(series_id = "FIRMMBAB30D")
by1m_tmp = xts::xts(by1m_dwnld$value, by1m_dwnld$date)
by3m_dwnld = readrba::read_rba(series_id = "FIRMMBAB90D")
by3m_tmp = xts::xts(by3m_dwnld$value, by3m_dwnld$date)
by6m_dwnld = readrba::read_rba(series_id = "FIRMMBAB180D")
by6m_tmp = xts::xts(by6m_dwnld$value, by6m_dwnld$date)
by2y_dwnld = readrba::read_rba(series_id = "FCMYGBAG2D")
by2y_tmp = xts::xts(by2y_dwnld$value, by2y_dwnld$date)
by3y_dwnld = readrba::read_rba(series_id = "FCMYGBAG3D")
by3y_tmp = xts::xts(by3y_dwnld$value, by3y_dwnld$date)
by5y_dwnld = readrba::read_rba(series_id = "FCMYGBAG5D")
by5y_tmp = xts::xts(by5y_dwnld$value, by5y_dwnld$date)
by10y_dwnld = readrba::read_rba(series_id = "FCMYGBAG10D")
by10y_tmp = xts::xts(by10y_dwnld$value, by10y_dwnld$date)
long_ou_tmp = na.omit(merge(by2y_tmp, by3y_tmp, by5y_tmp, by10y_tmp))
long_be = long_ou_tmp["/2013-05-16"]
long_af = long_ou_tmp["2022-01-01/"]
long_in_tmp = readxl::read_xls(path = "f02d.xls", skip = 10)
long_in = xts::xts(long_in_tmp[,2:5], as.Date(long_in_tmp$`Series ID`))
long_in = long_in["2013-05-17/2021-12-31"]
colnames(long_in) <- colnames(long_af)
short = na.omit(merge(icr_tmp, by1m_tmp, by3m_tmp, by6m_tmp))
long = rbind(long_be, long_in, long_af)
# daily systems
forecast_day = "/2023-03-28"
variables_all = na.omit(merge(short, long))
colnames(variables_all) = c("cash rate", "1m", "3m", "6m", "2y", "3y", "5y", "10y")
variables_all = variables_all[forecast_day]
variables_long = na.omit(merge(icr_tmp, long))
colnames(variables_long) = c("cash rate", "2y", "3y", "5y", "10y")
variables_long = variables_long[forecast_day]
variables_short = short
colnames(variables_short) = c("cash rate", "1m", "3m", "6m")
variables_short = variables_short[forecast_day]
# weekly and monthly systems
vwa = xts::to.weekly(variables_all, OHLC = FALSE)
vwl = xts::to.weekly(variables_long, OHLC = FALSE)
vws = xts::to.weekly(variables_short, OHLC = FALSE)
vma = xts::to.monthly(variables_all, OHLC = FALSE)
vml = xts::to.monthly(variables_long, OHLC = FALSE)
vms = xts::to.monthly(variables_short, OHLC = FALSE)
# create a dummy for the interest raise regime
T = nrow(vma)
dm = xts::xts(as.matrix(rep(0, T)), zoo::index(vma))
dm[(T - 10):T] = 1
colnames(dm) = "dum"
dmf = as.matrix(rep(1,12))
colnames(dmf) = "dum"
Tw = nrow(vwa)
dw = xts::xts(as.matrix(rep(0, Tw)), zoo::index(vwa))
dw[(Tw - 46):Tw] = 1
colnames(dw) = "dum"
dwf = as.matrix(rep(1,55))
colnames(dwf) = "dum"
```
```{r cointegrating rank}
#| echo: false
#| eval: false
#| message: false
#| warning: false
#| results: hide
library(vars)
# Johansen's cointegrating rank test
vecm_vma = ca.jo(vma, type = "trace", ecdet = "const", K = 5, spec = "transitory")
summary(vecm_vma) # r = 5, N = 8
vecm_vms = ca.jo(vms, type = "trace", ecdet = "const", K = 5, spec = "transitory")
summary(vecm_vms) # r = 3, N = 4
vecm_vml = ca.jo(vml, type = "trace", ecdet = "const", K = 5, spec = "transitory")
summary(vecm_vml) # r = 4, N = 5
vecm_vwa = ca.jo(vwa, type = "trace", ecdet = "const", K = 5, spec = "transitory")
summary(vecm_vwa) # r = 7, N = 8
vecm_vws = ca.jo(vws, type = "trace", ecdet = "const", K = 5, spec = "transitory")
summary(vecm_vws) # r = 3, N = 4
vecm_vwl = ca.jo(vwl, type = "trace", ecdet = "const", K = 5, spec = "transitory")
summary(vecm_vwl) # r = 4, N = 5
```
```{r forecasting}
#| echo: false
#| message: false
#| warning: false
library(vars)
# forecast with monthly data
f = 1
forecasts = array(NA, c(12, 3, 18))
loglik = rep(NA, 18)
vm = list(vma, vms, vml)
rr = c(5, 3, 4)
for (v in 1:3) {
for (p in c(3, 5, 7)) {
vecm = ca.jo(vm[[v]], type = "trace", ecdet = "const", K = p, spec = "transitory", dumvar = dm)
var_cr = vec2var(vecm, r = rr[v])
var_pr = predict(var_cr, n.ahead = 12, ci = .68, dumvar = dmf)
forecasts[,,f] = var_pr$fcst$cash.rate[,1:3]
loglik[f] = sum(dnorm(var_cr$resid[,1], log = TRUE))
f = f + 1
vecm = ca.jo(vm[[v]], type = "trace", ecdet = "const", K = p, spec = "transitory")
var_cr = vec2var(vecm, r = rr[v])
var_pr = predict(var_cr, n.ahead = 12, ci = .68)
forecasts[,,f] = var_pr$fcst$cash.rate[,1:3]
loglik[f] = sum(dnorm(var_cr$resid[,1], log = TRUE))
f = f + 1
}
}
ym1 = zoo::as.yearmon("2023-04") # the first forecasted period
ym2 = zoo::as.yearmon("2024-03") # the last forecasted period
s = seq(ym1, ym2, 1/12) # create yearmon sequence
# weights are proportional to marginal likelihood for the cash rate
ll = exp(loglik - max(loglik))
weights = ll/sum(ll)
forecasts_w = forecasts
for (i in 1:18) {
forecasts_w[,,i] = weights[i] * forecasts[,,i]
}
# pooled_forecasts_m = apply(forecasts, 1:2, mean)
# colnames(pooled_forecasts_m) = c("forecast", "lower", "upper")
# pooled_forecasts_m = xts::xts(pooled_forecasts_m, s)
pooled_forecasts_m = apply(forecasts_w, 1:2, sum)
colnames(pooled_forecasts_m) = c("forecast", "lower", "upper")
pooled_forecasts_m = xts::xts(pooled_forecasts_m, s)
ym13 = zoo::as.yearmon("2023-03") # forecast origin
s3 = seq(ym13, ym2, 1/12) # create yearmon sequence
ym12 = zoo::as.yearmon("2010-1") # first data point for the plot
s2 = seq(ym12, ym2, 1/12) # create yearmon sequence
datainforecast = as.vector(vm[[1]][(dim(vm[[1]])[1] - (length(s2) - 12 - 1)):dim(vm[[1]])[1], 1])
last_point = datainforecast[length(datainforecast)]
cols = c("darkorchid4","mediumorchid1","mediumorchid2","mediumorchid3","hotpink1","hotpink2","hotpink3","hotpink4")
# forecast with weekly data
f = 1
forecastsw = array(NA, c(55, 3, 18))
loglikw = rep(NA, 18)
vw = list(vwa, vws, vwl)
rrw = c(7, 3, 4)
for (v in 1:3) {
for (p in c(3, 5, 7)) {
vecm = ca.jo(vw[[v]], type = "trace", ecdet = "const", K = p, spec = "transitory", dumvar = dw)
var_cr = vec2var(vecm, r = rrw[v])
var_pr = predict(var_cr, n.ahead = 55, ci = .68, dumvar = dwf)
forecastsw[,,f] = var_pr$fcst$cash.rate[,1:3]
loglikw[f] = sum(dnorm(var_cr$resid[,1], log = TRUE))
f = f + 1
vecm = ca.jo(vw[[v]], type = "trace", ecdet = "const", K = p, spec = "transitory")
var_cr = vec2var(vecm, r = rrw[v])
var_pr = predict(var_cr, n.ahead = 55, ci = .68)
forecastsw[,,f] = var_pr$fcst$cash.rate[,1:3]
loglikw[f] = sum(dnorm(var_cr$resid[,1], log = TRUE))
f = f + 1
}
}
sw = as.Date(rep(NA, 55))
sw[1] = as.Date("2023-04-04")
for (i in 2:55) {
sw[i] = sw[i - 1] + 7
}
# weights are proportional to marginal likelihood for the cash rate
llw = exp(loglik - max(loglik))
weightsw = llw/sum(llw)
forecastsw_w = forecastsw
for (i in 1:18) {
forecastsw_w[,,i] = weightsw[i] * forecastsw[,,i]
}
pooled_forecasts_ww = apply(forecastsw_w, 1:2, sum)
colnames(pooled_forecasts_ww) = c("forecast", "lower", "upper")
pooled_forecasts_ww = xts::xts(pooled_forecasts_ww, sw)
# pooled_forecasts_w = apply(forecastsw, 1:2, mean)
# colnames(pooled_forecasts_w) = c("forecast", "lower", "upper")
# pooled_forecasts_w = xts::xts(pooled_forecasts_w, sw)
# pooled_forecasts_wm = xts::to.monthly(pooled_forecasts_w, OHLC = FALSE)
pooled_forecasts_wm = xts::to.monthly(pooled_forecasts_ww, OHLC = FALSE)
# pool forecasts
pooled_forecasts = 0.5 * (pooled_forecasts_m + pooled_forecasts_wm)
zoo::write.zoo(pooled_forecasts, sep = ",", file = "forecasts/2023-03.csv")
```
> The end-of-March forecasting for the RBA cash rate survey by [finder.com.au](https://www.finder.com.au/rba-cash-rate) indicates probably the last (for a while) raise in the cash rate predicted for April. Afterwards, the forecasts flatten to remain at a stable level until the end of the year.
## Cash rate forecasts
The figure below presents the monthly cash rate series starting from January 2010, with the forecasts reported from April 2023 to March 2024 as the forecast mean and the 68% forecasting intervals.
```{r forecast plot}
#| echo: false
#| message: false
#| warning: false
ci1_tmp = col2rgb(cols[2])
ci2_tmp = col2rgb(cols[4])
ci1 = rgb(ci1_tmp[1], ci1_tmp[2], ci1_tmp[3], 100, maxColorValue = 255)
ci2 = rgb(ci2_tmp[1], ci2_tmp[2], ci2_tmp[3], 100, maxColorValue = 255)
plot(x = s2, y = c(datainforecast, pooled_forecasts[,1]), main = "Cash rate forecast",
type = "l", ylab = "[%]", xlab = "time",
ylim = range(pooled_forecasts, datainforecast), bty = "n",
lwd = 1, col = cols[1]
)
polygon(x = c(s3, s3[13:1]),
y = c(last_point,as.vector(pooled_forecasts[,2]), as.vector(pooled_forecasts[,3])[12:1], last_point),
col = ci1, border = ci1)
lines(x = s2, y = c(datainforecast, pooled_forecasts[,1]), lwd = 2, col = cols[1])
abline(v = ym13, col = cols[6], lty = 3)
```
The table below makes the numerical values presented in the figure more accessible.
```{r forecast table}
#| echo: false
#| message: false
#| warning: false
options(knitr.kable.NA = '')
# pooled_mq = merge(pooled_forecasts,pooled_forecasts_q)
# colnames(pooled_mq) = c("monthly", "lower", "upper", "quarterly", "lower", "upper")
# knitr::kable(as.matrix(pooled_mq), caption = "Monthly and quarterly cash rate forecasts", digits = 2)
pooled_mq = merge(pooled_forecasts)
colnames(pooled_mq) = c("monthly", "lower", "upper")
knitr::kable(as.matrix(pooled_mq), caption = "Monthly and quarterly cash rate forecasts", digits = 2)
```
## Survey answers
Based on the forecasts above, and the analysis of forecasts from individual models, I formed the following survey answers:
**When you think the RBA will change the cash rate?**
| | Apr 2023 | May 2023 | Jun 2023 | Jul 2023 | Aug 2023 | Sep 2023 | Oct 2023 | Nov 2023 | Jan 2024 or later |
|--------|--------|--------|--------|--------|--------|--------|--------|--------|--------|
| Increase | ✓ | ✓ | ✓ | | | | | | |
| Decrease | | | | | | | | | |
**Why do you think this?**
> The weighted pooled forecasts from my monthly and weekly bond yield models indicate that April is likely to be the last month with increases in interest rates. The likely values for the forecasted cash rate target in April range from 3.53 to 3.76 per cent. After this month, the predictions indicate a probable flattening of the cash rate level. The arrival of the new inflation data will be decisive regarding RBA's decisions in the longer horizon. My forecasts are available at https://donotdespair.github.io/cash-rate-survey-forecasts/
**By how much do you think the RBA will change the cash rate in the next meeting?**
> 15 pbs
**At what level do you think the cash rate will peak?**
> 3.8%
**When do you think the cash rate will peak?**
> May 2023
**When do you expect the first cash rate cut?**
> June 2024
## RBA's decision
On 4 April 2023, TBA's Board decided to **leave** the cash rate target unchanged at 3.6 per cent.
## Forecasting system
The monthly forecasts were based on the same system of variables as the one I developed for [November forecasts](2022_11.qmd). The updated data is plotted below. The novelty is that, this month, I started computing the weights assigned to individual models that are proportional to the cash rate contribution to the likelihood function. These weights replace equal weighting used thus far.
```{r data plot yields}
#| echo: false
plot(x = index(vwa), y = as.vector(vwa[,2]), main = "Australian interest rates at various maturities",
type = "l", ylab = "yield [%]", xlab = "time",
ylim = range(vwa), bty = "n",
lwd = 1, col = "mediumorchid1"
)
for (i in 3:8) lines(x = index(vwa), y = as.vector(vwa[,i]), col = cols[i])
lines(x = index(vwa), y = as.vector(vwa[,1]), col = "darkorchid4", lwd = 2)
legend("topright", legend = colnames(vwa), col = cols, lwd = c(2, rep(1, 7)), bty = "n")
```