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

Difficulty drawing valid Q matrix #5

Closed
adamwang15 opened this issue Jan 26, 2024 · 2 comments
Closed

Difficulty drawing valid Q matrix #5

adamwang15 opened this issue Jan 26, 2024 · 2 comments

Comments

@adamwang15
Copy link
Collaborator

We have a minimum working example of sign restrictions on impulse response functions, but it is very difficult to have valid draws of Q, which is strange since only horizon 0 is considered.

set.seed(123)
data(oil)

sign_irf <-
  array(matrix(c(-1, -1, 1, 1, 1, 1, 1, -1, 1), nrow = 3), dim = c(3, 3, 1))
specification <-
  specify_bsvarSIGN$new(oil, p = 12, sign_irf = sign_irf)

burn_in <- estimate.BSVARSIGN(specification, 101, thin = 100)
posterior <- estimate.PosteriorBSVARSIGN(burn_in, 10, thin = 1)

# test
posterior$posterior$B # only one draw is valid
posterior$posterior$B[, , 1] |> solve()

#             [,1]      [,2]       [,3]
# [1,] -0.99836620 0.8753184  0.4946759
# [2,] -0.05624569 3.6964931 -6.0691198
# [3,]  4.72269479 4.7975231  1.4027944
@adamwang15
Copy link
Collaborator Author

Splitting a long loop into several functions and avoiding break/continue solved the problem. Lesson learned: good coding practice is important!

@donotdespair
Copy link
Member

Oh! That's fantastic! Thanks for the update!

@adamwang15 adamwang15 added this to the bsvarSIGNs v1.0.0 milestone Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants