diff --git a/README.md b/README.md index 245cc78..8f8f4f5 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ out #> Model estimated on 290 total observations and 2 groups #> Total MCMC iterations: 3000 #> maxL: 50 - maxK: 50 -#> Elapsed time: 1.548 secs +#> Elapsed time: 1.573 secs clusters <- estimate_clusters(out, burnin = 2000) clusters #> diff --git a/man/SANple-package.Rd b/man/SANple-package.Rd index 43a2af3..130fb55 100644 --- a/man/SANple-package.Rd +++ b/man/SANple-package.Rd @@ -4,7 +4,7 @@ \name{SANple-package} \alias{SANple} \alias{SANple-package} -\title{SANple: Fitting Common and Shared Atoms Nested Models via MCMC} +\title{SANple: Fitting Shared Atoms Nested Models via Markov Chains Monte Carlo} \description{ Estimate Bayesian nested mixture models via Markov Chain Monte Carlo methods. Specifically, the package implements the common atoms model (Denti et al., 2023), its finite version (D'Angelo et al., 2023), and a hybrid finite-infinite model. All models use Gaussian mixtures with a normal-inverse-gamma prior distribution on the parameters. Additional functions are provided to help analyzing the results of the fitting procedure. References: Denti, Camerlenghi, Guindani, Mira (2023) \doi{10.1080/01621459.2021.1933499}, D’Angelo, Canale, Yu, Guindani (2023) \doi{10.1111/biom.13626}. } diff --git a/src/common_functions.cpp b/src/common_functions.cpp index e6eff4b..b000983 100644 --- a/src/common_functions.cpp +++ b/src/common_functions.cpp @@ -24,7 +24,6 @@ arma::vec rdirichlet(arma::vec par) return(out) ; } - arma::vec relabel_arma(arma::vec cluster) { int n = cluster.n_elem ; diff --git a/src/funs_cam.cpp b/src/funs_cam.cpp index 1fc42e9..75fd7fa 100644 --- a/src/funs_cam.cpp +++ b/src/funs_cam.cpp @@ -22,6 +22,20 @@ int compute_trunc(double u_min, double kappa) // Compute stick-breaking weights starting from the vector of beta r.v. Beta(a_k,b_k) // Sethuraman (1994) construction arma::vec stick_breaking(arma::vec beta_var) +{ + int len = beta_var.n_elem ; + arma::vec out(len) ; + out(0) = beta_var(0) ; + arma::vec cs_log_one_m_beta = arma::cumsum(log(1.0-beta_var)); + for(int k = 1; k < len; k++) + { + out(k) = exp( log(beta_var(k)) + cs_log_one_m_beta(k-1)) ; + } + return(out) ; +} + +/* older version - to be removed +arma::vec stick_breaking(arma::vec beta_var) { int len = beta_var.n_elem ; arma::vec out(len) ; @@ -37,7 +51,7 @@ arma::vec stick_breaking(arma::vec beta_var) } return(out) ; } - +*/ // This function performs steps 1-4 of Algorithm 1 of Denti et al. (2021):