Skip to content

Commit 78f5ffe

Browse files
committed
sampling pi by rows
1 parent b590f2b commit 78f5ffe

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

NEWS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
* Update `simData()` by changing xi0 to simulate survival data with censoring rate 0.2
1111
* Remove `arms_simple`
1212
* Use `openmp` to parallelize some for-loop
13-
* TODO: remove ´arms.metropolis=false´
13+
1414
* TODO: decide whether keep `kappaIGamma=TRUE` or not
15-
* TODO: move 'sampleTau()' or similar out of 'arms_gibbs_*()', since ARMS MH sampling should use fixed variances for original and proposed parameters, similar for sampleW()
15+
* TODO: remove redundant arguments "tauSq" and "wSq" after bringing them out of ARMS files
1616
* TODO: bug for posterior pi_{jl}
1717

1818
## GPTCM 1.1.2 (2025-09-26)

man/GPTCM.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/BVS.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,15 @@ void BVS_Sampler::sampleGamma(
263263
if(pi0 == 0.) // this is to control if using pre-defined constant pi0 or hyperprior
264264
{
265265
//// feature-specific Bernoulli probability
266-
pi = R::rbeta(hyperpar->piA + (double)(proposedGamma(i,componentUpdateIdx)),
267-
hyperpar->piB + (double)(p) - (double)(proposedGamma(i,componentUpdateIdx)));
266+
// pi = R::rbeta(hyperpar->piA + (double)(proposedGamma(i,componentUpdateIdx)),
267+
// hyperpar->piB + 1.0 - (double)(proposedGamma(i,componentUpdateIdx)));
268268
//// column-specific Bernoulli probability
269269
// pi = R::rbeta(hyperpar->piA + (double)(arma::sum(proposedGamma.col(componentUpdateIdx))),
270270
// hyperpar->piB + (double)(p) - (double)(arma::sum(proposedGamma.col(componentUpdateIdx))));
271+
//// row-specific Bernoulli probability
272+
double pi = R::rbeta(hyperpar->piA + (double)(arma::accu(gammas_.row(i))),
273+
hyperpar->piB + (double)(L) - (double)(arma::accu(gammas_.row(i))));
271274
}
272-
//// row-specific Bernoulli probability
273-
// double pi = R::rbeta(hyperpar->piA + (double)(arma::accu(proposedGamma.row(i))),
274-
// hyperpar->piB + (double)(L) - (double)(arma::accu(proposedGamma.row(i))));
275275
// logProposalGammaRatio += logPDFBernoulli( proposedGamma(i,componentUpdateIdx), pi_proposed ) - logPDFBernoulli( gammas_(i,componentUpdateIdx), pi[componentUpdateIdx] );
276276
proposedGammaPrior(i,componentUpdateIdx) = logPDFBernoulli( proposedGamma(i,componentUpdateIdx), pi );
277277
logProposalGammaRatio += proposedGammaPrior(i, componentUpdateIdx) - logP_gamma_(i, componentUpdateIdx);
@@ -692,11 +692,14 @@ void BVS_Sampler::sampleEta(
692692
if(rho0 == 0.)
693693
{
694694
//// feature-specific Bernoulli probablity
695-
rho = R::rbeta(hyperpar->rhoA + (double)(proposedEta(i,componentUpdateIdx)),
696-
hyperpar->rhoB + (double)(p) - (double)(proposedEta(i,componentUpdateIdx)));
695+
// rho = R::rbeta(hyperpar->rhoA + (double)(proposedEta(i,componentUpdateIdx)),
696+
// hyperpar->rhoB + 1.0 - (double)(proposedEta(i,componentUpdateIdx)));
697697
//// column-specific Bernoulli probability
698698
// rho = R::rbeta(hyperpar->rhoA + (double)(arma::sum(proposedEta.col(componentUpdateIdx))),
699699
// hyperpar->rhoB + (double)(p) - (double)(arma::sum(proposedEta.col(componentUpdateIdx))));
700+
//// row-specific Bernoulli probablity
701+
rho = R::rbeta(hyperpar->rhoA + (double)(arma::accu(etas_.row(i))),
702+
hyperpar->rhoB + (double)(L) - (double)(arma::accu(etas_.row(i))));
700703
}
701704
//// the following random-walk MH sampler result in increasing rho
702705
// double proposedRho = std::exp( std::log( rho(i, componentUpdateIdx) ) + R::rnorm(0.0, 1.0) );
@@ -718,9 +721,6 @@ void BVS_Sampler::sampleEta(
718721
// logP_eta_(i, componentUpdateIdx) = proposedEtaPrior0;
719722
// }
720723
// }
721-
//// row-specific Bernoulli probablity
722-
// double rho = R::rbeta(hyperpar->rhoA + (double)(arma::accu(proposedEta.row(i))),
723-
// hyperpar->rhoB + (double)(L) - (double)(arma::accu(proposedEta.row(i))));
724724
// logProposalEtaRatio += logPDFBernoulli( proposedEta(i,componentUpdateIdx), rho_proposed ) - logPDFBernoulli( etas_(i,componentUpdateIdx), rho[componentUpdateIdx] );
725725
proposedEtaPrior(i,componentUpdateIdx) = logPDFBernoulli( proposedEta(i,componentUpdateIdx), rho );
726726
logProposalEtaRatio += proposedEtaPrior(i, componentUpdateIdx) - logP_eta_(i, componentUpdateIdx);

0 commit comments

Comments
 (0)