Skip to content

Commit

Permalink
fix dumb bug #30
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwang15 committed Jul 15, 2024
1 parent e0fb108 commit 690e657
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
5 changes: 0 additions & 5 deletions src/bsvars_sign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,9 @@ Rcpp::List bsvar_sign_cpp(
psi = hyper.rows(3, N + 2);

// update Minnesota prior
prior_v.rows(0, N * p - 1) = lambda * lambda *
prior_v.rows(0, N * p - 1) %
repmat(1 / psi, p, 1);

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

// update dummy observation prior
Expand Down
7 changes: 4 additions & 3 deletions src/sample_NIW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,15 @@ arma::field<arma::mat> niw_cpp(
mat post_B = post_V * (X.t() * Y + prior_V_inv * prior_B);

// marginal posterior of Sigma
mat post_S = prior_S + Y.t() * Y + prior_B.t() * prior_V_inv * prior_B - post_B.t() * post_V_inv * post_B;
post_S = symmatu(post_S);
mat post_S = prior_S + Y.t() * Y +
prior_B.t() * prior_V_inv * prior_B -
post_B.t() * post_V_inv * post_B;
int post_nu = prior_nu + T;

field<mat> post(4);
post(0) = post_B;
post(1) = post_V;
post(2) = post_S;
post(2) = symmatu(post_S);
post(3) = mat(1, 1, fill::ones) * post_nu;

return post;
Expand Down

0 comments on commit 690e657

Please sign in to comment.