Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwang15 committed Jul 17, 2024
1 parent 2a9f14b commit b2f49df
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
58 changes: 29 additions & 29 deletions src/bsvars_sign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ Rcpp::List bsvar_sign_cpp(
vec prog_rep_points = arma::round(arma::linspace(0, S / num_threads, 50));
if (show_progress) {
Rcout << "**************************************************|" << endl;
Rcout << " bsvarSIGNs: Bayesian Structural VAR with zero, |" << endl;
Rcout << " sign and narrative restrictions |" << endl;
Rcout << " bsvarSIGNs: Bayesian Structural VAR with sign, |" << endl;
Rcout << " zero and narrative restrictions |" << endl;
Rcout << "**************************************************|" << endl;
// Rcout << " Gibbs sampler for the SVAR model |" << endl;
// Rcout << "**************************************************|" << endl;
Expand Down Expand Up @@ -96,32 +96,35 @@ Rcpp::List bsvar_sign_cpp(
// #pragma omp parallel for private(hyper, mu, delta, lambda, psi, prior_V, prior_S, Ystar, Xstar, Yplus, Xplus, result, post_B, post_V, post_S, Sigma, chol_Sigma, B, h_invp, Q, shocks, w)
for (int s = 0; s < S; s++) {

w = 0;
hyper = hypers.col(randi(distr_param(0, S_hyper)));
mu = hyper(0);
delta = hyper(1);
lambda = hyper(2);
psi = hyper.rows(3, N + 2);

// update Minnesota prior
prior_V = diagmat(prior_v % join_vert(lambda * lambda * repmat(1 / psi, p, 1),
ones<vec>(K - N * p)));
prior_S = diagmat(psi);

// update dummy observation prior
Ystar = join_vert(Ysoc / mu, Ysur / delta);
Xstar = join_vert(Xsoc / mu, Xsur / delta);
Yplus = join_vert(Ystar, Y);
Xplus = join_vert(Xstar, X);

// posterior parameters
result = niw_cpp(Yplus, Xplus, prior_B, prior_V, prior_S, prior_nu);
post_B = result(0);
post_V = result(1);
post_S = result(2);
post_nu = as_scalar(result(3));

w = 0;

while (w == 0) {
hyper = hypers.col(randi(distr_param(0, S_hyper)));
mu = hyper(0);
delta = hyper(1);
lambda = hyper(2);
psi = hyper.rows(3, N + 2);

// update Minnesota prior
prior_V = diagmat(prior_v %
join_vert(lambda * lambda * repmat(1 / psi, p, 1),
ones<vec>(K - N * p)));
prior_S = diagmat(psi);

// update dummy observation prior
Ystar = join_vert(Ysoc / mu, Ysur / delta);
Xstar = join_vert(Xsoc / mu, Xsur / delta);
Yplus = join_vert(Ystar, Y);
Xplus = join_vert(Xstar, X);

// posterior parameters
result = niw_cpp(Yplus, Xplus, prior_B, prior_V, prior_S, prior_nu);
post_B = result(0);
post_V = result(1);
post_S = result(2);
post_nu = as_scalar(result(3));
checkUserInterrupt();

// sample reduced-form parameters
Sigma = iwishrnd(post_S, post_nu);
Expand All @@ -145,9 +148,6 @@ Rcpp::List bsvar_sign_cpp(
posterior_Theta0.slice(s) = chol_Sigma * Q;
posterior_shocks.slice(s) = shocks;

// Check for user interrupts
if (s % 1 == 0) checkUserInterrupt();

// Increment progress bar
if (any(prog_rep_points == s)) bar.increment();

Expand Down
2 changes: 1 addition & 1 deletion src/restrictions_narrative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ double weight_narrative(

const int M = 1e+3; // number of draws to approximate normal distribution

double n_success = 1.0e-6;
double n_success = 1e-6;

cube Z(irf.n_rows, sign_narrative.col(5).max() + 1, M, fill::randn);
// cube Z(irf.n_rows, T, M, fill::randn);
Expand Down

0 comments on commit b2f49df

Please sign in to comment.