Skip to content

Commit

Permalink
correct rho sampling for sv model closes #19
Browse files Browse the repository at this point in the history
  • Loading branch information
donotdespair committed Oct 6, 2022
1 parent 75768ef commit 47458ae
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/sv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ List svar_nc1 (
double aux_rho_var = as_scalar(pow(hm1*hm1.t(), -1));
double aux_rho_mean = as_scalar(aux_rho_var * hm1*aux_h_n.cols(1,T-1).t());
double upper_bound = pow(1-aux_sigma2_omega_n, 0.5);
aux_rho_n = RcppTN::rtn1(aux_rho_mean, pow(aux_rho_var, -0.5),-upper_bound,upper_bound);
aux_rho_n = RcppTN::rtn1(aux_rho_mean, pow(aux_rho_var, 0.5),-upper_bound,upper_bound);

mat H_rho_new(T, T, fill::eye);
H_rho_new.diag(-1) -= aux_rho_n;
Expand All @@ -235,6 +235,13 @@ List svar_nc1 (
aux_omega_n = ss * sqrt(sigma2_aux);
aux_h_n = aux_h_tilde / aux_omega_n;

// ASIS: resample aux_rho
hm1 = aux_h_n.cols(0,T-2);
aux_rho_var = as_scalar(pow(hm1*hm1.t(), -1));
aux_rho_mean = as_scalar(aux_rho_var * hm1*aux_h_n.cols(1,T-1).t());
upper_bound = pow(1-aux_sigma2_omega_n, 0.5);
aux_rho_n = RcppTN::rtn1(aux_rho_mean, pow(aux_rho_var, 0.5),-upper_bound,upper_bound);

return List::create(
_["aux_h_n"] = aux_h_n,
_["aux_rho_n"] = aux_rho_n,
Expand Down

0 comments on commit 47458ae

Please sign in to comment.