## A Dirichlet stochastic block model for composition-weighted networks

Iuliia Promskaia 1,2 , Adrian O'Hagan 1,2 , and Michael Fop 2

1

SFI Insight Centre for Data Analytics, Dublin, Ireland 2 School of Mathematics and Statistics, University College Dublin, Dublin, Ireland

Corresponding author: iuliia.promskaia@insight-centre.org

## Abstract

Network data are observed in various applications where the individual entities of the system interact with or are connected to each other, and very often these interactions are defined by their associated strength or importance. Clustering is a common task in network analysis that involves finding groups of nodes which display similarities in the way they interact with the rest of the network. However, most clustering methods use the strengths of connections between entities in their original form, ignoring the possible differences in the capacities of individual nodes to send or receive edges. This often leads to clustering solutions that are heavily influenced by the nodes' capacities. One way to overcome this is to analyse the strengths of connections in relative rather than absolute terms, expressing each edge weight as a proportion of the sending (or receiving) capacity of the respective node. This, however, induces additional modelling constraints that most existing clustering methods are not designed to handle. In this work we propose a stochastic block model for composition-weighted networks based on direct modelling of compositional weight vectors using a Dirichlet mixture, with the parameters determined by the cluster labels of the sender and the receiver nodes. Inference is implemented via an extension of the classification expectation-maximisation algorithm that uses a working independence assumption, expressing the complete data likelihood of each node of the network as a function of fixed cluster labels of the remaining nodes. A model selection criterion is derived to aid the choice of the number of clusters. An alternative approach to clustering in composition-weighted networks based on a mapping to the Euclidean space is also provided. The model is validated using a number of simulation studies, assessing the effect of various initialisation strategies on the model's performance, latent structure recovery, parameter estimation quality and model selection. Furthermore, it is showcased on network data from the Erasmus exchange program and a bike sharing network for the city of London.

Keywords Compositional data, hybrid likelihood, statistical network analysis, stochastic block model, weighted networks

Acknowledgements This work was supported by the Science Foundation Ireland funded Insight Centre for Data Analytics (Grant number 12/RC/2289 P2).

## 1 Introduction

Networks are often used to represent relationships between entities, and in the recent past there has been a rapid increase in the collection and availability of such relational data. Network data appear in a diverse range of applications, such as the social sciences (Rastelli and Fop, 2020), biology (Daudin, 2011), transportation (Ng and Murphy, 2021), and finance (Hledik and Rastelli, 2023). Given the wide availability of network data, the statistical analysis and modelling of networks is an active area of research, driven by the unique challenges that these data present, largely due to the dependence between entities. For a concise overview of the main models and methods for network data see Salter-Townshend et al. (2012).

One common task in network analysis is clustering, which involves finding groups of nodes that share similar connectivity patterns or have similar characteristics. The two main families of approaches to clustering in networks are algorithm-based and model-based (Leger et al., 2013). Algorithm-based methods, as the name suggests, involve a set of operations that partition the network into clusters. These methods are often based on some notion of distance or similarity

between nodes (Pons and Latapy, 2006), spectral properties of the Laplacian matrix (von Luxburg, 2007), or an optimisation procedure (Guimer` et al., 2010; Clauset et al., 2005). a Model-based methods assume the presence of sub-populations in the data, corresponding to the clusters, which are then modelled by means of probability distributions. As opposed to algorithm-based methods, model-based clustering approaches have the advantage of providing a principled framework where the clustering task is framed as an inferential task for a generative probability model (Daudin, 2011; Bouveyron et al., 2019).

Stochastic block modelling is a popular model-based clustering framework for network data, which models the connectivity patterns between pairs of nodes, assuming their stochastic equivalence: the presence and the strength of a connection between two nodes is determined by their cluster membership rather than by the nodes themselves. The definition of a stochastic block model as a way to describe the a priori community structure in a network was introduced in Holland et al. (1983) and Wang and Wong (1987), and the first attempt to use this model as a clustering tool was made in Wasserman and Anderson (1987).

The stochastic block model (SBM) was originally developed for the analysis and clustering of binary network data. For this type of data, binary interactions are often defined on a prespecified threshold or on a subjective evaluation of what constitutes an interaction between two nodes, resulting in a potential information loss. With network data becoming more widespread and complex in the recent years, a number of extensions of the SBM to networks with different edge types and characteristics have been proposed. Particular efforts have been focused on clustering models for weighted networks. For instance, Nowicki and Snijders (2001) extended the SBM to allow for finite set valued edges, such as those taking values in {-1 0 1 , , } . Count edge attributes or multiple edges between pairs of nodes were considered in El Haj et al. (2022), Karrer and Newman (2011), Zanghi et al. (2010), and Mariadassou et al. (2010). To cluster nodes in networks with continuous edge weights, Ng and Murphy (2021) propose a weighted SBM based on Gamma distributions. More general frameworks encompassing a wider range of edge types and attribute distributions have been proposed by Aicher et al. (2013, 2014), and Ludkin (2020). We point the reader to Lee and Wilkinson (2019) for a comprehensive review of extensions of the SBM for different data types as well as inferential approaches. An approach related to weighted SBMs is the one introduced by Melnykov et al. (2020). In Melnykov et al. (2020), the authors propose a general framework for performing model-based clustering on multi-layer networks. The approach uses a multivariate Gaussian distribution to model the weights, allowing the correlation between weights connecting pairs of nodes as well as between edge weights across different layers to be accounted for. This work can be seen as a generalisation of a weighted SBM (Aicher et al., 2013, 2014; Ng and Murphy, 2021) that takes into account the correlation structure between the weights.

All of the aforementioned approaches propose models for the analysis of the weights in their original form. However, in some applications, in particular those modelling flows in the network, such as transportation or trade, the observed edge weights are influenced by the nodes' capacities to send and receive edges, which can differ significantly across the network. This often results in clustering solutions that mimic the patterns related to the capacities of the sending and receiving nodes, rather than the weights connecting them. Taking as an example the Erasmus programme network presented in Section 6.1, suppose we are interested in grouping European countries based on similarities in students' preferences for exchange destinations. With the participating countries having very different populations, we expect larger countries, such as Germany, France and the UK, to have larger student populations and so larger volumes of students participating in the programme. These countries are also able to accommodate more incoming students. By contrast, the Nordic countries, like Denmark and Finland, are much smaller in population, and hence they send and receive significantly fewer students. If we were to perform clustering using the raw counts of students going on Erasmus exchange between these countries without taking the differences in population into account, the countries would be roughly divided into groups based on their population sizes, i.e. Germany, France and the UK as one cluster, and Denmark and Finland as another, due to differences in the scale of the weights. Even if the preference profile of the UK students is closer to those of the smaller Nordic countries, the volume of students the country sends is far too large for it to be assigned to the same cluster as Finland and Denmark. Similar issue can arise in flight networks, with small airports only being able to service a limited number of flights per day as opposed to international hubs with multiple runways, or international trade networks, where the value of goods traded is linked to country's GDP (Melnykov et al., 2020). The differences in the magnitudes of edge weights can significantly affect the results, making it more challenging to draw conclusions.

One way to address this is by using relative rather than absolute weights in the network. In the aforementioned cases, this can be done by calculating proportions of flow alongside each edge with

respect to a sending (or receiving) node, leading to edge weights of relative size. In other applications, the absolute weights can simply be unavailable for the analysis as the interactions between nodes are measured in relative terms to begin with. For example, in epidemiological networks the edge weights could represent probabilities of interaction between agents, or in infrastructure networks they could correspond to proportions of liquid flowing between units. Networks with relative edge weights can also arise as a result of privacy protection policies, such as in Hledik and Rastelli (2023), where the absolute information could potentially be used to identify individual actors, banks in this case.

The main challenge associated with the relative nature of edge weights in the network is their interdependence. Proportional data impose a constant-sum constraint, making the standard tools used for networks with independent weights invalid. To appropriately address this constraint, tools from compositional data analysis can be employed. Compositional data describe parts of some whole, such as percentages, probabilities, and proportions, and they can be naturally observed or constructed from other types of data, such as continuous or count data, by dividing individual components by their sum. There are two main families of approaches to compositional data analysis. The first involves mapping the compositions onto the real line, allowing one to use the standard machinery on the transformed data. Log-ratio transformations are a popular choice in the literature due to their sound theoretical properties, and other alternatives, such as standardisation, are also sometimes used in practice (Aitchison, 1986; Baxter, 1995). The second approach is based on direct modelling of compositional observations, which often uses the Dirichlet distribution to model the compositions in their original form (Pal and Heumann, 2022; Tsagris and Stewart, 2018). Both approaches have their relative benefits, such as the scale-invariance of the log-ratio transformations, or desirable distributional properties that come with direct modelling, and so the choice of the most suitable approach is context dependent. For the discussion of the main methods and challenges in compositional data analysis, we suggest the review paper by Alenazi (2023).

The literature on models and methods for networks with weights of relative nature is very scarce, with most works addressing unique application-specific challenges, often related to biological networks. Examples of such works are Yuan et al. (2019) and Ha et al. (2020), where the centered log-ratio transformation is applied to the compositional data to eliminate the constantsum constraint in an attempt to recover the microbiome interaction network. Another notable work by Hledik and Rastelli (2023), which is driven by a financial market application, uses direct modelling of proportions via the Dirichlet distribution and proposes a dynamic latent variable modelling framework for the analysis of interbank networks.

To the best of our knowledge, there have been no attempts to develop a general model-based clustering framework for composition-weighted networks. In this work, we propose an extension of the stochastic block model that utilises the relative rather than absolute strength of connections, by leveraging ideas from compositional data analysis. We model the set of edge weights from each node using a Dirichlet distribution, the parameters of which are determined by the cluster labels of the sender and each of the receivers. For inference, we consider the hybrid maximum likelihood approach developed by Marino and Pandolfi (2022), based on Daudin et al. (2008), using a variant of the classification expectation-maximisation (EM) algorithm (Celeux and Govaert, 1992). To address model selection, an integrated completed likelihood (ICL) criterion is derived (Daudin et al., 2008). We also briefly introduce an alternative approach to cluster nodes in compositionweighted networks by making use of the log-ratio transformation that maps compositional data onto the real line (Aitchison, 1982). The code implementing the modelling framework in R (R Core Team, 2019) is available on GitHub.

The structure of this paper is as follows: we start by describing the SBM with compositional Dirichlet-distributed edge weights in Section 2, and outline the inferential procedure based on a classification EM algorithm in Section 3; Section 4 presents an alternative method to cluster nodes in the network with compositional edge weights by using the log-ratio transformation of the compositions and then utilising a standard weighted stochastic block model; we test the model performance on synthetic data in Section 5, assessing different initialisation strategies, parameter estimation quality, and clustering and model selection performance, also in comparison to alternative approaches; we then illustrate the use of the proposed model in application to the Erasmus programme data from Gad´ ar et al. (2020) and the London bike sharing data from Transport for London (2016) in Section 6; Section 7 concludes the paper with a discussion, highlighting the work's impact and the potential for further developments.

## 2 Dirichlet stochastic block model

This section introduces the Dirichlet stochastic block model (DirSBM) for networks with compositional edge weights.

̸

Let Y be the weighted adjacency matrix of a directed network on n nodes with no self-loops with strictly positive entries, i.e. y ij &gt; 0 for all i = j and y ii = 0 for all i . Define the compositional counterpart of Y , denoted X , whose row entries x i are given by

̸

$$\mathbf x _ { i } = \left ( \frac { y _ { i 1 } } { \sum _ { j \neq i } ^ { n } y _ { i j } }, \frac { y _ { i 2 } } { \sum _ { j \neq i } ^ { n } y _ { i j } }, \dots, \frac { y _ { i ( i - 1 ) } } { \sum _ { j \neq i } ^ { n } y _ { i j } }, 0, \frac { y _ { i ( i + 1 ) } } { \sum _ { j \neq i } ^ { n } y _ { i j } }, \dots, \frac { y _ { i n } } { \sum _ { j \neq i } ^ { n } y _ { i j } } \right ),$$

̸

̸

̸

̸

̸

i.e. x ij &gt; 0 for i = j and ∑ l x il = 1 ∀ i . Note that x ii = 0 is due to the absence of self-loops in the original weighted network. Denote with x ∗ i a subvector of x i that excludes the zero entry x ii , and with X ∗ the matrix formed by row vectors x ∗ i , i = 1 , . . . , n . In practice, in some applications, the weighted adjacency matrix Y may be unavailable, with the compositional matrix X being the only piece of data provided. The Dirichlet stochastic block model with K blocks assumes the following generative process for a network with compositional edge weights X ∗ :

- 1. Given a K -dimensional vector of cluster membership proportions θ , generate binary cluster allocations z i ∼ Multinom (1 , θ ), for i = 1 , . . . , n . The entries of these vectors, i.e. z ik = 1 when node i is assigned to cluster C k and 0 otherwise. Denote with Z an n × K matrix of binary cluster allocations of all nodes in the network, and with Z -i the ( n -1) × K -dimensional matrix of cluster allocations of all nodes in the network that are not i .
- 2. Let A = { α kh } K h k, =1 be a K × K matrix with strictly positive values, corresponding to the Dirichlet distribution concentration parameters. Given the cluster allocations, generate ( n -1)-dimensional compositional observations as

$$x _ { i } ^ { * } | z _ { i }, \mathbf Z _ { - i } \sim D i r ( \mathbf z _ { i } \mathbf A \mathbf Z _ { - i } ^ { \top } ),$$

$$\text{for } i = 1, \dots, n.$$

To aid understanding, consider the vector c denoting the cluster labels of the nodes in the network, such that c i = k if i is a member of cluster C k . The above distribution can also be written as

$$\mathbf x _ { i } ^ { * } | \mathbf c \sim D i r ( \alpha _ { c _ { i } c _ { 1 } }, \dots, \alpha _ { c _ { i } c _ { i - 1 } }, \alpha _ { c _ { i } c _ { i + 1 } }, \dots, \alpha _ { c _ { i } c _ { n } } ).$$

̸

The intuition behind this formulation is as follows: for any sender i , the distribution of weights of the edges connecting it to other vertices depends on the cluster memberships of i itself and of all of the receiver nodes j = . If the sender i i and the receiver j are members of the same cluster C k , the corresponding parameter of the Dirichlet distribution is α kk , and this parameter value is shared for all such receivers j ∈ C k . If instead the receiver node is in a different cluster, j ∈ C h , the corresponding parameter is α kh .

## 2.1 Properties of DirSBM

The model statement in Section 2 implies that the distribution of weight vectors conditional on cluster labels in the whole network is shared among the nodes assigned to the same cluster, up to a permutation of the ordering of the nodes, which is assumed to be invariant for simplicity.

To illustrate this, consider, for example, the distribution of compositional weights of node i ∈ C 1 and rearrange the order of the dimensions so that they are sorted by cluster assignment index in ascending order for ease of notation. Every vector of compositional weights of node i belonging to cluster C 1 , denoted x ∗ i ∈ C 1 , conditional on the cluster assignments of all the remaining ( n -1) nodes, is distributed as

$$x _ { i \in C _ { 1 } } ^ { * } | \mathbf Z \sim D i r ( \underbrace { \alpha _ { 1 1 }, \dots, \alpha _ { 1 1 } } _ { ( n _ { 1 } - 1 ) \text{ times} }, \underbrace { \alpha _ { 1 2 }, \dots, \alpha _ { 1 2 } } _ { n _ { 2 } \text{ times} }, \dots, \underbrace { \alpha _ { 1 h }, \dots, \alpha _ { 1 h } } _ { n _ { h } \text{ times} }, \dots, \underbrace { \alpha _ { 1 K }, \dots, \alpha _ { 1 K } } _ { n _ { K } \text{ times} } ),$$

where n h denotes the membership count of cluster C h . This is because any member of cluster C 1 is connected to the remaining ( n 1 -1) members of its own cluster, all n 2 members of cluster C 2 , and so on.

Generalising for a generic node in cluster C k , k = 1 , . . . , K , we obtain:

$$x _ { i \in C _ { k } } ^ { * } | \mathbf Z \sim D i r ( \underbrace { \alpha _ { k 1 }, \dots, \alpha _ { k 1 } } _ { n _ { k } \text{ times} }, \dots, \underbrace { \alpha _ { k k }, \dots, \alpha _ { k k } } _ { ( n _ { k } - 1 ) \text{ times} }, \dots, \underbrace { \alpha _ { k h }, \dots, \alpha _ { k h } } _ { n _ { k } \text{ times} }, \dots, \underbrace { \alpha _ { k K }, \dots, \alpha _ { k K } } _ { n _ { K } \text{ times} } ).$$

Therefore, all the nodes belonging to the same cluster are identically distributed and share the same Dirichlet distribution, whose parameter vector is determined by the cluster allocations of the remaining nodes. This property of the DirSBM can be seen as a counterpart of stochastic equivalence in other stochastic block models (Lee and Wilkinson, 2019; Nowicki and Snijders, 2001; Snijders and Nowicki, 1997). The nodes in the network are called stochastically equivalent if they have the same probability of being connected by an edge to any other node in the network, conditional on their cluster labels. In weighted SBMs, such as the ones proposed by Aicher et al. (2014) and Ng and Murphy (2021), this leads to identical distributions of edge weights for any pair of nodes i ∈ C k and j ∈ C h as the parameters of such distributions are only determined by the cluster labels of nodes. The DirSBM cannot be said to strictly exhibit stochastic equivalence as it does not model the probability of edge existence between nodes, but it does share the benefits that arise as a consequence of stochastic equivalence as the identical distribution property of a set of edge weights conditional on cluster labels still holds.

## 2.1.1 Interpretation of parameters

The parameters of the Dirichlet distribution in their original form are usually difficult to interpret as they are not measured on the same scale as the compositional data. To relate the parameter values to the original compositions, we can compute the expected proportion sent from any node i ∈ C k to any node j ∈ C h , denoted w kh . In our case, as the parameter values are shared among the pairs of nodes that belong to the same cluster pair, this expected value is given by:

̸

$$w _ { k h } = \mathbb { E } [ X _ { i j } ^ { * } ] = \frac { \alpha _ { k h } } { ( n _ { k } - 1 ) \alpha _ { k k } + \sum _ { g \neq k } n _ { g } \alpha _ { k g } } \quad i \in C _ { k }, j \in C _ { h }.$$

We can use these values to construct a K × K matrix of expected exchange proportions, denoted W , that is more intuitive to interpret than the original Dirichlet parameter matrix A . Note that, although the entries of this matrix are proportions, the rows do not sum to 1, since these proportions are shared among all pairs of nodes with the same cluster labels.

It may also be insightful to learn the expected total shares of exchanges between clusters. To calculate these, we make use of the aggregation property of the Dirichlet distribution, which states that if the parts of the Dirichlet observation are added together, the distribution remains Dirichlet, with the updated parameter values being equal to the sum of the corresponding original values (Frigyik et al., 2010). Using Equation (2), we aggregate the parts from the same cluster pair, resulting in a compositional vector

̸

$$\mathfrak { q } _ { i } | \mathbf Z = \left ( \sum _ { \substack { j \neq i \\ j \in C _ { 1 } } } x _ { i j }, \dots, \sum _ { \substack { j \neq i \\ j \in C _ { k } } } x _ { i j }, \dots \sum _ { \substack { j \neq i \\ j \in C _ { K } } } x _ { i j } \right ) \sim D i r ( n _ { 1 } \alpha _ { k 1 }, \dots, ( n _ { k } - 1 ) \alpha _ { k k }, \dots, n _ { K } \alpha _ { k K } ),$$

̸

̸

for i ∈ C k . Hence, the expected cluster-to-cluster exchange shares, denoted with v kh , are given by:

̸

̸

̸

$$v _ { k h } = \mathbb { E } [ q _ { i l } ] = \begin{cases} \frac { ( n _ { k } - 1 ) \alpha _ { k k } } { ( n _ { k } - 1 ) \alpha _ { k k } + \sum _ { g \neq k } n _ { g } \alpha _ { k g } } & \text{if $h=k$,} \\ \frac { n _ { h } \alpha _ { k h } } { ( n _ { k } - 1 ) \alpha _ { k k } + \sum _ { g \neq k } n _ { g } \alpha _ { k g } } & \text{if $h\neq k$.} \end{cases} \\ \dots \quad \dots \quad \tilde { \ } \quad \tilde { \ } \quad \tilde { \nu } \quad \dots \quad \dots \quad \dots \quad \tilde { \ }.$$

The resulting matrix V = { v kh } K h k, =1 exhibits a unit-row-sum property.

## 3 Inference

The distribution of a set of edge weights X , conditional on the cluster indicator variable is

̸

̸

$$p ( \mathbf X | \mathbf Z ) = \prod _ { i = 1 } ^ { n } p ( \mathbf x _ { i } | \mathbf z _ { i }, \mathbf Z _ { - i } ) = \prod _ { i = 1 } ^ { n } \prod _ { k = 1 } ^ { K } \left [ \frac { \Gamma ( \sum _ { j \neq i } ^ { n } \alpha _ { j } ) } { \prod _ { j \neq i } ^ { n } \Gamma ( \alpha _ { j } ) } \prod _ { j \neq i } ^ { n } x _ { i j } ^ { \alpha _ { j } - 1 } \right ] ^ { z _ { i k } }, \text{ where } \alpha _ { j } = \sum _ { h = 1 } ^ { K } z _ { j h } \alpha _ { k h }.$$

̸

This is a product of probability densities of ( n -1)-dimensional Dirichlet distributions with the respective parameter vectors determined by the cluster label of the sender node i and of the remaining nodes in the network.

As usual in model-based clustering, inference proceeds by maximizing the marginal log-likelihood of the data X with respect to the model parameters. However, this quantity involves summing over the set of all possible cluster allocations and is computationally intractable (Daudin et al., 2008). A popular algorithm used in model-based clustering is the expectation-maximisation (EM) algorithm (Dempster et al., 1977). It is employed to find the maximum of the marginal log-likelihood of the data by introducing latent variables corresponding to cluster labels and defining the joint log-likelihood of the data and the cluster labels, the complete data log-likelihood. Then, inference for the model consists of estimation of parameters and of the latent cluster assignments. The EM algorithm works by iteratively finding the expectation of the complete data log-likelihood with respect to the posterior distribution of the latent variables (E-step) and maximising this expectation with respect to the model parameters (M-step).

In the case of the DirSBM, the complete data log-likelihood is:

̸

$$l _ { c } ( \mathbf A, \theta ) & = \log p ( \mathbf X, \mathbf Z ) \\ & = \sum _ { i = 1 } ^ { n } \sum _ { k = 1 } ^ { K } z _ { i k } \left [ \log \Gamma ( \sum _ { j \neq i } ^ { n } \alpha _ { j } ) - \sum _ { j \neq i } ^ { n } \log \Gamma ( \alpha _ { j } ) + \sum _ { j \neq i } ^ { n } ( \alpha _ { j } - 1 ) \log x _ { i j } \right ] + \sum _ { i = 1 } ^ { n } \sum _ { k = 1 } ^ { K } z _ { i k } \log \theta _ { k }. \\ \text{Further details are provided in Appendix A.}$$

̸

̸

Further details are provided in Appendix A.

In stochastic block modelling, the E-step is often computationally intractable due to the fact that the latent variables are not independent a posteriori. To overcome this problem, the variational EM is often employed for inference in SBMs, which is based on an approximation of the posterior distribution of the latent variables (Daudin et al., 2008).

## 3.1 Hybrid log-likelihood

In the DirSBM, a new challenge arises when trying to employ the variational EM for inference, as it is standard in SBMs. This is due to the fact that, in order to derive the evidence lower bound (Daudin et al., 2008) one is required to compute the expectation:

̸

$$\mathbb { E } _ { \mathbf z \sim q ( \mathbf z ) } \left [ \log \Gamma ( \sum _ { j \neq i } ^ { n } \sum _ { h = 1 } ^ { K } z _ { j h } \alpha _ { k h } ) - \sum _ { j \neq i } ^ { n } \log \Gamma ( \sum _ { h = 1 } ^ { K } z _ { j h } \alpha _ { k h } ) \right ],$$

̸

with respect to q ( Z ), the mean field approximation of the posterior distribution of the latent cluster allocations. This expectation is intractable, because, unlike in standard SBM, even conditional on their cluster labels, the distribution of node i is not independent of that of node j . In fact, due to the model formulation in (5), one needs to know the cluster assignments of all the receiving nodes contained in Z -i to define the distribution of x i given z i .

For this reason, we employ the inferential approach based on a hybrid log-likelihood proposed by Marino and Pandolfi (2022). The approach uses a working independence assumption, whereby each of the latent variables corresponding to the cluster label c i is seen as a function of fixed values of the remaining cluster labels c -i , allowing factorization of the likelihood over the nodes. The observed hybrid log-likelihood, using the notation from (1), is given by

$$l ^ { h y b } ( \mathbf A, \theta ) = \sum _ { i = 1 } ^ { n } \log \left ( \sum _ { k = 1 } ^ { K } \theta _ { k } p ( \mathbf x _ { i } | c _ { i } = k, \mathbf c _ { - i } = \tilde { \mathbf c } _ { - i } ) \right ),$$

where the notation ˜ c -i is employed to indicate the fixed nature of the cluster labels of the remaining ( n -1) nodes in the network when considering the contribution of node i to the log-likelihood.

Introducing the set of latent variables Z , we arrive at the complete data hybrid log-likelihood:

̸

$$l _ { c } ^ { h y b } ( \mathbf A, \theta ) & = \sum _ { i = 1 } ^ { n } \sum _ { k = 1 } ^ { K } z _ { i k } \log p ( \mathbf x _ { i } | z _ { i k } = 1, \mathbf Z _ { - i } = \widetilde { \mathbf Z } _ { - i } ) + \sum _ { i = 1 } ^ { n } \sum _ { k = 1 } ^ { K } z _ { i k } \log \theta _ { k } \\ & = \sum _ { i = 1 } ^ { n } \sum _ { k = 1 } ^ { K } z _ { i k } \left [ \log \Gamma ( \sum _ { j \neq i } ^ { n } \tilde { \alpha } _ { j } ) - \sum _ { j \neq i } ^ { n } \log \Gamma ( \tilde { \alpha } _ { j } ) + \sum _ { j \neq i } ^ { n } ( \tilde { \alpha } _ { j } - 1 ) \log x _ { i j } \right ] + \sum _ { i = 1 } ^ { n } \sum _ { k = 1 } ^ { K } z _ { i k } \log \theta _ { k }, \\ \text{where} \, \widetilde { \mathbf Z } \text{ is a binary matrix with entries } \tilde { z } _ { i k } = 1 \{ \tilde { c } _ { i } = k \} \text{ and } \tilde { \alpha } _ { j } = \sum _ { h = 1 } ^ { K } \tilde { z } _ { j h } \alpha _ { k h }.$$

̸

̸

where ˜ Z is a binary matrix with entries ˜ z ik = ✶ { ˜ c i = k } and ˜ α j = ∑ K h =1 ˜ z jh α kh .

With the complete data hybrid log-likelihood, a working independence assumption allows one to implement a variant of the classification EM algorithm (Celeux and Govaert, 1992), where the hard partition of the nodes that are not i is used to compute the cluster assignment probability for i . The steps of the algorithm are outlined below.

E-step: compute the probability of assignment of node i to cluster k at iteration t using

̸

̸

$$\hat { z } _ { i k } ^ { ( t ) } = \widehat { \Pr } ( z _ { i k } = 1 | { \mathbf x } _ { i }, \widetilde { \mathbf Z } _ { - i } ^ { ( t - 1 ) } ) \, \in \, \hat { \theta } _ { k } ^ { ( t - 1 ) } \frac { \Gamma ( \sum _ { j \neq i } ^ { n } \tilde { \alpha } _ { j } ^ { ( t - 1 ) } ) } { \prod _ { j \neq i } ^ { n } \Gamma ( \tilde { \alpha } _ { j } ^ { ( t - 1 ) } ) } \prod _ { j \neq i } ^ { n } x _ { i j } ^ { \tilde { \alpha } _ { j } ^ { ( t - 1 ) } },$$

̸

with ˜ α ( t -1) j = ∑ K h =1 ˜ z ( t -1) jh ˆ α ( t -1) kh . The quantity on the right hand side is normalised to fulfill the constraint ∑ K k =1 ˆ z ( ) t ik = 1.

C-step: following Marino and Pandolfi (2022), a greedy approach to the C-step is adopted. That is, for each node i = 1 , . . . , n , every label swap is considered and i is assigned to the cluster label producing the highest value of the observed hybrid log-likelihood, i.e.

$$c _ { i } ^ { ( t ) } = \underset { k = 1, \dots, K } { \arg \max } \ \sum _ { l = 1 } ^ { n } \log \left ( \sum _ { h = 1 } ^ { K } \hat { \theta } _ { h } ^ { ( t - 1 ) } p ( { \mathbf x } _ { l } | c _ { l } = k, { \mathbf c } _ { - l } = \tilde { \mathbf c } _ { - l } ) \right ),$$

then c ( ) t and ˜ Z ( ) t are updated. The update of cluster labels happens sequentially for the nodes in the network rather than simultaneously, so any changes in the cluster assignments of nodes before i affect ˜ c -i and hence the cluster label for i .

M-step: maximise the expectation of the complete data hybrid log-likelihood

̸

$$\mathbb { E } [ l _ { c } ^ { h y b } ( \mathbf A, \theta ) ] = & \sum _ { i = 1 } ^ { n } \sum _ { k = 1 } ^ { K } \hat { z } _ { i k } ^ { ( t ) } \left ( \log \Gamma ( \sum _ { j \neq i } ^ { n } \tilde { \alpha } _ { j } ^ { ( t - 1 ) } ) - \sum _ { j \neq i } ^ { n } \log \Gamma ( \tilde { \alpha } _ { j } ^ { ( t - 1 ) } ) + \sum _ { j \neq i } ^ { n } ( \tilde { \alpha } _ { j } ^ { ( t - 1 ) } - 1 ) \log x _ { i j } \right ) \\ & + \sum _ { i = 1 } ^ { n } \sum _ { k = 1 } ^ { K } \hat { z } _ { i k } ^ { ( t ) } \log \hat { \theta } _ { k } ^ { ( t - 1 ) }. \\ \sim \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots.$$

̸

̸

Closed form solution is available for the mixing proportions, so these are updated using

$$\hat { \theta } _ { k } ^ { ( t ) } = \frac { \sum _ { i = 1 } ^ { n } \hat { z } _ { i k } ^ { ( t ) } } { n }.$$

The updates for Dirichlet parameters are not available in closed form, so the set of estimates { ˆ α ( ) t kh } K h k, =1 are found numerically using the R function optim (R Core Team, 2019). Since the parameters of the Dirichlet distribution are strictly positive, we use the L-BFGS-B optimisation routine, which allows for optimization with parameters having a bounded range (Byrd et al., 1995).

The steps above are iterated until the following convergence criterion is met:

$$\left | \frac { l ^ { h y b } ( \hat { \mathbf A } ^ { ( t ) }, \hat { \theta } ^ { ( t ) } ) - l ^ { h y b } ( \hat { \mathbf A } ^ { ( t - 1 ) }, \hat { \theta } ^ { ( t - 1 ) } ) } { l ^ { h y b } ( \hat { \mathbf A } ^ { ( t ) }, \hat { \theta } ^ { ( t ) } ) } \right | < \epsilon.$$

In this work, ϵ = 10 -5 was used. More details on the algorithm can be found in Appendix B.

## 3.2 Identifiability of parameter ordering

The DirSBM exhibits a minor non-idenfitiability issue related to the ordering of clusters and the ordering of parameters. In particular, once we obtain the final node partition and the parameter estimates using the algorithm described in Section 3.1, the ordering of rows of the estimated Dirichlet concentration matrix ˆ A and of the entries of the mixing proportions vector ˆ θ is not guaranteed to match the ordering of clusters in the partition.

To aid understanding, consider an example with

$$\mathbf c = ( 1, 1, 2, 1, 2 ), \, \mathbf A = \begin{pmatrix} \alpha _ { 1 1 } & \alpha _ { 1 2 } \\ \alpha _ { 2 1 } & \alpha _ { 2 2 } \end{pmatrix} \text{ and } \mathbf \theta = ( \theta _ { 1 }, \theta _ { 2 } ).$$

For observation 1, x ∗ 1 ∼ θ Dir α 1 ( 11 , α 12 , α 11 , α 12 )+ θ Dir α 2 ( 21 , α 22 , α 21 , α 22 ). Now, consider the same partition of nodes with the same cluster order and reorder the rows of the parameter matrix A and the entries of θ , i.e.

$$\mathbf c = ( 1, 1, 2, 1, 2 ), \, \mathbf A ^ { \prime } = \begin{pmatrix} \alpha _ { 2 1 } & \alpha _ { 2 2 } \\ \alpha _ { 1 1 } & \alpha _ { 1 2 } \end{pmatrix} = \begin{pmatrix} \alpha ^ { \prime } _ { 1 1 } & \alpha ^ { \prime } _ { 1 2 } \\ \alpha ^ { \prime } _ { 2 1 } & \alpha ^ { \prime } _ { 2 2 } \end{pmatrix} \text{ and } \theta ^ { \prime } = ( \theta _ { 2 }, \theta _ { 1 } ) = ( \theta ^ { \prime } _ { 1 }, \theta ^ { \prime } _ { 2 } ).$$

Then,

$$\mathbf x _ { 1 } ^ { * } & \sim \theta _ { 1 } ^ { \prime } D i r ( \alpha _ { 1 1 } ^ { \prime }, \alpha _ { 1 2 } ^ { \prime }, \alpha _ { 1 1 } ^ { \prime }, \alpha _ { 1 2 } ^ { \prime } ) + \theta _ { 2 } ^ { \prime } D i r ( \alpha _ { 2 1 } ^ { \prime }, \alpha _ { 2 2 } ^ { \prime }, \alpha _ { 2 1 } ^ { \prime }, \alpha _ { 2 2 } ^ { \prime } ) \\ & = \theta _ { 2 } D i r ( \alpha _ { 2 1 }, \alpha _ { 2 2 }, \alpha _ { 2 1 }, \alpha _ { 2 2 } ) + \theta _ { 1 } D i r ( \alpha _ { 1 1 }, \alpha _ { 1 2 }, \alpha _ { 1 1 }, \alpha _ { 1 2 } ),$$

which will clearly give rise to the same likelihood value as the originally ordered parameters.

To address this, we create a hard partition based on probabilities ˆ Z from the E-step and use the order of clusters in this hard partition as reference since column entries of ˆ Z are tied to the individual terms of the Dirichlet mixture. Then we use the matchClasses () function in R ( e 1071 package, Dimitriadou et al., 2009) to match the order of clusters in the E-step to that in the C-step, and use this match to reorder the rows of ˆ A and entries of ˆ at the convergence of the algorithm. θ

## 3.3 Algorithm initialisation

As in most mixture models, extra attention should be paid to the choice of the initialisation strategy since the objective function in question is not unimodal, and the algorithm is only guaranteed to converge to a local optimum (Wu, 1983).

In this paper, we consider the following initialisation strategies, which are compared in the simulation study in Section 5.1:

- · Random: each node is assigned to one of K groups randomly with equal probability. Starting with a random partition of nodes gives us an idea of the performance of the algorithm when no information on the data is used when the initial partition is created. To reduce the risk of convergence to a poor local maximum, we run the algorithm with a number of random starting partitions and select the best based on the value of the observed hybrid log-likelihood. In the simulation study in Section 5.1, we set the number of random starting partitions equal to 5 as we want to strike a balance between performance and computational costs. A larger number of random starting partitions have been tested, providing only a marginal improvement on average, but at a higher computational cost.
- · K-means: the k-means algorithm (Hartigan and Wong, 1979) is repeatedly used to perform clustering on the data matrix X ∗ to reduce the risk of convergence to a local maximum, and the clustering solution of the best run is used as an initial partition. This is a widely used initialisation strategy as it is computationally inexpensive. Since the k-means algorithm itself is initialised at random, we run it 50 times in order to find the initial cluster labels as part of the simulation study.
- · K-means on CLR-transformed data (CLR+K-means): as our data are compositional in nature, the centered log-ratio transformation is first applied to the data matrix X ∗ (Aitchison, 1982), which maps the compositions to the real line, then the k-means algorithm is used in the same fashion as above to find an initial partition (Godichon-Baggioni et al., 2017).
- · Spectral clustering: eigendecomposition of X ∗ is performed and used for dimensionality reduction, then the k-means algorithm is used on the reduced data to get a set of initial cluster labels (von Luxburg, 2007). Spectral clustering is widely used for initialisation as it can handle more complex cluster shapes than k-means itself whilst maintaining low computational costs.
- · Binary SBM (BinSBM): a binary version of the network is created from X by assigning binary edges where the weighted edge exceeds a pre-specified threshold. After empirical investigation, we selected as a threshold the mean weight, as it tends to provide a reasonably well-connected binary network that retains clustering structure. Once such a binary network is created, a Bernoulli stochastic block model is fitted using the R package blockmodels (L´ eger, 2016) and the clustering partition is used to initialise the algorithm.
- · Gaussian SBM (GausSBM): a Gaussian stochastic block model is fitted directly to X using the R package blockmodels (L´ eger, 2016) and the obtained clustering solution is used for initialisation.

## 3.4 Model selection

The modelling approach detailed in Section 2 is only applicable when the number of clusters is set in advance. However, in reality, in many situations the number of clusters is unknown and needs to be inferred from the data. Therefore, a model selection criterion indicating how well models with varying numbers of clusters fit the data is required in order to choose the number of groups appropriately.

One popular choice in stochastic block modelling is the integrated completed likelihood criterion (ICL, Biernacki et al., 2000; Daudin et al., 2008), typically employed for selecting the number of groups in this context; see for example Rastelli and Fop (2020), Ng and Murphy (2021), and El Haj et al. (2022). In the case of DirSBM, the ICL is given by

$$I C L ( K ) = l _ { c } ^ { h y b } ( \hat { \mathbf A }, \hat { \theta } | \mathbf X, \hat { \mathbf Z }, K ) - \frac { 1 } { 2 } K ^ { 2 } \log n ( n - 1 ) - \frac { 1 } { 2 } ( K - 1 ) \log n,$$

where l hyb c ( ˆ A ˆ X ˆ , θ | , Z , K ) is the complete data hybrid log-likelihood from Equation (6), evaluated using parameter estimates at convergence of the algorithm, used in place of the complete data log-likelihood following Marino and Pandolfi (2022). We fit the DirSBM with different numbers of clusters, and compute the respective values of the criterion. The highest ICL value corresponds to the optimal number of groups.

Appendix C contains derivations of the ICL that follow closely the derivations of the original ICL for stochastic block models proposed in Daudin et al. (2008). The simulation study concerning model selection performance using the proposed framework is contained in Section 5.4.

## 4 An alternative approach

As discussed in Section 1, there are two main approaches to working with compositions in compositional data analysis. One involves applying a transformation to the data that maps them to the Euclidean space, followed by the use of standard tools and models for independent data. The second is based on direct modelling of compositions (Alenazi, 2023). The methodology proposed in Section 2 aims to model the compositions directly, but since both approaches have their relative benefits, we propose an alternative that falls under the transformation-based approach, assessing its performance in Section 5.3 for comparative purposes.

We first map the compositions onto the real line using the centered log-ratio (CLR) transformation proposed in Aitchison (1982):

$$\mathbf u _ { i } = C L R ( \mathbf x _ { i } ) = \left ( \log \frac { x _ { i 1 } } { \bar { x } }, \dots, 0, \dots, \log \frac { x _ { i n } } { \bar { x } } \right ),$$

̸

where ¯ = x ( ∏ n j = i x ij ) 1 n -1 is the geometric mean of x , then apply SBM with Gaussian weights (Aicher et al., 2013, 2014) to the transformed data, assuming that each individual edge weight follows

$$u _ { i j } | ( z _ { i k } = 1, z _ { j h } = 1 ) \sim N ( \mu _ { k h }, \sigma ^ { 2 } ).$$

The centered log-ratio transformation has been chosen for its property of preserving the dimensionality of the observations. That is, it maps the Aitchison simplex sample space S n to the standard Euclidean space R n , unlike many other transformations that map to R n -1 (Greenacre, 2021). In this case, each dimension of u i corresponds to a transformed weight of an edge connecting node i to each of the other nodes in the network, so the reduction of dimensionality would require a choice of an edge to be dropped, leading to information loss.

The approach of fitting the Gaussain SBM on CLR-transformed data is implemented using the blockmodels and compositions packages in R (L´ger, 2016; Van den Boogaart and Tolosanae Delgado, 2008), and its clustering performance is assessed alongside the DirSBM in Section 5.3. This approach is a rather strong competitor for the DirSBM proposed in Section 2, in particular in simpler and smaller cases, such as in networks with relatively few nodes with a small number of clusters.

There are two major drawbacks of the alternative approach in comparison to the DirSBM. First of all, the normality assumption in Equation (8) may not be appropriate as the mapping of compositional vectors to the real line (whether by using CLR or any other transformation) only eliminates a unit-sum constraint and does not guarantee convenient distributional behaviour of the resulting transformed data. This means that, in order to utilise this approach, one needs to check

the appropriateness of the transformation and the type of weighted SBM to fit to the transformed data. The DirSBM, on the other hand, is a ready-to-use model that takes into account the unique behaviour of the compositional data as it models them directly. The second disadvantage of the transformation-based approach is interpretability. The parameters of the distribution in Equation (8) (or of any other distribution selected to model the transformed data) refer to the auxiliary Euclidean space, and it is unclear how one could use these to understand the patterns present in the original simplex space. As presented in Section 2.1.1, the parameters of the DirSBM can be used to compute the expected exchange proportions between nodes as well as clusters, making the interpretation of results intuitive.

## 5 Simulation studies

In this section, we consider various simulation studies to assess the performance of our model with respect to clustering, parameter estimation, and model selection. We also investigate the effect of the different initialisation strategies listed in Section 3.3 on the quality of the final inferred clustering of the nodes.

̸

Artificial data are generated according to the DirSBM presented in Section 2. Different numbers of clusters, K = { 2 3 5 , , } , and network sizes, n = { 30 50 70 100 , , , } are considered. The parameter matrices A are defined so that the entries have varying levels of homogeneity, resulting in indirect modifications to the degree of overlap between clusters in the compositions. The term 'level of homogeneity' is used to describe the extent to which the between-cluster weight parameters, i.e. { α kh } h = k , are close to the respective within-cluster weight parameters, α kk . When the values of the between- and the within-cluster parameters are set to be more similar, the resulting compositional weights in the network become more homogeneous, thus making separating the clusters more challenging. On the other hand, the lower the homogeneity, the more separated the clusters. Further details on the parameter values used in the simulation studies can be found in Appendix D.

Throughout this section, where relevant, clustering performance is evaluated using the adjusted Rand Index (ARI, Rand, 1971; Hubert and Arabie, 1985), which measures the agreement between two partitions, adjusted for random chance, by comparing the estimated clustering against the true classification of the nodes.

## 5.1 Choice of initialisation strategy

We consider the different initialisation strategies of Section 3.3 and evaluate the model performance with respect to cluster label recovery on simulated data. We generate 50 networks with n = 50 nodes with 3 similarly-sized clusters and the parameter matrix A is chosen so that the resulting within- and between-cluster edge weights are reasonably, but not excessively, distinct:

$$\mathbf A = \begin{pmatrix} 1. 0 & 0. 7 & 0. 5 \\ 0. 9 & 1. 5 & 0. 6 \\ 0. 4 & 0. 5 & 1. 2 \end{pmatrix}.$$

We initialise the algorithm using the strategies outlined in Section 3.3 and compute the ARI. The results of this simulation study are shown in Figure 1. From the figure, random initialisation seems to work best on average, with a mean ARI of 0 805, despite being the only strategy that . is not informed by the data. It also exhibits relatively low variability in comparison to all but one other strategy, which is k-means on log-ratio transformed data that is clearly inferior, with a mean ARI of only 0 513. Further investigations also reveal that, as well as having the best average . ARI and low variability, random initialisation has led to the highest observed hybrid log-likelihood value in 33 out of 50 instances. Given that the number of random partitions considered was only 5, this result also shows that the proposed algorithm is capable of recovering the clustering patterns fairly successfully even when the initial cluster labels are assigned randomly and are not based on some educated guess.

It may come as a surprise to the reader that out of all the strategies considered, random initialisation performed best, as it gives a starting cluster partition that is completely uninformed. However, there are two aspects of the data modelled by the DirSBM that are worth remembering. Firstly, the data matrix X ∗ introduced in Section 2 is quite unusual in its structure in the sense that the ordering of the dimensions in the compositional edge weight vectors is not fixed and is tied to the index of the sender node. For example, the first entry of observation x ∗ 1 , i.e. x ∗ 11 , refers to the weight of an edge from node 1 to node 2 (as there are no self-loops and so there is no weight

Fig. 1 Adjusted Rand Index (ARI) of DirSBM with different initialisation strategies with mean ARI in blue.

![image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00651v1-figure-a37654bb-b3f9-4857-b787-90462a466279.jpg)

̸

corresponding to an edge from node 1 to itself), whereas, for any other node i = 1, x ∗ i 1 is the edge weight from node i to node 1. The same shift along the dimensions happens across the whole set of compositional weight vectors as we take each node in turn to be the sender. This means that distance-based algorithms, such as k-means, would not necessarily compute the distances between the matching pairs of nodes' edge weights, e.g. the first set of distances for node 1 would involve the edge weight from node 1 to node 2, and for any other node i , it would involve the edge weight from node i to node 1. This can potentially lead to finding spurious clustering patterns, producing initial partitions that result in convergence to local maxima.

The second aspect is the fact that the edges in the networks are not independent, because the weights are defined in terms of compositions. Using initialisation strategies that assume independence between the edge weights, we risk identifying false patterns in the network and getting stuck in a local maximum as a result. For instance, the Gaussian SBM initialisation could give rise to a misleading initial partition as the unit-sum constraint is ignored. With repeated random initialisation, we are less likely to get stuck in one of the local maxima as we can control the exploration of the partition space by changing the number of random starts.

Throughout the simulation studies, we use random initialisation with 5 starts, and to increase the reliability of results for the real world data in sections 6.1 and 6.2 we increase the number of random partitions to 20.

## 5.2 Parameter estimation performance

In this section we examine parameter estimation quality when the number of clusters is known in advance. We consider the cases with 2, 3 and 5 clusters as well as low, medium and high level of parameter homogeneity, as described at the start of Section 5. The size of the networks is also varied to inspect its effect on parameter estimation quality.

The Frobenius distance (Golub and Van Loan, 1996) between the true parameter matrix A and its estimate ˆ A is calculated for 50 synthetic data sets in each scenario, and the results are presented in Figure 2. As expected, larger networks lead to better parameter estimates, showing that the proposed hybrid log-likelihood classification EM leads to consistent parameter estimates as the size of the network increases. Notably, the biggest improvement occurs when we move from n = 30 to n = 50. This comes as no surprise since the performance of the model with regards to the recovery of latent clustering improves significantly when the number of nodes increases from 30 to 50 and above, as seen in Section 5.3. We can also note that higher homogeneity of Dirichlet parameters makes the estimation more challenging as a result of higher difficulty in separating the clusters, and the parameter estimates are closer to their true counterparts when the number of clusters is lower. This is again an expected result, as, when the number of clusters increases, recovering the underlying partition of the nodes is more challenging and each individual parameter is estimated from a smaller share of the data.

![image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00651v1-figure-6b36df2e-d56d-4531-8153-f73a4dcd40c4.jpg)

(c)

K=5

Fig. 2 Frobenius distance between the true parameter matrix A and its estimate ˆ A , based on 50 artificial data sets. The number of clusters K is fixed at the respective true values of (a) 2, (b) 3 and (c) 5.

## 5.3 Clustering structure recovery

To assess the quality of the clustering results, we compare the clustering performance of the following models using the ARI:

## 1. Binary SBM fitted on the binary version of the network (BinSBM):

We test the approach that is often taken in practice where a weighted network is transformed into a binary one. Following closely the description of using binary SBM as an initialisation strategy from Section 3.3, we construct a binary network and fit the Bernoulli SBM using the blockmodels package in R (L´ger, 2016). e

## 2. Naive Gaussian SBM (GausSBM):

We fit SBM with Gaussian edge weights (Aicher et al., 2014) directly to the data. This model is used to test the robustness to whether accounting for the constant-sum constraint on the sender edge weights or not in different scenarios, as similar naive approaches are sometimes implemented in applications.

## 3. Gaussian SBM on log-ratio transformed data (CLR+GausSBM):

The data are mapped onto the real line using a centered log-ratio transformation, then SBM with Gaussian weights is fitted to the transformed data, as described in Section 4.

## 4. DirSBM (DirSBM):

We fit the DirSBM described in Section 2 directly to the data.

Figure 3 illustrates the performance of all 4 models on artificial data sets with 2, 3 and 5 clusters across multiple network sizes and varying levels of Dirichlet parameter homogeneity. Each boxplot

n=30                     n=50                      n=70                      n=100

n=30                     n=50                      n=70                      n=100

n=30                     n=50                      n=70                      n=100

(c)

![image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00651v1-figure-56ce108f-be01-4aaa-8cfe-866501d68db7.jpg)

K=5

Fig. 3 Adjusted Rand Index between the true partition and clustering solutions estimated by binary SBM, Gaussian SBM, Gaussian SBM on centered log-ratio transformed data and DirSBM, with different network sizes and levels of Dirichlet parameters homogeneity. Results are based on 50 artificial data sets with (a) K = 2 , (b) K = 3 and (c) K = 5 clusters.

Table 1 Choice of the number of clusters using integrated completed likelihood (ICL). Results indicate the number of times each number of clusters has been selected by the criterion, based on 50 artificial networks.

| K                  | K       |    |    |    | 3    | 3     | 3   | 5    | 5   | 5   | 5   | 5   |
|--------------------|---------|----|----|----|------|-------|-----|------|-----|-----|-----|-----|
| ˆ K                | ˆ K     |  2 | 3  | 4  | 1    | 2 3   | 4   | 1 2  | 3   | 4   | 5   | 6   |
| Low homogeneity    | n = 30  | 45 | 3  | 1  |      | 3 46  | 1   | 2    | 30  | 18  |     |     |
|                    | n = 50  | 50 |    |    |      | 50    |     |      |     | 10  | 40  |     |
|                    | n = 70  | 48 | 1  | 1  |      | 50    |     |      |     | 1   | 49  |     |
|                    | n = 100 | 45 | 5  |    |      | 50    |     |      |     |     | 45  | 5   |
| Medium homogeneity | n = 30  | 44 | 6  |    |      | 37 13 |     | 1 20 | 27  | 2   |     |     |
|                    | n = 50  | 47 | 3  |    | 10   | 40    |     |      | 3   | 37  | 10  |     |
|                    | n = 70  | 47 | 3  |    |      | 48    | 2   |      |     | 19  | 31  |     |
|                    | n = 100 | 42 | 7  | 1  |      | 49    | 1   |      |     | 2   | 47  | 1   |
| High homogeneity   | n = 30  | 28 | 1  |    | 1 35 | 14    | 9   | 25   | 16  |     |     |     |
|                    | n = 50  | 41 | 8  |    | 15   | 35    |     | 1    | 31  | 18  |     |     |
|                    | n = 70  | 45 | 5  |    | 2    | 47    | 1   |      |     | 40  | 10  |     |
|                    | n = 100 | 46 | 4  |    |      | 49    | 1   |      |     | 7   | 43  |     |

is based on 50 networks. The DirSBM was initialised with 5 random cluster partitions based on the results of the simulation study in Section 5.1.

It is evident that the performance of all models improves with sample size, often approaching an ARI of 1 as we reach 100 nodes. In the case of BinSBM and GausSBM, this can be due to the fact that, in larger networks, the compositional samples are rather high-dimensional, and so the constant-sum constraint does not induce as much dependence between the individual dimensions as in smaller networks, resulting in a good fit of the models that assume independence between the weights. In the case of CLR+GausSBM and DirSBM, the improvement of performance with sample size can be associated with more accurate parameter estimation. Smaller networks present a greater challenge, due to both stronger dependence between the dimensions of compositions and the limited amount of data available for parameter estimation.

The CLR+GausSBM and DirSBM tend to outperform the competitors in terms of clustering structure recovery, and the gap in performance is significantly wider for smaller networks and higher homogeneity of Dirichlet parameters. It is also notable that the performance of BinSBM and the GausSBM on the raw compositional data often exhibits much higher variability indicated by wider boxplots.

With regards to the comparison between the DirSBM and the CLR+GausSBM, the two methods tend to perform similarly well. Looking at Figures 3(b) and 3(c), we observe that in many scenarios the DirSBM performs better and with lower overall variability, making it a more a suitable model in the cases with larger number of clusters in the data. Considering Figure 3(a), where the number of underlying clusters is 2, we note that CLR+GausSBM tends to perform better than DirSBM. Albeit a simplistic approach, CLR+GausSBM seems to present a valid alternative when modelling compositional networks if it is expected that the number of clusters is small.

## 5.4 Model selection performance

We assess the model selection performance using the integrated completed likelihood (ICL) detailed in Section 3.4. Table 1 reports the confusion matrices of the true number of clusters K and the optimal number of clusters ˆ K as selected by ICL.

We observe that ICL is successful in selecting the correct number of clusters in larger networks with any level of parameter homogeneity, which is to be expected provided that both the latent structure recovery and the parameter estimation improve with network size. It is also not surprising that, in smaller networks with higher levels of homogeneity and/or higher numbers of clusters, the model selection becomes a much more complex task, and the number of clusters tends to be underestimated by the ICL. This is due to the fact that in cases with medium and high levels of homogeneity the clusters are much harder to separate, coupled with the difficulty of accurately estimating the parameters in smaller networks, as seen in Sections 5.3 and 5.2 respectively.

## 6 Application to real world network data

## 6.1 Erasmus programme data

The Erasmus programme is the most popular university student exchange programme in Europe, spanning thousands of Higher Education institutions in more than 30 countries. Gad´r et al. (2020) a have produced an extensive data set of student, staff and teacher mobility in the Erasmus network by combining data from a number of different sources.

The aim of our analysis is to understand global mobility patterns in the Erasmus network, focusing on student exchanges. Due to significant differences in the student populations of the European countries, analysis of raw counts of students per pair of countries may not provide particular insights regarding the popularity of destinations, as the biggest countries dominate simply due to their overall hosting capacity.

After aggregating the student numbers to country level for the 2012-2013 academic year, a directed network with countries as nodes and proportions of students as edge weights is constructed, with the proportions summing to 1 for the sending countries. The Erasmus network is very dense ( ≈ 87% of all possible edges are present), and there is no reason to believe that the remaining edges are not allowed to exist since all countries in the Erasmus network are allowed to exchange students. Therefore, instead of treating the edges as truly missing, we assign a value of 0 001 to . the interactions with zero count and treat the network as fully connected. In compositional data analysis, zero values present a great challenge and are an active area of research since standard tools are not designed to handle zero-valued compositional parts (Filzmoser et al., 2018). Replacing zeros by some small value is a standard approach in the case of zero counts that works generally well, especially considering its simplicity. Since in our case 0 001 is added to the original count . data rather than to the compositions themselves, the final results should be robust relative to the magnitude of the added constant.

We implement DirSBM with K ranging from 1 to 6 and use the ICL to select the number of clusters. According to the ICL, the optimal number of clusters is 3 (ICL= 3764), followed by a solution with 5 clusters (ICL= 3718). As the Erasmus network is fairly small (33 nodes), the ICL might underestimate the number of clusters due to the penalty being too strong in the context of small n , as we saw in Section 5.4, therefore we examine the results of both K = 3 and K = 5 cases.

Figure 4(a) illustrates the solution with 3 clusters on a map of Europe, noting the membership of each cluster on the side as smaller countries are difficult to see on the plot. Figure 4(b) represents the total percentage flows between the clusters, based on the estimated matrix ˆ V . The estimate of the parameter matrix A as well as the expected node-to-node and cluster-to-cluster exchange matrices ˆ W and ˆ V from Equations (3) and (4) respectively are provided in Appendix E.

The clustered compositions are reasonably interpretable in a real-world context. The red group seems to dominate the student preference list across all clusters as indicated by high country-wise exchange percentages (12.6, 8.7 and 10 respectively) from the first column of ˆ W , and it consists of Germany, Spain, France, Italy and the UK. The red cluster collectively also notably receives the highest total percentages. The blue cluster can be described as containing countries that are still very popular exchange destinations, but not as popular as the likes of Germany and France, possibly due to their relatively small size or more challenging national language. Although roughly equal percentages of students are expected to be retained by the blue cluster and to be sent to the countries in the red cluster, 41.4% and 43.7% respectively, these shares are split between 11 countries instead of 5, hence each individual country in the blue cluster is expected to receive smaller shares in comparison to countries in the red cluster; for instance, any red cluster country is expected to receive 10% of students from any green cluster country, whereas for blue cluster countries this share is only 3%. The green cluster contains the less popular exchange destinations, such as Bulgaria and Slovakia, as indicated by significantly lower expected country-wise and clusterwise exchange shares. Collectively, the green cluster also retains the least of students, as only 16.8% go on exchange within the cluster itself, while the remaining 83.2% go on exchange to the countries in the red and blue clusters. It can also be noted that the countries in the red cluster are generally closely co-located in geographical terms, as are most countries in the blue cluster, except for Portugal and Turkey, and the countries in the green cluster are more spread out.

The second best solution according to ICL with K = 5 is presented in Figure 5, and the parameter estimates as well as matrices ˆ V and ˆ W are available in Appendix E. The red cluster, now consisting of only Germany, Spain and France, is the cluster of countries receiving the highest percentages of students from the countries of all clusters, ranging between the expected 8.1% to 19.6% per country pair, and the second largest total shares, dominated by the blue cluster by a small margin. It should be noted that the total shares received by the red cluster are only

Fig. 4 Clustering solution for DirSBM with 3 clusters: (a) map of Europe with countries coloured by cluster assignment; (b) chord diagram of total percentage flows between clusters of countries based on ˆ V . On the left, S1, S2 and S3 denote the sending cluster (1, 2 and 3). Percentages departing from the sender sum up to 100. On the right, R1, R2 and R3 denote the receiving cluster (1, 2 and 3).

![image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00651v1-figure-9dd193a1-b816-49c7-8743-5d1dd97ca4e5.jpg)

Fig. 5 Clustering solution for DirSBM with 5 clusters: (a) map of Europe with countries coloured by cluster assignment; (b) chord diagram of total percentage flows between clusters of countries based on ˆ V . On the left, S1-S5 denote the sending cluster (numbered 1 to 5). Percentages departing from the sender sum up to 100. On the right, R1-R5 denote the receiving cluster (numbered 1 to 5).

![image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00651v1-figure-f8489ce4-790c-450e-913a-a787e51e424b.jpg)

split between 3 countries instead of 11 like in the case of the blue cluster. This cluster is also characterised by retaining 39.1% of its students, and sending 43.3% to the blue cluster, implying a lack of diversity of exchange destinations among its students. The blue cluster can be described as containing reasonably popular exchange destinations, but not quite as popular as the red countries, and, similarly to the red cluster, the majority of students go on exchange within the cluster itself (42.2%) or to the red cluster (38.1%). The green cluster, despite consisting of 9 countries (8 Eastern European countries and Cyprus), does not attract large shares of students (total cluster exchange shares are between 2.4% and 10.6%), which may be due to the fact that such countries are less well known exchange destinations. Green countries have a somewhat more diverse preference profile in comparison to the first two clusters, as the parameter estimates are much closer to each other, but there is still a strong preference for the red and blue cluster countries. Purple countries, which are Switzerland, Hungary, Ireland, Norway and Turkey, can be described as medium-preference exchange destinations. They have a strong preference for the red and blue cluster countries, and very limited interest in countries within its own cluster, as well as in green and orange clusters. The orange cluster is the one having the most homogeneous preferences, as indicated by the smallest differences between the parameter estimates, and its countries tend to be among the least popular destinations for exchange. This can possibly be explained by the fact that these countries are either very small, are located very far from the centre of Europe or are not members of the European Union (as of the 2012-2013 academic year). The green, purple and orange clusters retain very small shares or transfers, 14.2%, 2.4% and 5.6% respectively, while the majority of students from these clusters tend to go on exchange to countries in the red and blue clusters. A final observation is that there seems to be a connection between the exchange preferences of Erasmus students and the level of economic development of the hosting country or the prestige of going on exchange to specific destinations. The countries with stronger economies tend to be grouped together and to exhibit higher expected country-to-country exchange proportions, whereas countries with weaker economies or newer members of the programme, such as Turkey and Croatia, tend to be separated from the more established members.

## 6.2 London bike sharing data

We illustrate DirSBM in application to the London bike sharing data from 2014 provided by the Transport for London (2016). We start by counting the number of trips taken between pairs of stations and identifying the busiest stations for our analysis. To do so, we look at the top 100 start and end stations in terms of volume of bikes exchanged and consider their intersection, i.e. the stations that are both among the most popular start and end points of the journey, resulting in an overall network of 85 stations. The trips only between these 85 stations account for over 10% of the total year's trips. The network is very dense, with just under 2% of edges having zero weights, hence, similarly to the Erasmus programme network from Section 6.1, we set the weights of zero-weighted edges equal to 0 001. . We then compute the compositional edge weights by dividing the count weights by the total number of trips taken from the start station.

We fit the DirSBMs with number of clusters between 1 and 8 clusters and select the optimal number of clusters based on the ICL. According to the criterion, the solution with K = 4 is optimal (ICL= 27866), followed by the solution with K = 3 (ICL= 27608). Figure 6 illustrates the solution with 4 clusters on a map of central London (an interactive version of the map is available here) as well as the chord diagram for total exchange proportions between clusters. The Dirichlet parameter matrix estimate ˆ A as well as matrices ˆ V and ˆ W are provided in Appendix F.

Unlike the Erasmus network data presented in Section 6.1, the clustering structure is largely driven by stronger connections within clusters than those between clusters as the diagonal elements of ˆ A tend to be dominant. The clusters are also much more balanced in terms of number of observations, with 24, 15, 26 and 20 stations in the green, blue, red and purple cluster, respectively. There is a geographical component to the clustering structure recovered, in the sense that the clusters are quite compact in space, indicating that more trips take place within the neighbouring areas of the city, and the neighboring clusters tend to exchange larger shares of trips in comparison to more distant ones.

The blue cluster is centered around Hyde Park and Kensington, which has the least geographical spread, and it retains the majority of its flow within the cluster (62.3% of trips), possibly due to the purpose of the journey being recreational cycling. A portion of 23.2% of trips departing from the blue cluster terminate in the neighboring red cluster, and significantly smaller shares arrive to the purple (8.6%) or the green clusters (5.9%). The red cluster contains bike stations around Soho and Covent Garden regions of London that are known for entertainment and shopping, as well as stations near major tourist attractions (such as the British Museum) or large train stations

![image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00651v1-figure-8109455c-09d8-4fdd-bd79-34982f2c2c94.jpg)

(a)

Fig. 6 Clustering solution for DirSBM with 4 clusters, as selected by ICL, on London bike sharing data: (a) map of Central London with bike stations coloured by cluster assignment. Image created using Google My Maps software, with the interactive map available here; (b) chord diagram of total percentage flows between clusters of stations based on ˆ V . On the left, S1-S4 denote the sending cluster (numbered 1 to 4). Percentages departing from the sender sum up to 100. On the right, R1-R4 denote the receiving cluster (numbered 1 to 4).

![image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00651v1-figure-56953c86-f962-4781-a566-0551f4adb981.jpg)

(e.g. Euston station and King's Cross station). A significant 46.4% of trips take place within the cluster, and the green cluster receives the least trips starting from the red cluster, possibly due to the geographical distance between the two. The green and the purple clusters have strong connections with each other, exchanging 41.1% and 23.2% of their trips (in comparison to retaining 36.5% and 34.9% respectively), which can be due to the concentration of corporate buildings in this region of London and the employees living within cycling distance of their workplaces. Neither cluster is well connected to the blue cluster, likely due to the distance and availability of faster public transport options as well as the purpose of travel. A proportion of 34.3% of trips from stations in a purple cluster arrive in the red cluster, whilst 21.6% travel in the opposite direction. In summary, the clusters detected by DirSBM by modelling the proportions of transfers between the stations are interpretable in terms of geographical locations and neighbourhoods of London.

## 7 Discussion

In this paper, we have introduced DirSBM, an extension of the stochastic block model to directed weighted networks with compositional edge weights that is based on direct modelling of compositional weights vectors using the Dirichlet distribution. To the best of our knowledge, no counterparts currently exist in the literature, making the proposed clustering methodology the first of its kind. We have developed an inferential procedure based on a variant of the classification expectation-maximisation algorithm for hybrid likelihood. Model selection is addressed using the integrated completed likelihood criterion. We have also proposed an alternative framework for clustering for composition-weighted networks via a log-ratio transformation of the data and subsequent application of the existing weighted SBM to the transformed data. In the simulation studies, we have shown the effectiveness of DirSBM in terms of parameter estimation and recovery of the clustering structure in a variety of settings, and have explored the use of ICL for model selection, which has proven to work reasonably well. The code implementing the modelling framework in R can be found on GitHub.

The modelling approach can be extended in multiple directions. One important extension to the DirSBM is introducing structural zeros, to enable the ability to model the absence of guaranteed edges in the network. One could use the idea from Tsagris and Stewart (2018) that concerns Dirichlet regression with zeros, where indicators are used to 'discard' zero entries of compositional vectors and subsequently fit the model to the non-zero subset of compositional data. As well as making the model more realistic and applicable to a wider range of real world data, such an extension could lead to numerically more stable performance, since the dimension of the Dirichlet observations would not scale with the number of nodes.

The use of the centered log-ratio transformation approach presented in Section 4 has been shown to be a simple valid alternative to the DirSBM in simple scenarios with few clusters in small networks. With regards to this approach, transformations other than the centered logratio could be explored as well as other weighted SBMs. As for the incorporation of structural zeros, it is unclear how one could include such information in this methodology as the edges are treated as independent and the respective parameters of the distribution are estimated in the Euclidean space (Filzmoser et al., 2018, Chapter 13.5). This implies that even if two nodes have similar weights in a compositional sense, the absence of edges for one of them can lead to assignment to different clusters, because the absent edges would make them appear more different than they actually are when mapped to the Euclidean space. To give a simple illustrative example, suppose we have two compositions, x 1 = (0 2 0 5 0 28 0 01 0 01) . , . , . , . , . and x 2 = (0 2 0 5 0 3 0 0), . , . , . , , and let the zero values be structural zeros, i.e. indicating a missing edge in the network. Then, applying the centered log-ratio transformation, u 1 = clr ( x 1 ) = (0 95 . , 1 86 . , 1 28 . , -2 05 . , -2 05) and . u 2 = clr ( x 2 ) = ( -0 44 . , 0 48 . , -0 035 0 0) (using the convention log 0 = 0), a false impression is . , , created that the compositions are quite different.

Other developments could include investigating more educated and efficient initialisation strategies for the proposed algorithm. Although random initialisation allows to explore the solution space rather well by considering the most diverse set of starting points, thus reducing the risk of convergence to a local maximum, it does so at a computational cost. This cost could potentially be reduced if the algorithm was to be run from fewer, or ideally a single, more informed initial clustering allocation set. Other distributions for compositional data could be considered to model the sets of proportional edge weights in the network, such as the generalised Dirichlet distribution, which would be less restrictive on the compositional variance (Connor and Mosimann, 1969).

## A Complete data log-likelihood

Recall that given the binary matrix of cluster allocations Z , the compositional data X has the following probability density:

̸

̸

$$p ( \mathbf X | \mathbf Z ) = \prod _ { i = 1 } ^ { n } p ( \mathbf x _ { i } | \mathbf z _ { i }, \mathbf Z _ { - i } ) = \prod _ { i = 1 } ^ { n } \prod _ { k = 1 } ^ { K } \left [ \frac { \Gamma ( \sum _ { j \neq i } ^ { n } \alpha _ { j } ) } { \prod _ { j \neq i } ^ { n } \Gamma ( \alpha _ { j } ) } \prod _ { j \neq i } ^ { n } x _ { i j } ^ { \alpha _ { j - 1 } } \right ] ^ { z _ { i k } }, \text{where } \alpha _ { j } = \sum _ { h = 1 } ^ { K } z _ { j h } \alpha _ { k h }.$$

̸

The latent variables have probability distribution:

$$p ( { \mathbf z } _ { i } ) = \prod _ { k = 1 } ^ { K } \theta _ { k } ^ { z _ { i k } }.$$

This results in the following complete data likelihood:

̸

̸

$$\mathcal { L } _ { c } ( \mathbf A, \theta ) = \prod _ { i = 1 } ^ { n } \prod _ { k = 1 } ^ { K } p ( x _ { i }, \mathbf z _ { i }, \mathbf Z _ { - i } ) = \prod _ { i = 1 } ^ { n } \prod _ { k = 1 } ^ { K } \left [ \theta _ { k } \frac { \Gamma ( \sum _ { j \neq i } ^ { n } \alpha _ { j } ) } { \prod _ { j \neq i } ^ { n } \Gamma ( \alpha _ { j } ) } \prod _ { j \neq i } ^ { n } x _ { i j } ^ { \alpha _ { j } - 1 } \right ] ^ { z _ { i k } }.$$

̸

Taking the natural logarithm of Equation (9), we arrive at the expression for the complete data log-likelihood from Equation (5).

## B Classification EM with hybrid log-likelihood

The expectation of the complete data hybrid log-likelihood with respect to a single latent variable z i is given by:

̸

$$& \mathbb { E } [ l _ { c } ^ { h y b } ( \mathbf A, \theta ) ] \\ & = \sum _ { i = 1 } ^ { n } \sum _ { k = 1 } ^ { K } \mathbb { E } [ z _ { i k } ] \left ( \log \Gamma ( \sum _ { j \neq i } ^ { n } \tilde { \alpha } _ { j } ) - \sum _ { j \neq i } ^ { n } \log \Gamma ( \tilde { \alpha } _ { j } ) + \sum _ { j \neq i } ^ { n } ( \tilde { \alpha } _ { j } - 1 ) \log x _ { i j } \right ) + \sum _ { i = 1 } ^ { n } \sum _ { k = 1 } ^ { K } \mathbb { E } [ z _ { i k } ] \log \theta _ { k },$$

̸

̸

with ˜ α j = ∑ K h =1 ˜ z jh α kh , where ˜ z jh is the fixed cluster indicator ˜ z jk = ✶ { ˜ c j = k } . The E-step can be found in standard EM fashion by using the Bayes rule:

̸

̸

$$E _ { \text{-step can be found in standard EM fashion by using the Bayes rule:} } \\ \hat { z } _ { i k } = \widehat { \Pr } ( z _ { i k } = 1 | x _ { i }, \widetilde { Z } _ { - i } ) & = \frac { p ( z _ { i k } = 1 | \widetilde { Z } _ { - i } ) p ( x _ { i } | z _ { i k } = 1, \widetilde { Z } _ { - i } ) } { p ( x _ { i } | \widetilde { Z } _ { - i } ) } \\ & = \frac { p ( z _ { i k } = 1 ) p ( x _ { i } | z _ { i k } = 1, \widetilde { Z } _ { - i } ) } { \sum _ { h } p ( z _ { i h } = 1 ) p ( x _ { i } | z _ { i h } = 1, \widetilde { Z } _ { - i } ) } \\ & \infty p ( z _ { i k } = 1 ) p ( x _ { i } | z _ { i k } = 1, \widetilde { Z } _ { - i } ) \\ & = \theta _ { k } \prod _ { j \neq i } ^ { n } x _ { i j } \frac { \Gamma ( \sum _ { j \neq i } ^ { n } \tilde { \alpha } _ { j } ) } { \prod _ { j \neq i } ^ { n } \Gamma ( \tilde { \alpha } _ { j } ) }, \\ = 1 | \widetilde { Z } _ { - i } ) = p ( z _ { i k } = 1 ) \, \text{due to the working independence assumption.}$$

̸

as p z ( ik = 1 | ˜ Z -i ) = p z ( ik = 1) due to the working independence assumption.

The M-step involves finding the estimates for the mixing proportions θ = ( θ , ..., θ 1 K ) and the Dirichlet connectivity matrix A . The closed form solution for the mixing proportions is derived similarly to that in the standard EM algorithm by maximising E [ l hyb c ( A , θ )], subject to constraint ∑ k θ k = 1. Let

$$f = \mathbb { E } [ l _ { c } ^ { h y b } ( \mathbf A, \theta ) ] - \lambda ( \sum _ { k = 1 } ^ { K } \theta _ { k } - 1 ).$$

The partial derivative of f with respect to θ k is

$$\frac { 1 } { \theta _ { k } } \sum _ { i = 1 } ^ { n } \hat { z } _ { i k } - \lambda = 0,$$

which gives λθ k = ∑ n i =1 ˆ z ik . Summing over k and using the unit-sum constraint for ( θ , ..., θ 1 K ), we find that λ = n , producing the update for the mixing proportions from Equation (7).

The updates for the Dirichlet concentration parameter matrix A are not available in closed form and so are found numerically using the R function optim (R Core Team, 2019). L-BFGS-B optimisation procedure (Byrd et al., 1995) is used to update the set of parameters { α kh } K h k, =1 as it allows a permitted range of values to be set; in the case of DirSBM, we are only interested in strictly positive solutions.

## C Integrated completed likelihood

Following Biernacki et al. (2000), the exact complete-data integrated log-likelihood is given by

$$\log p ( { \mathbf X }, { \mathbf Z } | K ) = \log p ( { \mathbf X } | { \mathbf Z }, K ) + \log p ( { \mathbf Z } | K ).$$

Following closely the derivations of the ICL for random graphs in Daudin et al. (2008), we can find the first term of Equation (10) using a BIC approximation:

$$\log p ( \mathbf X | \mathbf Z, K ) = \max _ { \mathbf A } \log p ( \mathbf X | \mathbf Z, \mathbf A, K ) - \frac { 1 } { 2 } K ^ { 2 } \log n ( n - 1 ),$$

where K 2 is the number of parameters in the model (elements of non-symmetric A matrix), and n n ( -1) is the number of edge weights in the network (with no self-loops).

The second term of Equation (10) is derived in the same fashion as in Daudin et al. (2008), using a non-informative Jeffrey prior and Stirling formula for an approximation of a Gamma function, leading to

$$\log p ( \mathbf Z | K ) = \max _ { \theta } \log p ( \mathbf Z | \theta, K ) - \frac { 1 } { 2 } ( K - 1 ) \log n,$$

with ( K -1) being the number of free parameters in θ and n being the number of latent variables in the model.

Substituting the approximation results back and then replacing the complete data log-likelihood with its hybrid counterpart in the fashion of Marino and Pandolfi (2022), we arrive at

$$\L _ { c } ^ { \cdot } \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \, - \
 \text{LCL} ( K ) & = \log p ( \mathbf X | \tilde { \mathbf Z }, \hat { \mathbf A }, K ) - \frac { 1 } { 2 } K ^ { 2 } \log n ( n - 1 ) + \log p ( \tilde { \mathbf Z } | \hat { \mathbf \theta }, K ) - \frac { 1 } { 2 } K ^ { 2 } \log n ( n - 1 ) - \frac { 1 } { 2 } ( K - 1 ) \log n \\ & = \lq _ { c } ^ { h y b } ( \hat { \mathbf A }, \hat { \mathbf \theta } | \mathbf X, \hat { \mathbf Z }, K ) - \frac { 1 } { 2 } K ^ { 2 } \log n ( n - 1 ) - \frac { 1 } { 2 } ( K - 1 ) \log n.$$

## D Simulation studies: additional notes

Parameters used to generate data sets with different levels of parameter homogeneity, low, medium and high, denoted with subscripts L M , and H , respectively:

K = 2

$$\mathbf A _ { L } = \begin{pmatrix} 1. 0 & 0. 6 \\ 0. 8 & 1. 5 \end{pmatrix}, \mathbf A _ { M } = \begin{pmatrix} 1. 0 & 0. 6 \\ 0. 9 & 1. 4 \end{pmatrix}, \mathbf A _ { H } = \begin{pmatrix} 1. 0 & 0. 8 \\ 0. 9 & 1. 5 \end{pmatrix} ;$$

K = 3

K = 5

$$\mathbf A _ { L } = \begin{pmatrix} 1. 0 & 0. 6 & 0. 2 \\ 0. 6 & 1. 5 & 0. 5 \\ 0. 3 & 0. 4 & 1. 2 \end{pmatrix}, \mathbf A _ { M } = \begin{pmatrix} 1. 0 & 0. 7 & 0. 5 \\ 0. 9 & 1. 5 & 0. 6 \\ 0. 4 & 0. 5 & 1. 2 \end{pmatrix}, \mathbf A _ { H } = \begin{pmatrix} 1. 0 & 0. 7 & 0. 5 \\ 0. 9 & 1. 3 & 0. 7 \\ 0. 6 & 0. 5 & 1. 2 \end{pmatrix} ;$$

$$K = 5 \, \begin{pmatrix} 1. 0 & 0. 6 & 0. 2 & 0. 3 & 0. 5 \\ 0. 6 & 1. 5 & 0. 5 & 0. 4 & 0. 7 \\ 0. 3 & 0. 4 & 1. 2 & 0. 5 & 0. 2 \\ 0. 7 & 0. 5 & 0. 3 & 1. 4 & 0. 4 \\ 0. 5 & 0. 7 & 0. 8 & 0. 6 & 1. 7 \end{pmatrix}, \, \begin{pmatrix} 1. 0 & 0. 7 & 0. 5 & 0. 4 & 0. 6 \\ 0. 9 & 1. 5 & 0. 6 & 0. 5 & 0. 7 \\ 0. 4 & 0. 5 & 1. 2 & 0. 6 & 0. 3 \\ 0. 8 & 0. 6 & 0. 4 & 1. 4 & 0. 5 \\ 0. 5 & 0. 8 & 0. 9 & 0. 7 & 1. 7 \end{pmatrix},$$

$$\mathbf A _ { H } = \begin{pmatrix} 1. 0 & 0. 7 & 0. 5 & 0. 4 & 0. 6 \\ 0. 9 & 1. 3 & 0. 7 & 0. 5 & 0. 8 \\ 0. 6 & 0. 7 & 1. 2 & 0. 8 & 0. 5 \\ 0. 8 & 0. 6 & 0. 4 & 1. 4 & 0. 7 \\ 0. 7 & 0. 8 & 0. 9 & 0. 6 & 1. 6 \end{pmatrix}.$$

The parameter values are constrained to be positive, but some care is needed when the parameter matrices for synthetic data sets are chosen if the intention is to use such data for model testing. Due to specification of the model based on the Dirichlet distribution whose dimensions grow with the size of the network, they cannot be too large, especially in the case of large number of nodes. The expression for the complete data hybrid log-likelihood involves a Gamma function term evaluated at the sum of all parameter values, and large parameters cause it to become too large to compute. The parameters also cannot be too close to 0 as we are required to evaluate the Gamma function at each individual parameter value.

## E Erasmus programme data: parameter estimates

## E.1 K=3

The estimate of the Dirichlet parameter matrix A of the 3-cluster DirSBM on the Erasmus programme data is

$$\hat { \mathbf A } = \begin{pmatrix} 7. 0 1 9 & 1. 8 9 3 & 0. 4 1 0 \\ 5. 3 2 5 & 2. 5 2 1 & 0. 5 3 5 \\ 1. 3 4 7 & 0. 4 1 0 & 0. 1 4 2 \end{pmatrix}.$$

The expected total cluster-to-cluster exchange share and the expected node-to-node exchange share matrices are (multiplied by 100 for convenience):

$$\hat { \mathbf V } = \begin{pmatrix} 5 0. 3 & 3 7. 3 & 1 2. 5 \\ 4 3. 7 & 4 1. 4 & 1 4. 9 \\ 4 9. 8 & 3 3. 4 & 1 6. 8 \end{pmatrix}, \quad \hat { \mathbf W } = \begin{pmatrix} 1 2. 6 & 3. 4 & 0. 7 \\ 8. 7 & 4. 1 & 0. 9 \\ 1 0. 0 & 3. 0 & 1. 1 \end{pmatrix}.$$

The rows of these matrices correspond to the sending clusters, and the receiving clusters are along the columns. To give an example in the context of the Erasmus programme network, the entry ˆ v 12 = 37 3 indicates that 37.3% of students of cluster 1 collectively (which contains Germany, . Spain, France, Italy and the UK) go on exchange to cluster 2 collectively (which includes countries like Austria and Belgium). The entry ˆ w 31 = 10 0 can be read as 10.0% of Irish students (cluster . 3) are expected to go to Germany (cluster 1), and the same percentage is expected to go from Norway (cluster 3) to Spain (cluster 1).

## E.2 K=5

Similarly, for the K = 5 solution,

$$\hat { \mathbf A } = \begin{pmatrix} 1 1. 0 0 4 & 2. 2 1 4 & 0. 3 2 3 & 1. 1 8 9 & 0. 2 1 3 \\ 1 2. 1 9 7 & 4. 0 5 7 & 0. 8 4 7 & 1. 9 8 4 & 0. 2 8 2 \\ 5. 5 3 9 & 3. 0 8 3 & 1. 1 7 4 & 0. 9 5 9 & 0. 3 0 1 \\ 3. 0 3 5 & 1. 2 9 8 & 0. 2 3 1 & 0. 1 5 8 & 0. 1 0 5 \\ 0. 6 3 0 & 0. 3 2 3 & 0. 1 2 4 & 0. 1 5 5 & 0. 1 0 8 \end{pmatrix}.$$

and

$$\hat { V } = \begin{pmatrix} 3 9. 1 & 4 3. 3 & 5. 2 & 1 0. 6 & 1. 9 \\ 3 8. 1 & 4 2. 2 & 7. 9 & 1 0. 3 & 1. 5 \\ 2 5. 1 & 5 1. 2 & 1 4. 2 & 7. 2 & 2. 3 \\ 3 4. 2 & 5 3. 6 & 7. 8 & 2. 4 & 2. 0 \\ 2 4. 3 & 4 5. 8 & 1 4. 4 & 1 0. 0 & 5. 6 \end{pmatrix}, \ \hat { W } = \begin{pmatrix} 1 9. 6 & 3. 9 & 0. 6 & 2. 1 & 0. 4 \\ 1 2. 7 & 4. 2 & 0. 9 & 2. 1 & 0. 3 \\ 8. 4 & 4. 7 & 1. 8 & 1. 4 & 0. 5 \\ 1 1. 4 & 4. 9 & 0. 9 & 0. 6 & 0. 4 \\ 8. 1 & 4. 2 & 1. 6 & 2. 0 & 1. 4 \end{pmatrix}.$$

## F Bike sharing data: parameter estimates

Dirichlet parameter matrix A estimate of the 4-cluster DirSBM on the bike sharing data is

$$\hat { \mathbf A } = \begin{pmatrix} 1. 5 8 & 0. 2 5 & 0. 7 1 & 2. 0 4 \\ 0. 2 2 & 3. 9 6 & 0. 7 9 & 0. 3 8 \\ 0. 6 1 & 1. 5 1 & 2. 1 6 & 1. 2 6 \\ 1. 2 3 & 0. 6 4 & 1. 6 7 & 2. 3 3 \end{pmatrix}, \\. \quad. \quad. \quad. \quad. \quad. \quad.$$

and the expected cluster-to-cluster exchange shares and station-to-station exchange shares matrices are

$$\hat { V } = \begin{pmatrix} 3 6. 5 & 3. 7 & 1 8. 7 & 4 1. 1 \\ 5. 9 & 6 2. 3 & 2 3. 2 & 8. 6 \\ 1 2. 6 & 1 9. 4 & 4 6. 4 & 2 1. 6 \\ 2 3. 2 & 7. 6 & 3 4. 3 & 3 4. 9 \end{pmatrix}, \ \hat { W } = \begin{pmatrix} 1. 6 & 0. 2 & 0. 7 & 2. 1 \\ 0. 2 & 4. 5 & 0. 9 & 0. 4 \\ 0. 5 & 1. 3 & 1. 9 & 1. 1 \\ 1. 0 & 0. 5 & 1. 3 & 1. 8 \end{pmatrix}.$$

## References

| Aicher, C., Jacobs, A. Z., and Clauset, A. (2013). Adapting the stochastic block model to edge- weighted networks. https://doi.org/10.48550/arXiv.1305.5782 .                                                                                                     |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Aicher, C., Jacobs, A. Z., and Clauset, A. (2014). Learning latent block structure in weighted networks. Journal of Complex Networks , 3(2):221-248.                                                                                                              |
| Aitchison, J. (1982). The statistical analysis of compositional data. Journal of the Royal Statistical Society: Series B (Methodological) , 44(2):139-160.                                                                                                        |
| Aitchison, J. (1986). The statistical analysis of compositional data . Chapman & Hall, Ltd., GBR.                                                                                                                                                                 |
| Alenazi, A. (2023). A review of compositional data analysis and recent advances. Communications in Statistics - Theory & Methods , 52(16):5535-5567.                                                                                                              |
| Baxter, M. J. (1995). Standardization and transformation in principal component analysis, with applications to archaeometry. Journal of the Royal Statistical Society. Series C (Applied Statis- tics) , 44(4):513-527.                                           |
| Biernacki, C., Celeux, G., and Govaert, G. (2000). Assessing a mixture model for clustering with the integrated completed likelihood. IEEE Transactions on Pattern Analysis and Machine Intelligence , 22(7):719-725.                                             |
| Bouveyron, C., Celeux, G., Murphy, T. B., and Raftery, A. E. (2019). Model-Based Clustering and Classification for Data Science: with Applications in R . Cambridge Series in Statistical and Probabilistic Mathematics. Cambridge University Press.              |
| Byrd, R. H., Lu, P., Nocedal, J., and Zhu, C. (1995). A limited memory algorithm for bound constrained optimization. SIAM Journal on Scientific Computing , 16:1190-1208.                                                                                         |
| Celeux, G. and Govaert, G. (1992). A classification EM algorithm for clustering and two stochastic versions. Computational Statistics & Data Analysis , 14(3):315-332.                                                                                            |
| Clauset, A., Newman, M., and Moore, C. (2005). Finding community structure in very large networks. Physical Review E, Statistical, Nonlinear, and Soft Matter Physics , 70:066111.                                                                                |
| Connor, R. J. and Mosimann, J. E. (1969). Concepts of independence for proportions with a generalization of the Dirichlet distribution. Journal of the American Statistical Association , 64(325):194-206.                                                        |
| Daudin, J. J. (2011). A review of statistical models for clustering networks with an application to a PPI network. Journal de la Societe Fran¸aise c de Statistique , 152(2):111-125.                                                                             |
| Daudin, J. J., Picard, F., and Robin, S. (2008). A mixture model for random graphs. Statistics & Computing , 18:173-183.                                                                                                                                          |
| Dempster, A. P., Laird, N. M., and Rubin, D. B. (1977). Maximum likelihood from incomplete data via the EM algorithm. Journal of the Royal Statistical Society. Series B (Methodological) , 39(1):1-38.                                                           |
| Dimitriadou, E., Hornik, K., Leisch, F., Meyer, D., and Weingessel, A. (2009). E1071: Misc functions of the department of statistics (e1071), tu wien. R package version 1.5-24 .                                                                                 |
| El Haj, A., Slaoui, Y., Louis, P.-Y., and Khraibani, Z. (2022). Estimation in a binomial stochastic blockmodel for a weighted graph by a variational expectation maximization algorithm. Commu- nication in Statistics - Simulation & Computation , 51:4450-4469. |
| Filzmoser, P., Hron, K., and Templ, M. (2018). Applied Compositional Data Analysis. With Worked Examples in R . Springer Series in Statistics. Springer.                                                                                                          |
| Frigyik, A. B., Kapila, A., and Gupta, M. R. (2010). Introduction to the Dirichlet distribution and related processes. https://api.semanticscholar.org/CorpusID:8763665 .                                                                                         |
| Gad´r, a L., Koszty´n, a Z., Telcs, A., and Abonyi, J. (2020). A multilayer and spatial description of the Erasmus mobility network. Scientific Data , 7.                                                                                                         |

| Godichon-Baggioni, A., Maugis-Rabusseau, C., and Rau, A. (2017). Clustering transformed com- positional data using k-means, with applications in gene expression and bicycle sharing system data. Journal of Applied Statistics , 46.   |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Golub, G. H. and Van Loan, C. F. (1996). Matrix computations . Johns Hopkins University Press, USA, 3 edition.                                                                                                                          |
| Greenacre, M. (2021). Compositional data analysis. Annual Review of Statistics & its Applications , 8(1):271-299.                                                                                                                       |
| Guimer`, a R., Stouffer, D. B., Sales-Pardo, M., Leicht, E. A., Newman, M. E. J., and Amaral, L. A. N. (2010). Origin of compartmentalization in food webs. Ecology , 91(10):2941-2951.                                                 |
| Ha, M. J., Kim, J., Galloway-Pe˜a, n J., Do, K.-A., and Peterson, C. B. (2020). Compositional zero-inflated network estimation for microbiome data. BMC Bioinformatics , 21:1-20.                                                       |
| Hartigan, J. A. and Wong, M. A. (1979). Algorithm AS 136: A k-means clustering algorithm. Journal of the Royal Statistical Society. Series C (Applied Statistics) , 28(1):100-108.                                                      |
| Hledik, J. and Rastelli, R. (2023). A dynamic network model to measure exposure concentration in the Austrian interbank market. Statistical Methods & Applications .                                                                    |
| Holland, P. W., Laskey, K. B., and Leinhardt, S. (1983). Stochastic blockmodels: first steps. Social Networks , 5(2):109-137.                                                                                                           |
| Hubert, L. J. and Arabie, P. (1985). Comparing partitions. Journal of Classification , 2:193-218.                                                                                                                                       |
| Karrer, B. and Newman, M. E. J. (2011). Stochastic blockmodels and community structure in networks. Physical Review E , 83:016107.                                                                                                      |
| Lee, C. and Wilkinson, D. J. (2019). A review of stochastic block models and extensions for graph clustering. Applied Network Science , 4(1).                                                                                           |
| L´ger, e J.-B. (2016). Blockmodels: A R-package for estimating in latent block model and stochastic block model, with various probability functions, with or without covariates. https://doi.org/ 10.48550/arXiv.1602.07587 .           |
| Leger, J.-B., Vacher, C., and Daudin, J. J. (2013). Detection of structurally homogeneous subsets in graphs. Statistics & Computing , 24.                                                                                               |
| Ludkin, M. (2020). Inference for a generalised stochastic block model with unknown number of blocks and non-conjugate edge models. Computational Statistics & Data Analysis , 152:107051.                                               |
| Mariadassou, M., Robin, S., and Vacher, C. (2010). Uncovering latent structure in valued graphs: a variational approach. The Annals of Applied Statistics , 4.                                                                          |
| Marino, M. F. and Pandolfi, S. (2022). Hybrid maximum likelihood inference for stochastic block models. Computational Statistics & Data Analysis , 171:107449.                                                                          |
| Melnykov, V., Sarkar, S., and Melnykov, Y. (2020). On finite mixture modeling and model-based clustering of directed weighted multilayer networks. Pattern Recognition , 112:107641.                                                    |
| Ng, T. L. J. and Murphy, T. B. (2021). Weighted stochastic block model. Statistical Methods & Applications , 30(5):1365-1398.                                                                                                           |
| Nowicki, K. and Snijders, T. A. B. (2001). Estimation and prediction for stochastic block structures. Journal of the American Statistical Association , 96(455):1077-1087.                                                              |
| Pal, S. and Heumann, C. (2022). Clustering compositional data using dirichlet mixture model. PLOS ONE , 17(5):1-24.                                                                                                                     |
| Pons, P. and Latapy, M. (2006). Computing communities in large networks using random walks. Journal of Graph Algorithms & Applications , 10:191-218.                                                                                    |
| R Core Team (2019). R: A Language and Environment for Statistical Computing . R Foundation for Statistical Computing.                                                                                                                   |
| Rand, W. M. (1971). Objective criteria for the evaluation of clustering methods. Journal of the American Statistical Association , 66(336):846-850.                                                                                     |

| Rastelli, R. and Fop, M. (2020). A stochastic block model for interaction lengths. Advances in Data Analysis & Classification , 14.                                                                |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Salter-Townshend, M., White, A., Gollini, I., and Murphy, T. B. (2012). Review of statistical network analysis: models, algorithms, and software. Statistical Analysis & Data Mining , 5:243- 264. |
| Snijders, T. A. and Nowicki, K. (1997). Estimation and prediction for stochastic blockmodels for graphs with latent block structure. Journal of Classification , 14(1):75-100.                     |
| Transport for London (2016). https://cycling.data.tfl.gov.uk .                                                                                                                                     |
| Tsagris, M. and Stewart, C. (2018). A Dirichlet regression model for compositional data with zeros. Lobachevskii Journal of Mathematics , 39:398-412.                                              |
| Van den Boogaart, K. and Tolosana-Delgado, R. (2008). 'compositions': a unified R package to analyze compositional data. Computers & Geosciences , 34:320-338.                                     |
| von Luxburg, U. (2007). A tutorial on spectral clustering. Statistics & Computing , 17(4):395-416.                                                                                                 |
| Wang, Y. J. and Wong, G. Y. C. (1987). Stochastic Blockmodels for Directed Graphs. Journal of the American Statistical Association , 82:8-19.                                                      |
| Wasserman, S. and Anderson, C. (1987). Stochastic a posteriori blockmodels: construction and assessment. Social Networks , 9(1):1-36.                                                              |
| Wu, C. F. J. (1983). On the Convergence Properties of the EMAlgorithm. The Annals of Statistics , 11(1):95 - 103.                                                                                  |
| Yuan, H., He, S., and Deng, M. (2019). Compositional data network analysis via lasso penalized D-trace loss. Bioinformatics , 35(18):3404-3411.                                                    |
| Zanghi, H., Picard, F., Miele, V., and Ambroise, C. (2010). Strategies for online inference of model-based clustering in large and growing networks. The Annals of Applied Statistics , 4(2).      |
Iuliia Promskaia Adrian O'Hagan Michael Fop
A Dirichlet stochastic block model for composition-weighted networks
Network data are observed in various applications where the individual
entities of the system interact with or are connected to each other, and often
these interactions are defined by their associated strength or importance.
Clustering is a common task in network analysis that involves finding groups of
nodes displaying similarities in the way they interact with the rest of the
network. However, most clustering methods use the strengths of connections
between entities in their original form, ignoring the possible differences in
the capacities of individual nodes to send or receive edges. This often leads
to clustering solutions that are heavily influenced by the nodes' capacities.
One way to overcome this is to analyse the strengths of connections in relative
rather than absolute terms, expressing each edge weight as a proportion of the
sending (or receiving) capacity of the respective node. This, however, induces
additional modelling constraints that most existing clustering methods are not
designed to handle. In this work we propose a stochastic block model for
composition-weighted networks based on direct modelling of compositional weight
vectors using a Dirichlet mixture, with the parameters determined by the
cluster labels of the sender and the receiver nodes. Inference is implemented
via an extension of the classification expectation-maximisation algorithm that
uses a working independence assumption, expressing the complete data likelihood
of each node of the network as a function of fixed cluster labels of the
remaining nodes. A model selection criterion is derived to aid the choice of
the number of clusters. The model is validated using simulation studies, and
showcased on network data from the Erasmus exchange program and a bike sharing
network for the city of London.