Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I add deterministics to a model identified by Sign restrictions? #55

Open
JPablo1203 opened this issue Nov 13, 2024 · 3 comments
Assignees

Comments

@JPablo1203
Copy link

I am trying to estimate a series of models with some deterministics - i.e., constant terms, dummies for the 2008 financial crises and some time trends.

After revising the documentation I have struggled to find examples of how to include them within the bsvarSIGNs workflow. I was therefore wondering if you could maybe workout a small example with one of the accompaniying vignettes.

For instance, taking the Arias, Rubio-Ramírez, & Waggoner (2018) series, it is noticeable that productivity is increasing throughout time and that there is a big deep on stock's prices on 2008:

library(bsvars)
library(bsvarSIGNs)

# investigate the effects of the optimism shock
data(optimism)

# plot the series
plot(optimism)

optimism evolution

If I were to include a constant for each variable, a time trend and a set of dummies for the 2008 observations, how would these fit within the workflow?

Thanks in advance for your kind help and for developing such a great package.

@donotdespair
Copy link
Member

Hey @JPablo1203

Thanks so much for reaching out and your kind words about this work! We really appreciate this!

Here's a small example to illustrate the possible approach. It is based on the example available whn you xecute: ?bsvarSIGNs::estimate.BSVARSIGN. The extension includes the specification of the dymmy variable as a matrix with the number of rows the same as the input data in matrix optimism.

> library(bsvarSIGNs)
> data(optimism)
> 
> dummy = as.matrix(rep(0, nrow(optimism)))
> dummy[200:205] = 1
> 
> # specify identifying restrictions:
> # + no effect on productivity (zero restriction)
> # + positive effect on stock prices (positive sign restriction) 
> sign_irf       = matrix(c(0, 1, rep(NA, 23)), 5, 5)
> 
> # specify the model and set seed
> set.seed(123)
> specification  = specify_bsvarSIGN$new(
+   optimism * 100,
+   p        = 1,
+   sign_irf = sign_irf,
+   exogenous = dummy
+ )
> 
> # estimate the model
> posterior      = estimate(specification, S = 10)
**************************************************|
 bsvarSIGNs: Bayesian Structural VAR with sign,   |
             zero and narrative restrictions      |
**************************************************|
 Progress of simulation for 10 independent draws
 Press Esc to interrupt the computations
**************************************************|
0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
> apply(posterior$posterior$A, 1:2, mean)
             [,1]         [,2]         [,3]       [,4]          [,5]       [,6]       [,7]
[1,]  0.991759947 1.786706e-03 -0.000645267 0.04606189 -0.0003360055  2.0976934  0.3231690
[2,] -0.003529415 9.969500e-01  0.004925880 0.01382317  0.0032667429  1.7007535  2.3772056
[3,] -0.009652161 7.392993e-04  1.000541694 0.02267975  0.0006105814  2.4073697  0.2329108
[4,] -0.028298626 1.384864e-03  0.007707101 0.60096218  0.0015731459  7.9172172  0.3241072
[5,]  0.001166160 5.287929e-05 -0.001627602 0.03320721  1.0005328484 -0.3894902 -0.0712389

The constant term is always included in our models. You can create any matrix of deterministic terms with any number of columns in dummy and provide it here. The $A$ matrix includes first all the autoregressive matrices, thn the constant term, and then your provided exogenous variables. Above the posterior mean of $A$ includes a 5x5 matrix for lag 1, then the column of constant terms, and then the slope on the dummy.

The use of the exogenous variables in bsvarSIGNs is the same as in package bsvars. I have recently issued its new version that includes extensive examples with exogenous variables available by executing ?bsvars::bsvars.

Let me know if this helps!

Greetings, T

@JPablo1203
Copy link
Author

Dear Professor Wozniak,

Sorry for not responding earlier, this was extremely helpful, many thanks.

I have a few other questions regarding the package, though unrelated to this issue. Please do let me know if it would be preferrable to open a new issue with a different title.

  1. I am wondering if there are ways of speeding up the simulations by running them in parallel, I have not found any information in the documentation of the packages.
  2. When plotting the 'PosteriorIR' objects, is the package plotting the point-wise median and credible set for each horizon or is it running some other procedure to perform inference -e.g., the procedure proposed by Inoue and Kilian (2022)?

Regards,

Juan Pablo

@donotdespair
Copy link
Member

Hi Juan Pablo @JPablo1203

Please, just call me Tomasz 😄 And of course you choose how to write to us! It's perfect here! To address your qs:

  1. Nope, not ATM! But we're working on this and a nice and polished deployment of openMP (parallel computations for C++) will be available sometime in 2025. We're on the same page! Everybody is if it's about sign-restricted BSVARs 😸
  2. It's the median and the quantiles. Not the highest density intervals ATM. The conclusions of the Inoue & Kilian paper do not really apply to our package, bc we're doing Bayesian inference here and startistical statements on set identified models are legitimate.

All the best,

Tomasz @donotdespair

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants