From c87b42ee41a1fbbc01ce4d6df181ddd2bd11a33a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Wo=C5=BAniak?= Date: Sun, 12 May 2024 13:26:30 +1000 Subject: [PATCH] corrected sampler for nu #2 --- R/specify_bvarpanel.R | 4 ++-- src/sample_mniw.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/R/specify_bvarpanel.R b/R/specify_bvarpanel.R index 30b0f8d..a9d1a02 100644 --- a/R/specify_bvarpanel.R +++ b/R/specify_bvarpanel.R @@ -94,7 +94,7 @@ specify_prior_bvarPANEL = R6::R6Class( self$S_Sigma_inv = diag(N) self$eta = N + 1 self$mu_Sigma = N + 1 - self$lambda = 0.1 + self$lambda = 0.01385 self$mu_m = 1 self$sigma2_m = 1 self$s_w = 1 @@ -210,7 +210,7 @@ specify_starting_values_bvarPANEL = R6::R6Class( self$A = matrix(stats::rnorm(K * N, sd = 0.001), K, N) + diag(K)[,1:N] self$V = stats::rWishart(1, K + 1, diag(K))[,,1] self$Sigma = stats::rWishart(1, N + 1, diag(N))[,,1] - self$nu = stats::rgamma(1, 3) + self$nu = 30 #stats::rgamma(1, shape = 1, scale = 30) self$m = stats::rnorm(1, sd = 0.001) self$w = stats::rgamma(1, 1) self$s = stats::rgamma(1, 1) diff --git a/src/sample_mniw.cpp b/src/sample_mniw.cpp index ff29ca6..a22d73d 100644 --- a/src/sample_mniw.cpp +++ b/src/sample_mniw.cpp @@ -169,6 +169,7 @@ double sample_nu ( Cov_nu_tmp += R::psigamma( 0.5 * (aux_nu + 1 - n), 1); } // END n loop Cov_nu += 1 / Cov_nu_tmp; + Cov_nu = sqrt(Cov_nu); // Metropolis-Hastings double aux_nu_star = RcppTN::rtn1( aux_nu, Cov_nu, N + 1, R_PosInf );