From cc608dc7c0980434ed5d8d37fcebd385932a17df Mon Sep 17 00:00:00 2001 From: adamwang15 Date: Tue, 16 Jul 2024 17:37:52 +1000 Subject: [PATCH] change example --- R/bsvarSIGNs-package.R | 24 ++++++++---------------- man/bsvarSIGNs-package.Rd | 24 ++++++++---------------- src/sample_hyper.cpp | 1 - 3 files changed, 16 insertions(+), 33 deletions(-) diff --git a/R/bsvarSIGNs-package.R b/R/bsvarSIGNs-package.R index 4187203..375ae82 100644 --- a/R/bsvarSIGNs-package.R +++ b/R/bsvarSIGNs-package.R @@ -24,20 +24,12 @@ #' #' Antolín-Díaz & Rubio-Ramírez (2018) Narrative Sign Restrictions for SVARs, American Economic Review, 108(10), 2802-29, . #' @examples -#' # upload data -#' data(oil) -#' -#' # restrictions as in Antolín-Díaz & Rubio-Ramírez (2018) -#' sign_narrative = matrix(c(2, -1, 3, 2, 236, 0), ncol = 6) -#' sign_irf = array(matrix(c(-1, -1, 1, 1, 1, 1, 1, -1, 1), nrow = 3), -#' dim = c(3, 3, 1)) -#' -#' # specify the model and set seed -#' set.seed(123) -#' specification = specify_bsvarSIGN$new(oil, -#' p = 12, -#' sign_irf = sign_irf, -#' sign_narrative = sign_narrative -#' ) -#' posterior = estimate(specification, S = 10) +#' sign_irf = matrix(NA, 5, 5) +#' sign_irf[2, 1] = 1 +#' sign_irf[1, 1] = 0 +#' spec = specify_bsvarSIGN$new(optimism * 100, +#' p = 4, +#' sign_irf = sign_irf) +#' spec$prior$estimate_hyper() +#' post = estimate(spec, S = 1000) NULL diff --git a/man/bsvarSIGNs-package.Rd b/man/bsvarSIGNs-package.Rd index 97d1315..22730b3 100644 --- a/man/bsvarSIGNs-package.Rd +++ b/man/bsvarSIGNs-package.Rd @@ -17,22 +17,14 @@ This package is currently in active development. We give no warranty that anything here works. } \examples{ -# upload data -data(oil) - -# restrictions as in Antolín-Díaz & Rubio-Ramírez (2018) -sign_narrative = matrix(c(2, -1, 3, 2, 236, 0), ncol = 6) -sign_irf = array(matrix(c(-1, -1, 1, 1, 1, 1, 1, -1, 1), nrow = 3), - dim = c(3, 3, 1)) - -# specify the model and set seed -set.seed(123) -specification = specify_bsvarSIGN$new(oil, - p = 12, - sign_irf = sign_irf, - sign_narrative = sign_narrative - ) -posterior = estimate(specification, S = 10) +sign_irf = matrix(NA, 5, 5) +sign_irf[2, 1] = 1 +sign_irf[1, 1] = 0 +spec = specify_bsvarSIGN$new(optimism * 100, + p = 4, + sign_irf = sign_irf) +spec$prior$estimate_hyper() +post = estimate(spec, S = 1000) } \references{ Rubio-Ramírez, Waggoner & Zha (2010) Structural Vector Autoregressions: Theory of Identification and Algorithms for Inference, The Review of Economic Studies, 77(2), 665-696, . diff --git a/src/sample_hyper.cpp b/src/sample_hyper.cpp index 70a0889..517f75f 100644 --- a/src/sample_hyper.cpp +++ b/src/sample_hyper.cpp @@ -280,7 +280,6 @@ arma::mat sample_hyper( S, start, narrow_hyper(model, init), W, [init, model, Y, X, prior](const vec& x) { - vec extended = extend_hyper(init, model, x); return log_posterior_hyper(extended, model, Y, X, prior); }