|
Docs
|
Module for binary covariate-related computations within clustering processes. More...
#include <binary_covariate_module.hpp>
Public Member Functions | |
| BinaryCovariatesModule (const Data &data_, const Eigen::VectorXi binary_covariate, double beta_prior_alpha_, double beta_prior_beta_, const Eigen::VectorXi *old_alloc_provider=nullptr, const std::unordered_map< int, std::vector< int > > *old_cluster_members_provider_=nullptr) | |
| Constructor for BinaryCovariatesModule. | |
Similarity Computation Methods | |
| double | compute_similarity_cls (int cls_idx, bool old_allo=false) const override __attribute__((hot)) |
| Compute covariate similarity contribution for a cluster. | |
| double | compute_similarity_obs (int obs_idx, int cls_idx) const override __attribute__((hot)) |
| Compute covariate similarity for a single observation in a cluster. | |
| Eigen::VectorXd | compute_similarity_obs (int obs_idx) const override __attribute__((hot)) |
| Compute covariate similarity contributions for all existing clusters. | |
| Public Member Functions inherited from Module | |
| Module (const Eigen::VectorXi *old_allocations_provider_=nullptr, const std::unordered_map< int, std::vector< int > > *old_cluster_members_provider_=nullptr) | |
| void | set_old_allocations_provider (const Eigen::VectorXi *provider) |
| void | set_old_cluster_members_provider (const std::unordered_map< int, std::vector< int > > *provider) |
| virtual | ~Module ()=default |
Protected Attributes | |
Module References | |
| const double | beta_prior_alpha = 1.0 |
| const double | beta_prior_beta = 1.0 |
| const Data & | data |
| Reference to data object with cluster assignments. | |
| const Eigen::VectorXi | binary_covariate_data |
Precomputed Values | |
| const double | log_beta_prior |
| Protected Attributes inherited from Module | |
| const Eigen::VectorXi * | old_allocations_provider |
| Provider function for accessing old allocation state. | |
| const std::unordered_map< int, std::vector< int > > * | old_cluster_members_provider |
| Provider function for accessing old cluster members map. | |
Module for binary covariate-related computations within clustering processes.
This class implements covariate-related computations for clustering processes where covariates are binary (0/1). It computes similarity measures based on the distribution of binary covariates within clusters using a Beta-Binomial model.
alpha is associated with the number of successes (1s) and beta with the number of failures (0s).
|
inline |
Constructor for BinaryCovariatesModule.
| data_ | Reference to data object with cluster assignments |
| binary_covariate | Covariate values (1D vector of 0s and 1s) |
| beta_prior_alpha_ | Prior alpha parameter for Beta-Binomial model |
| beta_prior_beta_ | Prior beta parameter for Beta-Binomial model |
| old_alloc_provider | Optional pointer to old allocations for split-merge moves |
| old_cluster_members_provider_ | Optional pointer to old cluster members for split-merge moves |
|
overridevirtual |
Compute covariate similarity contribution for a cluster.
Computes the log marginal likelihood of the covariates within a cluster under the Beta-Binomial conjugate model. Higher values indicate that observations in the cluster have similar covariate values. ...
The computation follows Müller et al. (2011):
Implements Module.
|
overridevirtual |
Compute covariate similarity contributions for all existing clusters.
Computes the predictive contributions for adding observation obs_idx to each existing cluster, considering covariate values.
| obs_idx | Index of the observation |
Implements Module.
|
overridevirtual |
Compute covariate similarity for a single observation in a cluster.
Computes the predictive contribution when adding observation obs_idx to cluster cls_idx, considering the covariate values.
| obs_idx | Index of the observation |
| cls_idx | Index of the cluster |
Used in Gibbs sampling to compute the probability of assigning an observation to a cluster based on covariate similarity.
Implements Module.
|
protected |
Prior alpha parameter for Beta-Binomial model
|
protected |
Prior beta parameter for Beta-Binomial model
|
protected |
Binary covariate values for observations
|
protected |
Reference to data object with cluster assignments.
|
protected |
Log Beta function for prior parameters