-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2023_04.qmd
468 lines (352 loc) · 18 KB
/
2023_04.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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
---
title: "April 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)
# daily systems
forecast_day = "/2023-04-26"
variables_all = na.omit(merge(icr_tmp, by1m_tmp, by3m_tmp, by6m_tmp, by2y_tmp, by3y_tmp, by5y_tmp, by10y_tmp))
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, by2y_tmp, by3y_tmp, by5y_tmp, by10y_tmp))
colnames(variables_long) = c("cash rate", "2y", "3y", "5y", "10y")
variables_long = variables_long[forecast_day]
variables_short = na.omit(merge(icr_tmp, by1m_tmp, by3m_tmp, by6m_tmp))
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(vms)
dm = xts::xts(as.matrix(rep(0, T)), zoo::index(vms))
dm[(T - 12):T] = 1
colnames(dm) = "dum"
dmf = as.matrix(rep(1,12))
colnames(dmf) = "dum"
Tw = nrow(vws)
dw = xts::xts(as.matrix(rep(0, Tw)), zoo::index(vws))
dw[(Tw - 52):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)
forecasts = array(NA, c(12, 3, 16))
loglik = rep(NA, 16)
vm = list(vma, vms, vml)
rr = c(4, 3, 3)
# for (v in 1:3) {
for (v in 2) {
for (p in c(3, 5, 7, 9, 11, 13, 15, 17)) {
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-05") # the first forecasted period
ym2 = zoo::as.yearmon("2024-04") # 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) {
for (i in 1:16) {
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-04") # 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[[2]][(dim(vm[[2]])[1] - (length(s2) - 12 - 1)):dim(vm[[2]])[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)
forecastsw = array(NA, c(55, 3, 16))
loglikw = rep(NA, 16)
vw = list(vwa, vws, vwl)
rrw = c(7, 3, 4)
# for (v in 1:3) {
for (v in 2) {
for (p in c(3, 5, 7, 9, 11, 13, 15, 17)) {
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-05-01")
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) {
for (i in 1:16) {
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-04.csv")
```
```{r rates data}
#| echo: false
#| message: false
#| warning: false
# download the 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)
icr = xts::to.quarterly(icr_tmp, OHLC = FALSE)
icr = icr[-nrow(icr),]
by10y_dwnld = readrba::read_rba(series_id = "FCMYGBAG10D") # 10-year bonds
by10y_tmp = xts::xts(by10y_dwnld$value, by10y_dwnld$date)
by10y = xts::to.quarterly(by10y_tmp, OHLC = FALSE)
by10y = by10y[-nrow(by10y),]
# "GMAREXPY" # Survey measure of market economists' inflation expectations; Median inflation for 1 year ahead; Year-ended
piexpe1y_dwnld = readrba::read_rba(series_id = "GMAREXPY")
piexpe1y_tmp = xts::xts(piexpe1y_dwnld$value, piexpe1y_dwnld$date, tclass = 'yearqtr')
piexpe1y = xts::to.quarterly(piexpe1y_tmp, OHLC = FALSE)
# "GUNIEXPY" # Survey measure of union officials' inflation expectations; Median inflation for 1 year ahead; Year-ended
piexpu1y_dwnld = readrba::read_rba(series_id = "GUNIEXPY")
piexpu1y_tmp = xts::xts(piexpu1y_dwnld$value, piexpu1y_dwnld$date, tclass = 'yearqtr')
piexpu1y = xts::to.quarterly(piexpu1y_tmp, OHLC = FALSE)
# "GCPIAGSAQP" # Consumer price index; All groups; Quarterly change (in per cent)
picpi_dwnld = readrba::read_rba(series_id = "GCPIAGSAQP")
picpi_tmp = 4 * xts::xts(c(picpi_dwnld$value, 7.1/4), c(picpi_dwnld$date,"2023-03-31"), tclass = 'yearqtr')
picpi = xts::to.quarterly(picpi_tmp, OHLC = FALSE)
# "GLFSURSA" # Unemployed persons as percentage of labour force
ur_dwnld = readrba::read_rba(series_id = "GLFSURSA")
ur_tmp = xts::xts(ur_dwnld$value, ur_dwnld$date)
ur = xts::to.quarterly(ur_tmp, OHLC = FALSE)
# "GLFSEPTPOP" # Employed persons as percentage of working age civilian population
er_dwnld = readrba::read_rba(series_id = "GLFSEPTPOP")
er_tmp = xts::xts(er_dwnld$value, er_dwnld$date)
er = xts::to.quarterly(er_tmp, OHLC = FALSE)
with_exp = na.omit(merge(icr, by10y, piexpe1y, piexpu1y, picpi, ur, er))
colnames(with_exp) = c("cash rate", "10yb", "Epi_eco", "Epi_uni", "pi", "ur", "er")
with_exp = with_exp["2002-01/2023-03"]
no_exp = na.omit(merge(icr, by10y, picpi, ur, er))
colnames(no_exp) = c("cash rate", "10yb", "pi", "ur", "er")
no_exp = no_exp["/2023-03"]
```
```{r forecasting quarterly}
#| echo: false
#| eval: false
#| message: false
#| warning: false
#| results: hide
# Johansen's test
library(vars)
vecm_we = ca.jo(with_exp, type = "trace", ecdet = "none", K = 3, spec = "transitory")
summary(vecm_we) # r = 2, N = 7
vecm_noe = ca.jo(no_exp, type = "trace", ecdet = "none", K = 3, spec = "transitory")
summary(vecm_noe) # r = 2, N = 5
# forecast with quarterly data
f = 1
forecasts = array(NA, c(4, 3, 2))
vmq = list(with_exp, no_exp)
for (v in 1:2) {
vecm = ca.jo(vmq[[v]], type = "trace", ecdet = "none", K = 3, spec = "transitory")
var_cr = vec2var(vecm, r = 2)
var_pr = predict(var_cr, n.ahead = 4, ci = .68)
forecasts[,,f] = var_pr$fcst$cash.rate[,1:3]
f = f + 1
}
ym1q = zoo::as.yearqtr("2023-02") # the first forecasted period
ym2q = zoo::as.yearqtr("2024-01") # the last forecasted period
sq = seq(ym1, ym2, 1/4) # create yearqtr sequence
pooled_forecasts_q = apply(forecasts, 1:2, mean)
colnames(pooled_forecasts_q) = c("forecast", "lower", "upper")
pooled_forecasts_q = xts::xts(pooled_forecasts_q, sq + 1/12)
ym13q = zoo::as.yearqtr("2023-01") # forecast origin
s3q = seq(ym13q, ym2q, 1/4) # create yearmon sequence
ym12q = zoo::as.yearqtr("2010-01")
s2q = seq(ym12q, ym2q, 1/4) # create yearmon sequence
datainforecastq = as.vector(vmq[[1]][(dim(vmq[[1]])[1] - (length(s2q) - 4 - 1)):dim(vmq[[1]])[1], 1])
last_pointq = datainforecastq[length(datainforecastq)]
cols = c("darkorchid4","mediumorchid1","mediumorchid2","mediumorchid3","hotpink1","hotpink2","hotpink3","hotpink4")
zoo::write.zoo(pooled_forecasts_q, sep = ",", file = "forecasts/2023-04-quarterly.csv")
```
> The end-of-April forecasting for the RBA cash rate survey by [finder.com.au](https://www.finder.com.au/rba-cash-rate) follows the anouncement of inflation for the first quarter of 2023 at the level of 7%. It fell, but remains high. The new data leads to forecasts indicating a slight increase in the cash rate for May. In the longer horizon, the bond yield curve modelling indicates stabilisation or further increases of cash rate while a system focusing on inflation and its expectations show its decline.
## Cash rate forecasts
The figure below presents the monthly cash rate series starting from January 2010, with the forecasts reported from May 2023 to April 2024 as the forecast mean and the 68% forecasting intervals.
```{r forecast plot}
#| echo: 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)
# polygon(x = c(s3q + .25, s3q[5:1] + .25),
# y = c(last_pointq,as.vector(pooled_forecasts_q[,2]), as.vector(pooled_forecasts_q[,3])[4:1], last_pointq),
# col = ci2, border = ci2)
lines(x = s2, y = c(datainforecast, pooled_forecasts[,1]), lwd = 2, col = cols[1])
# lines(x = s3q + .25, y = c(last_pointq, pooled_forecasts_q[,1]), lwd = 2, col = cols[4])
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
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?**
| | May 2023 | Jun 2023 | Jul 2023 | Aug 2023 | Sep 2023 | Oct 2023 | Nov 2023 | Dec 2023 | Jan 2024 or later |
|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|
| Increase | ✓ | ✓ | | | | | | | |
| Decrease | | | | | | | | | |
**Why do you think this?**
> The new reading of the CPI inflation reaching 7% in the first quarter of 2023 aligns the quarterly forecasts with the monthly indicating the cash rate at 3.77% within the next 3-5 months. The prediction bands around this value reach from 3.4 to 4.1 %. My interpretation is a likely raise by 15 pp this or next month. Beyond this horizon, the forecasts diverge with the bond yield curve modelling indicating further increases and the system focusing on inflation, labour market and expectations showing cuts. The arrival of new macro data occurs essential in such dynamically changing circumstances./
**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?**
> June 2023
**Where do you think the cash rate will be at the end of 2023?**
> 3.8%
## RBA's decision
On 2 May 2023, the RBA announced an **increase** in the cash rate target by **25** basis points.
## Forecasting system
<!-- My quarterly forecasts are based on the same system that presented in [January forecasts](2023_01.qmd). The quarterly data spanning the period starting in the second quarter of 2002 and finishing in the first one of 2023 is plotted below. -->
```{r data plot rates}
#| echo: false
#| eval: false
plot(x = index(with_exp), y = as.vector(with_exp[,1]), main = "Quarterly data",
type = "l", ylab = "[%]", xlab = "time",
ylim = range(with_exp[,1:6], with_exp[,7]-60), bty = "n",
lwd = 2, col = "darkorchid4"
)
for (i in 2:6) lines(x = index(with_exp), y = as.vector(with_exp[,i]), col = cols[i])
lines(x = index(with_exp), y = as.vector(with_exp[,7]) - 60, col = cols[7], lwd = 2)
lines(x = index(with_exp), y = as.vector(with_exp[,1]), col = "darkorchid4", lwd = 2)
axis(2, lwd = 2, col = "darkorchid4")
axis(4, c(-1, 2, 5), c(59, NA, 65), lwd = 2, col = cols[7])
var_names = c("cash rate", "10y bond yield", "inflation expectation eco", "inflation expectation union", "inflation", "unemployment", "employment")
legend("bottomleft", legend = var_names, col = cols[1:7], lwd = c(2, rep(1, 5), 2), bty = "n")
```
My monthly forecasts were based a similar forecasting system as the one I developed for [March forecasts](2023_03.qmd). However, due to [unavailability of long-term interest rates via package](https://github.com/MattCowgill/readrba/issues/43) **readrba** I only used cash rate and government bond yields at maturity 30, 90, and 180 days. The data is plotted below.
```{r data plot yields}
#| echo: false
plot(x = index(vms), y = as.vector(vms[,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:ncol(vms)) lines(x = index(vms), y = as.vector(vms[,i]), col = cols[i])
lines(x = index(vms), y = as.vector(vms[,1]), col = "darkorchid4", lwd = 2)
legend("topright", legend = colnames(vms), col = cols, lwd = c(2, rep(1, 7)), bty = "n")
```