R Package bsvarSIGNs

Di Cook Award Presentation

Xiaolei (Adam) Wang

Authors


Xiaolei (Adam) Wang

  • Economics PhD student at the University of Melbourne

Tomasz Woźniak

  • Senior Lecturer at the University of Melbourne

This package


Over 2,000 downloads!

Users from…

  • central banks of Switzerland, Italy, Canada, Basil, and Mexico

  • postgraduate students

  • anonymous internet users

State-of-the-art econometric algorithms

Blazingly fast C++ code

User-friendly summary and plot

Name?


(b)ayesian

(s)tructural

(v)ector (a)utoreg(r)essions

with (SIGN) restriction(s)

Structural?


  • VAR model: \[\begin{align*} y_t &= A_1 y_{t-1} + \ldots + A_p y_{t-p} + A_dd_t + \varepsilon_t\\ y_t &= Ax_t + \varepsilon_t \end{align*}\]

  • Structural VAR (SVAR) identifies well-isolated structural shocks: \[u_t=B\varepsilon_t,\quad \text{var}(u_t)=I\]

  • SVAR is a simultaneous equations model: \[\begin{align*} y_t &= Ax_t + B^{-1}u_t\\ By_t &= BAx_t + u_t \end{align*}\]

  • Commonly used in empirical macroeconomics

    • e.g. identify monetary policy shock, an unanticipated change in interest rate

SIGN?


  • Can’t identify \(A\) and \(B\) due to simultaneity, SIGN restriction helps!1

  • An Australian example2, consider 4 variables: cash rate, real GDP, trimmed-mean CPI, trade-weighted exchange rate

  • To identify positive monetary policy shock, may restrict \(B^{-1}\) s.t. \[\begin{align*} y_t &= \dots + B^{-1}u_t\\ \begin{bmatrix} \text{CASH}_t\\\text{GDP}_t\\\text{CPI}_t\\\text{TWI}_t \end{bmatrix} &= \dots+ \begin{bmatrix} +&*&*&*\\*&*&*&*\\-&*&*&*\\+&*&*&* \end{bmatrix} \begin{bmatrix} u_{1t}^{\text{MP}}\\u_{2t}\\u_{3t}\\u_{4t} \end{bmatrix} \end{align*}\]

  • \(B^{-1}\) are the impulse responses at horizon 0, can extend to futher horizons

Code


sign_irf <- matrix(NA, 4, 4)
sign_irf[1, 1] <- sign_irf[4, 1] <- 1
sign_irf[3, 1] <- -1
sign_irf
     [,1] [,2] [,3] [,4]
[1,]    1   NA   NA   NA
[2,]   NA   NA   NA   NA
[3,]   -1   NA   NA   NA
[4,]    1   NA   NA   NA

More SIGNs


  • The package alo supports restrictrions on \(B\) i.e. contemporaneous relations \[\begin{align*} By_t&=\dots\\ \begin{bmatrix} b_{11}&b_{12}&b_{13}&b_{14}\\ b_{21}&b_{22}&b_{23}&b_{24}\\ b_{31}&b_{32}&b_{33}&b_{34}\\ b_{41}&b_{42}&b_{43}&b_{44} \end{bmatrix} \begin{bmatrix} \text{CASH}_t \\\text{GDP}_t \\\text{CPI}_t \\\text{TWI}_t \end{bmatrix} &=\dots \end{align*}\]

  • Where the first row can be interpreted as policy reaction function \[b_{11}\text{CASH}_t=-b_{12}\text{GDP}_t-b_{13}\text{CPI}_t-b_{14}\text{TWI}_t+\dots\]

  • Economic theory says \[\begin{align*} \begin{bmatrix} +&-&-&+\\ *&*&*&*\\*&*&*&*\\*&*&*&* \end{bmatrix} \begin{bmatrix} \text{CASH}_t \\\text{GDP}_t \\\text{CPI}_t \\\text{TWI}_t \end{bmatrix} &=\dots \end{align*}\]

Code


sign_structural <- matrix(NA, 4, 4)
sign_structural[1, ] <- c(1, -1, -1, 1)
sign_structural
     [,1] [,2] [,3] [,4]
[1,]    1   -1   -1    1
[2,]   NA   NA   NA   NA
[3,]   NA   NA   NA   NA
[4,]   NA   NA   NA   NA


# specify the model
spec <- specify_bsvarSIGN$new(
  Y,
  p = 4,
  exogenous = Z,
  sign_irf = sign_irf,
  sign_structural = sign_structural
)

# sample posterior draws
post <- estimate(spec, S = 5000, show_progress = FALSE)

# compute impulse response functions
irf <- compute_impulse_responses(post, horizon = 20)

Algorithm

  • Recall, \[\varepsilon_t=B^{-1}u_t,\quad \text{var}(u_t)=I\]

  • Let \(\Sigma=\text{var}(\varepsilon_t)\) and \(Q\) be some orthogonal matrix, can decompose \[B^{-1}=\text{chol}(\Sigma)Q\]

  • Sample \(Q\) uniformly by QR decomposition of \(X\), where \(X_{ij}\overset{i.i.d}{\sim}N(0,1)\)1 \[X=QR\]

  • Until the SIGN restrictions for \(B\) and \(B^{-1}\) are satisfied

Impulse responses plot


plot(irf, probability = 0.68)

Impulse responses summary


summary(irf)$shock1$variable2
 **************************************************|
 bsvars: Bayesian Structural Vector Autoregressions|
 **************************************************|
   Posterior summary of impulse responses          |
 **************************************************|
         mean        sd 5% quantile  95% quantile
0  -0.1837484 0.1438489  -0.4295756  0.0254521230
1  -0.1919969 0.1462399  -0.4442807  0.0241581974
2  -0.2125791 0.1469114  -0.4621927  0.0112834321
3  -0.2323939 0.1460791  -0.4757095  0.0008290802
4  -0.2528213 0.1488622  -0.4977457 -0.0104613974
5  -0.2637240 0.1525702  -0.5153036 -0.0134905369
6  -0.2664673 0.1563720  -0.5256955 -0.0122216476
7  -0.2622209 0.1593557  -0.5315106 -0.0038934003
8  -0.2547855 0.1615475  -0.5298977  0.0063592121
9  -0.2457313 0.1631078  -0.5232646  0.0128340909
10 -0.2362044 0.1642777  -0.5143287  0.0254801247
11 -0.2267619 0.1652260  -0.5048653  0.0374801324
12 -0.2177028 0.1660716  -0.4972879  0.0423198619
13 -0.2091278 0.1668833  -0.4949965  0.0501458378
14 -0.2010556 0.1677055  -0.4830306  0.0564884001
15 -0.1934627 0.1685626  -0.4773320  0.0621637593
16 -0.1863216 0.1694680  -0.4703457  0.0667087572
17 -0.1796096 0.1704267  -0.4640941  0.0726520546
18 -0.1733106 0.1714390  -0.4596467  0.0781103445
19 -0.1674123 0.1725033  -0.4538969  0.0854539864
20 -0.1619036 0.1736181  -0.4535250  0.0896760294

More features

  • Hyperparameter estimation via adaptive Metropolis1

  • Zero and sign restrictions2

  • Narrative restrictions3

  • All restrictions at once4

Materials


Slides as a Website

R script for the Australian monetary policy analysis

GitHub repo to reproduce the slides and results

adamwang15[at]gmail.com

adamwang15

adamwang15

adamwang15.bsky.social