Skip to content

Commit

Permalink
version 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscarmona authored and cran-robot committed Nov 30, 2020
1 parent 5c93958 commit c4216fe
Show file tree
Hide file tree
Showing 37 changed files with 569 additions and 186 deletions.
32 changes: 18 additions & 14 deletions DESCRIPTION
Expand Up @@ -2,25 +2,29 @@ Package: BNPMIXcluster
Type: Package
Title: Bayesian Nonparametric Model for Clustering with Mixed Scale
Variables
Version: 1.2.4
Authors@R: c(person("Christian", "Carmona", role = c("aut", "cre"), email = "carmona@stats.ox.ac.uk"),
person("Luis", "Nieto-Barajas", role = "aut", email = " lnieto@itam.mx"),
person("Antonio", "Canale", role = "ctb", email = "antonio.canale@unito.it")
Version: 1.3
Date: 2020-11-28
Authors@R: c(person("Christian", "Carmona", role = c("aut", "cre"), email = "carmona@stats.ox.ac.uk", comment = c(ORCID = "0000-0003-0224-4968")),
person("Luis", "Nieto-Barajas", role = "aut", email = " lnieto@itam.mx", comment = c(ORCID = "0000-0002-0859-7679")),
person("Antonio", "Canale", role = "ctb", email = "antonio.canale@unito.it", comment = c(ORCID = "0000-0002-5403-0040"))
)
Description: Bayesian nonparametric approach for clustering that is capable to combine different types of variables (continuous, ordinal and nominal) and also accommodates for different sampling probabilities in a complex survey design. The model is based on a location mixture model with a Poisson-Dirichlet process prior on the location parameters of the associated latent variables. The package performs the clustering model described in Carmona, C., Nieto-Barajas, L. E., Canale, A. (2016) <arXiv:1612.00083>.
License: GPL (>= 2)
Description: Model-based approach for clustering of multivariate data, capable of combining different types of variables (continuous, ordinal and nominal) and accommodating for different sampling probabilities in a complex survey design. The model is based on a location mixture model with a Poisson-Dirichlet process prior on the location parameters of the associated latent variables. Details of the underlying model is described in Carmona, C., Nieto-Barajas, L. E., Canale, A. (2016) <arXiv:1612.00083>.
License: MIT + file LICENSE
URL: https://github.com/christianu7/BNPMIXcluster
BugReports: https://github.com/christianu7/BNPMIXcluster/issues
LazyData: TRUE
Depends: R (>= 2.10),
Imports: compiler, gplots, MASS, matrixcalc, mvtnorm, plyr, Rcpp,
truncnorm
Imports: compiler, gplots, MASS, matrixcalc, mvtnorm, plyr, Rcpp (>=
1.0.5), truncnorm
LinkingTo: Rcpp, RcppArmadillo
Suggests: scatterplot3d
RoxygenNote: 6.0.1
RoxygenNote: 7.1.1
Encoding: UTF-8
NeedsCompilation: yes
Packaged: 2017-09-26 19:24:38 UTC; Chris
Author: Christian Carmona [aut, cre],
Luis Nieto-Barajas [aut],
Antonio Canale [ctb]
Packaged: 2020-11-29 23:19:05 UTC; chris
Author: Christian Carmona [aut, cre] (<https://orcid.org/0000-0003-0224-4968>),
Luis Nieto-Barajas [aut] (<https://orcid.org/0000-0002-0859-7679>),
Antonio Canale [ctb] (<https://orcid.org/0000-0002-5403-0040>)
Maintainer: Christian Carmona <carmona@stats.ox.ac.uk>
Repository: CRAN
Date/Publication: 2017-09-26 19:46:36 UTC
Date/Publication: 2020-11-30 11:10:06 UTC
2 changes: 2 additions & 0 deletions LICENSE
@@ -0,0 +1,2 @@
YEAR: 2020
COPYRIGHT HOLDER: Chris U. Carmona
64 changes: 36 additions & 28 deletions MD5
@@ -1,45 +1,53 @@
a1aca3d7720752c4918f41e438313cfc *DESCRIPTION
18a39446a0f4a0b3870ecc74d6379316 *DESCRIPTION
51ae03b1585f8c0706f96fd2c1d25653 *LICENSE
ee8dc04c07cf29bf971aded815ffa1dd *NAMESPACE
e5f2255fedc354da33a2be5c2cbcd75c *R/MIXclustering.R
29757b2aa5891398a21a9ae3b2624ffb *R/RcppExports.R
f03e938d710427a1eb94702927098660 *R/Y_ex_5_1.R
eb32ef2a7789a076f4d2874dd9a9b351 *R/Z_latent_ex_5_1.R
a8fe7794a18e8d3452e75a1bd1fa8bc6 *NEWS.md
5a81dc98ed116ff0e3bbd573cbde1c85 *R/MIXclustering.R
9d4512aa019cd6794a45f657149b8dee *R/RcppExports.R
7bc9793b9a80baa43676b99a7e9258b1 *R/Y_ex_5_1.R
f6e01a8dc7abe2ebd5be1707057bf122 *R/Z_latent_ex_5_1.R
95d43b9ca5d1c43aee6919415a218fdf *R/det_omega_mod.R
bbfb3cf53e86df5f960448d31a4395f6 *R/get_latents.R
e1ac8504234a21f8e6fdb478d3514b47 *R/get_latents.R
179c29ce2596aa53ae68b5ee9a5a7a47 *R/log_f_post_Lambda_jj.R
d394a878ad63b74f4059f2e18cd880e2 *R/log_f_post_Omega.R
527d84bd4b3e96313160bfae1b8d916a *R/log_f_post_Omega.R
8732b15933a3369213a6ab87b3760c32 *R/log_f_post_a.R
195ccc0b2811e15eb218b51049ecbf5c *R/log_f_post_b.R
384a68a0ae5a8f9afe81f3fd2670b54c *R/meta_param_ex.R
bfb3f15d59701815b3e05b1bea80e2b5 *R/meta_param_ex.R
32a050d2e63112c3fc67f498d26d0fca *R/plot.MIXcluster.R
69be32fb98977f5fdca6425606c70577 *R/poverty.data.R
fd855c7af5dd56ca60cd0257492e304b *R/poverty.data.R
acc85741b57f9b59eb93c9270b5332fb *R/print.MIXcluster.R
e0d5b6ad9d258ce1d53580b4d6724c1e *R/sampling_Lambda_jj.R
5700bd37e4246b9b7ebc2dd8fbfc5028 *R/sampling_Omega_ij.R
1b1d886146de50df10cbf36505d0a858 *R/sampling_a.R
cb61793c325136318eb796401ea46bf7 *R/sampling_b.R
580761f1ea2334f502db6a6c1c89b868 *R/sampling_Lambda_jj.R
231fcfcb2a47de44b2146ffa54ed4fc2 *R/sampling_Omega_ij.R
698a618a6264c952da2550c1c746b15b *R/sampling_a.R
45709ac73e65984dd709929029887b78 *R/sampling_b.R
cf1d4c55ebf03e9a5905fc28c5dd1a86 *R/summary.MIXcluster.R
5527f8b296fafcd7b25a900489f6663a *README.md
e74971d952c037671b5c05e5ee7f7692 *data/Y_ex_5_1.rda
834cac29dc53fe3031328b93c508b31f *data/Z_latent_ex_5_1.rda
6fc61e48a9f16f1a1c671d96fbddad9f *data/meta_param_ex.rda
5b4971a336869c5c5160fc0fc2e39c69 *data/poverty.data.rda
de98b5f45e6bba3970ee1b3fba520a1a *inst/include/BNPMIXcluster.h
1cac0c598598395619c503dde0b410a5 *inst/include/BNPMIXcluster_RcppExports.h
aaca22bf91d115a60a060f65756dae8a *man/MIXclustering.Rd
2105272bd48fddfe899d1c4967bba3a4 *man/Y_ex_5_1.Rd
48ae820b9ba3277af28cd2eafa053995 *man/Z_latent_ex_5_1.Rd
cc5626248654855a2b86be9a5b30913c *man/get_latents.Rd
56fce3947c463cce12478971b57daeb4 *man/meta_param_ex.Rd
82ae95703ed254011e5f844ee9a76f86 *man/plot.MIXcluster.Rd
454e8a1e27e92faf0c683dd6f91ce0ec *man/poverty.data.Rd
57f6472d997d6a9dff8a617241f2bff6 *man/sampling_Lambda_jj.Rd
6f4f8652ebd2c039213a9f3b0c2711aa *man/sampling_Omega_ij.Rd
e9f43ecfef04b3387a73daefa075e61a *man/sampling_a.Rd
f436ffef64f3d9705b8ca3e605e15e4b *man/sampling_b.Rd
c6894e8f82203d769d74270a20a173d2 *inst/include/BNPMIXcluster_RcppExports.h
c4c02c5a7b07a3f5cb4931c9fad19b8b *man/MIXclustering.Rd
7d061923811556422801d4045bd674d7 *man/Y_ex_5_1.Rd
989b501d09db8fd93499b3f22e13c7e7 *man/Z_latent_ex_5_1.Rd
68b2212e4f8c59b924ce8c7a5311bf3a *man/figures/README-sim_study_5_1_data-1.png
81a46156eade3aaa7cd3e6d3a54baffe *man/figures/README-sim_study_5_1_plot_1-1.png
59c3f34d53192c5696b1ace850321e02 *man/figures/README-sim_study_5_1_plot_2-1.png
b257dea2abb38bba55dbfb6766a8f8ba *man/figures/README-sim_study_5_1_plot_3-1.png
6ca4b4b6434e3e5ed3cdc3fe526b9917 *man/figures/README-sim_study_5_1_plot_4-1.png
c8caff8291d1162669c4f8020165b2bb *man/get_latents.Rd
126ff68abaec2133ee964ed38b5bf3b7 *man/meta_param_ex.Rd
de6b621c2818a277dc44319b75a303ff *man/plot.MIXcluster.Rd
328106053acc0d895911bc6f8004c677 *man/poverty.data.Rd
ecbd712edf9a2a3289bbb437a18e71c5 *man/sampling_Lambda_jj.Rd
8877dd5202e93978e744853f365a8410 *man/sampling_Omega_ij.Rd
5ee109369feb5e940f581ee273bf69fe *man/sampling_a.Rd
479cbf30cff1d661e72d07fe82fef47a *man/sampling_b.Rd
b599ae226c33b831bd2f909146b2c644 *man/summary.MIXcluster.Rd
4d751a816a417548d9de308ba62c3ba7 *src/Makevars
4d751a816a417548d9de308ba62c3ba7 *src/Makevars.win
93f2caf30d30a5bf0c53e812ce9fc910 *src/RcppExports.cpp
61059660eb073d93e00e8ee054237071 *src/Makevars
61059660eb073d93e00e8ee054237071 *src/Makevars.win
639e9f5e312718d74dd447a201ff99aa *src/RcppExports.cpp
da18bf1736d4ee6638c0d38646ceec89 *src/dmvnrm_arma.cpp
8e4f42cc8b23e3fd199d67ce8e7c3f5d *src/get_latents.cpp
3f37ede1d5812558dc018b70cd3a91d8 *src/log_f_post_Lambda_jj.cpp
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
@@ -0,0 +1,8 @@
# BNPMIXcluster 1.3
- Addressed check issues related to makefiles.
- Adoption of some best practices for package management, which include:
- Added a `README.md` file for an introduction to the package functionality.
- Added a `NEWS.md` file to track changes to the package.
- Change of License to MIT
- Git repo contains the RStudio project.
- Use of renv to manage package dependencies.
30 changes: 16 additions & 14 deletions R/MIXclustering.R
Expand Up @@ -2,7 +2,7 @@
#' Bayesian Nonparametric Model for Clustering with Mixed Scale Variables
#'
#' @description
#' \code{MIXclustering} is used to perform cluster analisis of individuals using a Bayesian nonparametric mixture model that jointly models mixed scale data and accommodates for different sampling probabilities. The model is described in Carmona, C., Nieto-Barajas, L. E., Canale, A. (2016).
#' \code{MIXclustering} is used to perform cluster analysis of individuals using a Bayesian nonparametric mixture model that jointly models mixed scale data and accommodates for different sampling probabilities. The model is described in Carmona, C., Nieto-Barajas, L. E., Canale, A. (2016).
#'
#' @param Y Matrix or data frame containing the data to be clustered.
#'
Expand All @@ -18,7 +18,7 @@
#'
#' @param n_iter_out Number of effective iterations in the MCMC procedure for clustering.
#' @param n_burn Number of iterations discarded as part of the burn-in period at the beginning MCMC procedure.
#' @param n_thin Number of iterations discarded for thining the chain (reducing the autocorrelation). We keep 1 of every n_thin iterations.
#' @param n_thin Number of iterations discarded for thinning the chain (reducing the autocorrelation). We keep 1 of every n_thin iterations.
#'
#' @param a_fix A numeric value to set the parameter \eqn{a} in the model. If \code{NULL} (default), the parameter \eqn{a} is assigned a prior distribution. See \code{details}.
#' @param alpha Hyperparameter in the prior distribution of \eqn{a}. See \code{details}.
Expand All @@ -40,15 +40,15 @@
#' @param d_1_mu Hyperparameter in the prior distribution of the variance of the location in each cluster. See \code{details}.
#'
#' @param log_file Specifies a file to save the details with the execution time and the parameters used.
#' @param keep_param_chains Indicates wheter the simulations of parameters \code{a}, \code{b}, \code{lambda} and \code{omega} should be returned as output.
#' @param keep_param_chains Indicates if the simulations of parameters \code{a}, \code{b}, \code{lambda} and \code{omega} should be returned as output.
#'
#' @details
#'
#' The model consists on a bayesian non-parametric approach for clustering that is capable to combine different types of variables through the usage of associated continuous latent variables. The clustering mechanism is based on a location mixture model with a Poisson-Dirichlet (\eqn{PD}) process prior on the location parameters \eqn{\mu_i ; i=1,...,n} of the associated latent variables.
#' The model consists on a Bayesian non-parametric approach for clustering that is capable to combine different types of variables through the usage of associated continuous latent variables. The clustering mechanism is based on a location mixture model with a Poisson-Dirichlet (\eqn{PD}) process prior on the location parameters \eqn{\mu_i ; i=1,...,n} of the associated latent variables.
#'
#' Computational inference about the cluster allocation and the posterior distribution of the parameters are performed using MCMC simulations.
#' Computational inference about the cluster allocation and the posterior distribution of the parameters are performed using MCMC.
#'
#' A full description of the model is in the article Carmona et al. (2016) (preprint: \url{http://arxiv.org/abs/1612.00083}). See \code{Reference}.
#' A full description of the model is in the article Carmona et al. (2016) (\url{https://arxiv.org/abs/1612.00083}). See \code{Reference}.
#'
#' The model consider an individual \eqn{y_i} that is characterized by a multivariate response of dimension \eqn{p}, i.e., \eqn{y_i=(y_{i,1},...,y_{i,p})}. The total number of variables \eqn{p} is divided into \eqn{c} continuous variables, \eqn{o} ordinal variables, and \eqn{m} nominal variables such that \eqn{p=c+o+m}.
#'
Expand All @@ -73,7 +73,7 @@
#'
#' \eqn{\mu_i | G}~\eqn{G}, iid for \eqn{i=1,...,n}
#'
#' Where \eqn{G}~\eqn{PD(a,b,G_0)} is a Poisson-Dirichlet process with parameters \eqn{a \in [0,1)}, \eqn{b>-a} and centring measure \eqn{G_0}. The Dirichlet and the normalized stable processes arise when \eqn{a=0} and when \eqn{b=0}, respectively.
#' Where \eqn{G}~\eqn{PD(a,b,G_0)} is a Poisson-Dirichlet process with parameters \eqn{a \in [0,1)}, \eqn{b>-a} and centering measure \eqn{G_0}. The Dirichlet and the normalized stable processes arise when \eqn{a=0} and when \eqn{b=0}, respectively.
#'
#' In consequence, this choice of prior implies that the \eqn{\mu_i}'s are exchangeable with marginal distribution \eqn{\mu_i}~\eqn{G_0} for all \eqn{i=1,...,n}.
#'
Expand All @@ -93,7 +93,7 @@
#'
#' For example, increasing the values of \code{d_1_a} and \code{d_1_b} reduce the number of groups.
#'
#' Finally, the function parameters \code{eta}, \code{kappa}, \code{delta} are tuning parameters that control the acceptance rate in the random-walk MH steps of the new proposed values for the parameters \eqn{b}, \eqn{\Lambda_{j,j}} (variance of latents) and \eqn{\Omega_{i,j}} (correlation of latents). These parameters are not recomended to be changed (used in the internal functions: \code{sampling_b} , \code{sampling_Lambda_jj} , \code{sampling_Omega_ij}).
#' Finally, the function parameters \code{eta}, \code{kappa}, \code{delta} are tuning parameters that control the acceptance rate in the random-walk MH steps of the new proposed values for the parameters \eqn{b}, \eqn{\Lambda_{j,j}} (variance of latents) and \eqn{\Omega_{i,j}} (correlation of latents). These parameters are not recommended to be changed (used in the internal functions: \code{sampling_b} , \code{sampling_Lambda_jj} , \code{sampling_Omega_ij}).
#'
#' @return
#' \code{MIXclustering} returns a S3 object of class "\code{MIXcluster}".
Expand Down Expand Up @@ -135,14 +135,16 @@
#'
#' # Specification of data Y #
#' help(Y_ex_5_1)
#' # Choose 1, 2, or 3 #
#'
#' # Observable data
#' # Choose scenario: 1, 2, or 3
#' ex_i <- 1
#'
#' # specification of parameters #
#' help(meta_param_ex)
#' # Choose "a", "b" or "c" #
#' # Prior specification
#' # Choose "a", "b" or "c"
#' param_j <- "c"
#'
#' # Specify the data type that is being provided to the method
#' var_type_Y_ex_5_1 <- list( c("c","c","c"),
#' c("o","o"),
#' c("o","o","o","c") )
Expand Down Expand Up @@ -170,7 +172,7 @@
#' # Summary of clustering results
#' summary(cluster_ex)
#'
#' # Representation of clustering results
#' # Visualizing clustering results
#' plot(cluster_ex,type="heatmap")
#' plot(cluster_ex,type="chain")
#'
Expand Down Expand Up @@ -258,7 +260,7 @@
#' }
#'
#' @references
#' Carmona, C., Nieto-Barajas, L. E. & Canale, A. (2017). \emph{Model based approach for household clustering with mixed scale variables.} (preprint: \url{http://arxiv.org/abs/1612.00083})
#' Carmona, C., Nieto-Barajas, L. E. & Canale, A. (2017). \emph{Model based approach for household clustering with mixed scale variables.} (\url{https://arxiv.org/abs/1612.00083})
#'
#' @importFrom stats aggregate as.formula cor rgamma rmultinom sd
#' @import plyr
Expand Down
16 changes: 8 additions & 8 deletions R/RcppExports.R
Expand Up @@ -9,14 +9,6 @@ get_latents_cpp <- function(Y, var_type, mu_Z, sigma_Z, Z_ini, verbose = FALSE)
.Call('_BNPMIXcluster_get_latents_cpp', PACKAGE = 'BNPMIXcluster', Y, var_type, mu_Z, sigma_Z, Z_ini, verbose)
}

log_f_post_a_cpp <- function(a, b, alpha, d_0_a, d_1_a, mu_star_n_r) {
.Call('_BNPMIXcluster_log_f_post_a_cpp', PACKAGE = 'BNPMIXcluster', a, b, alpha, d_0_a, d_1_a, mu_star_n_r)
}

log_f_post_b_cpp <- function(b, a, d_0_b, d_1_b, mu_star_n_r) {
.Call('_BNPMIXcluster_log_f_post_b_cpp', PACKAGE = 'BNPMIXcluster', b, a, d_0_b, d_1_b, mu_star_n_r)
}

log_f_post_Lambda_jj_cpp <- function(sigma_jj, d_0_z, d_1_z, Z, mu_Z, sigma_Z, sampling_prob) {
.Call('_BNPMIXcluster_log_f_post_Lambda_jj_cpp', PACKAGE = 'BNPMIXcluster', sigma_jj, d_0_z, d_1_z, Z, mu_Z, sigma_Z, sampling_prob)
}
Expand All @@ -25,6 +17,14 @@ log_f_post_Omega_cpp <- function(Omega, Z, mu_Z, sampling_prob, Lambda) {
.Call('_BNPMIXcluster_log_f_post_Omega_cpp', PACKAGE = 'BNPMIXcluster', Omega, Z, mu_Z, sampling_prob, Lambda)
}

log_f_post_a_cpp <- function(a, b, alpha, d_0_a, d_1_a, mu_star_n_r) {
.Call('_BNPMIXcluster_log_f_post_a_cpp', PACKAGE = 'BNPMIXcluster', a, b, alpha, d_0_a, d_1_a, mu_star_n_r)
}

log_f_post_b_cpp <- function(b, a, d_0_b, d_1_b, mu_star_n_r) {
.Call('_BNPMIXcluster_log_f_post_b_cpp', PACKAGE = 'BNPMIXcluster', b, a, d_0_b, d_1_b, mu_star_n_r)
}

rtn1 <- function(mean, sd, low, high) {
.Call('_BNPMIXcluster_rtn1', PACKAGE = 'BNPMIXcluster', mean, sd, low, high)
}
Expand Down
2 changes: 1 addition & 1 deletion R/Y_ex_5_1.R
Expand Up @@ -9,7 +9,7 @@
#'
#' @description
#'
#' List with three data frames. Each dataset consists of the data Yi described in the exercise of section 5.1 in the article Carmona et al (2017).
#' List with three data frames. Each dataset consists of the data \eqn{Y_i} described in the exercise of section 5.1 in the article Carmona et al (2017).
#'
#' The data \code{Y_ex_5_1} is a transformation of the simulated data \code{Z_latent_ex_5_1}.
#'
Expand Down
6 changes: 3 additions & 3 deletions R/Z_latent_ex_5_1.R
Expand Up @@ -8,11 +8,11 @@
#' Simulated data for testing the \emph{BNPMIXcluster} package
#'
#' @description
#' Simulated values for three continuos variables under the existence of three clusters.
#' Simulated values for three continuous variables under the existence of three clusters.
#'
#' The data consists of a three-variate Normal distribution with different mean and covariance matrix between clusters.
#'
#' This can be assumed either as continuos data to be clustered Y=(Y_1,Y_2,Y_3); or also can be used as the underlying latent data that can be transformed into observable variables Y_i=f(Z_i), which can be continuos or categorical.
#' This can be assumed either as continuous data to be clustered Y=(Y_1,Y_2,Y_3); or also can be used as the underlying latent data that can be transformed into observable variables Y_i=f(Z_i), which can be continuous or categorical.
#'
#' @usage
#' Z_latent_ex_5_1
Expand All @@ -21,7 +21,7 @@
#' A data frame with 100 rows and 4 variables.
#' \describe{
#' \item{cluster}{Indicates the cluster for each row}
#' \item{Z1,Z2,Z3}{Continuos values coming from a multivariate normal distribution, given the cluster}
#' \item{Z1,Z2,Z3}{Continuous values coming from a multivariate normal distribution, given the cluster}
#' }
#'
#' @details
Expand Down
8 changes: 4 additions & 4 deletions R/get_latents.R
Expand Up @@ -23,8 +23,8 @@
#' @importFrom MASS ginv
#'
#' @details
#' For each variable in the \code{Y} data frame, an associated continuos latent variable is generated.
#' if \eqn{Y_j} is continuos, the corresponding \eqn{Z_j} will keep the original values of \eqn{Y_j}.
#' For each variable in the \code{Y} data frame, an associated continuous latent variable is generated.
#' if \eqn{Y_j} is continuous, the corresponding \eqn{Z_j} will keep the original values of \eqn{Y_j}.
#' If \eqn{Y_j} is categorical, the function will scan the unique values of \eqn{Y_j} and generate continuous latent variables accordingly.
#'
#' @keywords internal
Expand Down Expand Up @@ -109,7 +109,7 @@ get_latents <- function( Y,

# colnames of Z #
colnames_Z <- NULL
# colnames of Z: continuos #
# colnames of Z: continuous #
if( n_c > 0 ) {
colnames_Z <- c( colnames_Z, paste("var_",
rep(var_type_all[1],n_c),"_",
Expand Down Expand Up @@ -150,7 +150,7 @@ get_latents <- function( Y,
# cat('Simulating latents for ',n_c,' Continuous variables ')
if( is.null(Z_old) ) {
Z[,1:n_c] <- as.matrix( Y[,1:n_c] )
# standardize the continuos variables
# standardize the continuous variables
#Z[,1:n_c] <- as.matrix( scale(Y[,1:n_c]) , nrow=nrow(Y), ncol=n_c )
} else {
Z[,1:n_c] <- Z_old[,1:n_c]
Expand Down
1 change: 0 additions & 1 deletion R/log_f_post_Omega.R
Expand Up @@ -15,7 +15,6 @@ log_f_post_Omega <- function(Omega,
aux_s <- matrix(Z[i,]-mu_Z[i,],nrow=n_q,ncol=1)
S_mat <- S_mat + 1/sampling_prob[i] * aux_s %*% t(aux_s)
}
#browser()
log_posterior_Omega <- -(1/2)*(n_q+1) * sum(log(abs(diag(Omega)))) - (1/2) * (n+2-n_q*(n_q-1)) * det(Omega) - (1/2) * sum(diag( solve(Omega) %*% (solve(Lambda) %*% S_mat %*% solve(Lambda)) ))

return( log_posterior_Omega )
Expand Down

0 comments on commit c4216fe

Please sign in to comment.