nk027 / bvar

Toolkit for the estimation of hierarchical Bayesian vector autoregressions. Implements hierarchical prior selection for conjugate priors in the fashion of Giannone, Lenza & Primiceri (2015). Allows for the computation of impulse responses and forecasts and provides functionality for assessing results.
https://cran.r-project.org/package=BVAR
Other
50 stars 21 forks source link

Problems with sign and zero restriction #66

Closed AmAzing97 closed 3 years ago

AmAzing97 commented 3 years ago

Hello,

I am trying to run data sign and zero restrictions for Croatia and the European union spanning from 2000Q2 to 2020Q1, using GDP and HICP of Croatia and GDP and HICP of EU, so there are 4 variables in the model. Data are logged and differenced.

When I try to make IRF with the sign and zero restrictions I get this error.

Error in sign_restr(sigma_chol = sigma_chol, sign_restr = sign_restr, : No matrix fitting the sign restrictions found.

This is my code:

hrv <- openxlsx::read.xlsx("C:/Users/User/OneDrive/Radna površina/data.xlsx", sheet = "hr") hrv <- select(hrv, -X1)

CRO <- bvar(hrv, lags = 1, n_draw = 1000L, n_burn = 200L, verbose = FALSE)

irf(CRO) <- irf(CRO, identification = TRUE) irf(CRO, conf_bands = c(0.01, 0.05, 0.1)) irf(CRO) <- irf(CRO, bv_irf(horizon = 24L, identification = FALSE), n_thin = 10L) plot(irf(CRO))

sign_restr <- matrix(c(1, 1, 0, 0, 1, -1, 0, 0, 1, 1, NA, NA, 1, -1, NA, NA), nrow = 4) opt_signs <- bv_irf(horizon = 20, fevd = TRUE, identification = TRUE, sign_restr = sign_restr, sign_lim = 10000) irf(CRO) <- irf(CRO, opt_signs)

data.xlsx

Also, is there a possibility to impose long sign and zero restrictions, along with creating historical variance decomposition, and to choose another prior, for example, Independent Normal inverse Wishart prior?

Thank you in forward.

nk027 commented 3 years ago

Hey,

This is less of a software error than a theoretical one -- the algorithm cannot find a shock that suits your sign restrictions. There is a small chance that you can counteract this by increasing the number of draws in bvar() (which I would recommend in general), but you may need to reconsider whether the exact restrictions make sense (e.g. the shock of the HICP on itself should maybe be positive). At the moment other identification algorithms have to be added manually, although that is a pending feature (see #62). The same goes for the historical decomposition -- you can obtain the necessary quantities, but there is currently no specific method (see #61). If you delve into that we'd be happy to adapt your code or merge it straight into the package. Regarding priors you can add dummy observation priors from the NIW family.

Best,