Skip to contents

This function performs a modularity-based hierarchical clustering approach to identify clusters from a correlation matrix.

Usage

get_hierarchical_clusters(cormat, min_cluster_corr = 0.8)

Arguments

cormat

A correlation matrix.

min_cluster_corr

The small correlation for the weights distributions across different iterations to be decided having only one cluster. Default is 0.8.

Value

A list containing:

cluster

A binary matrix indicating the cluster membership of each variable.

Q_modularity

The modularity values for the identified clusters.

See also

Other colocboost_utilities: get_cormat(), get_cos(), get_cos_purity(), get_cos_summary(), get_ucos_summary()

Examples

# Example usage
set.seed(1)
N <- 100
P <- 4
sigma <- matrix(0.2, nrow = P, ncol = P)
diag(sigma) <- 1
sigma[1:2, 1:2] <- 0.9
sigma[3:4, 3:4] <- 0.9
X <- MASS::mvrnorm(N, rep(0, P), sigma)
cormat <- get_cormat(X)
clusters <- get_hierarchical_clusters(cormat)
clusters$cluster
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    1    0
#> [3,]    0    1
#> [4,]    0    1
clusters$Q_modularity
#> [1] 3.588250e-17 3.618688e-01 2.714016e-01 1.809344e-01