Skip to content

Commit b590f2b

Browse files
committed
sampling tauSq before sampling gammas
1 parent ce00a4b commit b590f2b

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

R/GPTCM.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#' common (\code{dirichlet = TRUE}) or alternative (\code{dirichlet = FALSE})
2727
#' parametrization of the Dirichlet regression model
2828
#' @param hyperpar a list of relevant hyperparameters
29-
#' @param BVS logical value for implementing Bayesian variable selection//'
29+
#' @param BVS logical value for implementing Bayesian variable selection
3030
#' @param threads maximum threads used for parallelization. Default is 1
3131
#' @param kappaIGamma logical value for using inverse-gamma prior (\code{TRUE})
3232
#' or gamma prior (\code{FALSE}) for Weibull's shape parameter

src/arms_gibbs.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ void ARMS_Gibbs::arms_gibbs_beta(
240240
// mydata->xr = xr;
241241
// mydata->vA = vA;
242242
// mydata->vB = vB;
243-
// mydata->tauSq = tauSq;
243+
mydata->tau0Sq = tau0Sq;
244244
mydata->kappa = kappa;
245245
mydata->datTheta = datTheta.memptr();
246246
mydata->datMu = datMu.memptr();
@@ -257,10 +257,7 @@ void ARMS_Gibbs::arms_gibbs_beta(
257257
// Gibbs sampling
258258
// mydata->tauSq = sampleW(tauA, tauB, currentPars.col(l));
259259
// mydata->tau0Sq = sampleW0(tauA, tauB, currentPars(0,l));
260-
261-
tau0Sq = sampleV(tau0A, tau0B, currentPars.row(0).t());
262-
mydata->tau0Sq = tau0Sq;
263-
tauSq[l] = sampleV(tauA, tauB, currentPars.submat(1,l,p,l));
260+
264261
mydata->tauSq = tauSq[l];
265262
// tauSq_tmp[l] = sampleW(tauA, tauB, currentPars.col(l));
266263
// mydata->tauSq = tauSq_tmp[l];
@@ -556,7 +553,7 @@ void ARMS_Gibbs::arms_gibbs_zeta(
556553
mydata->p = p;
557554
mydata->L = L;
558555
mydata->N = N;
559-
// mydata->w0Sq = w0Sq;
556+
mydata->w0Sq = w0Sq;
560557
// mydata->wSq = wSq;
561558
//mydata->phi = phi;
562559
//mydata->dirichlet = dirichlet,
@@ -576,9 +573,6 @@ void ARMS_Gibbs::arms_gibbs_zeta(
576573
{
577574
// Gibbs sampling
578575
// mydata->w0Sq = sampleW0(w0A, w0B, currentPars(0,l));
579-
w0Sq = sampleV(w0A, w0B, currentPars.row(0).t());
580-
mydata->w0Sq = w0Sq;
581-
wSq[l] = sampleV(wA, wB, currentPars.submat(1,l,p,l));
582576
mydata->wSq = wSq[l];
583577
// wSq_tmp[l] = sampleW(wA, wB, currentPars.submat(1,l,p,l));
584578
// mydata->wSq = wSq_tmp[l];

src/drive.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,16 @@ Rcpp::List run_mcmc(
481481
std::string(cTotalLength * (1. - (m + 1.) / nIter), '-') << // printing empty part
482482
"] " << (int)((m + 1.) / nIter * 100.0) << "%\r"; // printing percentage
483483

484+
485+
// update \beta's and \zeta's variacnes tau0Sq, tauSq, w0Sq, wSq
486+
tau0Sq = sampleV(hyperpar->tau0A, hyperpar->tau0B, betas.row(0).t());
487+
w0Sq = sampleV(hyperpar->w0A, hyperpar->w0B, zetas.row(0).t());
488+
for (unsigned int l=0; l<L; ++l)
489+
{
490+
tauSq[l] = sampleV(hyperpar->tauA, hyperpar->tauB, betas.submat(1,l,p,l));
491+
wSq[l] = sampleV(hyperpar->wA, hyperpar->wB, zetas.submat(1,l,p,l));
492+
}
493+
484494
// update \xi's variance vSq
485495
v0Sq = sampleV0(hyperpar->v0A, hyperpar->v0B, xi[0]);
486496
// hyperpar->v0Sq = v0Sq;

0 commit comments

Comments
 (0)