# Clustering of a Health Dataset Using Diagnosis Co-Occurrences
## 2 Materials and Methods
### Statistical Analysis: A New Hierarchical Agglomerative Clustering Algorithm
#### 2.2.2 New Quality Indicators  
The relative risk measure introduced in the previous section is at the foundation of all measures of the clustering algorithm. Indeed, it is used to construct clustering quality indicators, namely \(\text{RR}_{\text{intra}}\), which measures cluster intra-compactness by computing the average of the relative risk of a block with the other blocks of its cluster, and \(\text{RR}_{\text{inter}}\), which measures cluster inter-separability by computing the average of the maximum relative risk of a block with a cluster other than its own. Let \(\text{S}=\{\text{C}_{1},\dots,\text{C}_{\text{N}}\}\) be some clustering solution composed of a set of N clusters denoted \(\text{C}_{\text{k}}\), \(\text{k}\in\{1,\dots,\text{N}\}\), each cluster having a certain number of diagnosis blocks. The relative risk \(\text{RR}_{\text{i},\text{C}_{\text{k}}}\) of a diagnosis i co-occurring with a cluster \(\text{C}_{\text{k}}\) is computed directly with the Equation (1) by considering the cluster \(\text{C}_{\text{k}}\) as a new diagnosis labelled j in the dataset and by taking all the visits of any diagnosis of \(\text{C}_{\text{k}}\) in a single pool of visits related to \(\text{C}_{\text{k}}\). Then, the cluster intra-compactness and inter-separability indicators for a clustering solution S can be formulated as follows:  
\[\text{RR}_{\text{intra}}(\text{S})=\sum_{i\in D}\text{p}_{\text{i}}{}^{\prime }*\text{RR}_{\text{i}_{\text{C}_{\text{k}}}\setminus\{\text{i}\}} \tag{3}\]  
\[\text{C}_{\text{k}}\in\text{S}\mid i\in\text{C}_{\text{k}}\]  
\[\text{RR}_{\text{inter}}(\text{S})=\sum_{i\in\text{D}}\text{p}_{\text{i}}{}^{ \prime}*\max_{\text{C}_{\text{k}}\in\text{S}\mid i\in\text{C}_{\text{k}}}\text{ RR}_{\text{i}_{\text{C}_{\text{k}}}} \tag{4}\]  
where D is the set of diagnosis blocks, i is the index of some diagnosis block, \(\text{p}_{\text{i}}{}^{\prime}=\frac{\text{p}_{\text{i}}}{\sum_{i\in\text{D} }\text{p}_{\text{i}}}\) is the empirical probability that a block occurrence on ED episode is from block i and \(\text{C}_{\text{k}}\setminus\{\text{i}\}\) is the cluster k with diagnosis block i excluded. The indicator \(\text{RR}_{\text{intra}}(\text{S})\) is designed to ignore co-occurrences of a diagnosis with itself, as it does not yield any pertinent information; it would correspond to the inverse of its occurrence probability \(\frac{1}{\text{p}_{\text{i}}}\) and therefore \(\text{RR}_{\text{intra}}(\text{S})\) would depend much more on the distribution of block occurrence probabilities than on the distribution of their co-occurrence probabilities. However, this design implies an ad hoc choice for singleton clusters. Indeed, when a block of diagnosis i is a singleton, we define \(\text{RR}_{\text{i}\varnothing}\equiv 1\) as it provides an adequate reference value corresponding to probability independence. The indicator \(\text{RR}_{\text{inter}}(\text{S})\) is designed to use a maximum RR value instead of an average RR value with all other clusters (other than the one of the blocks involved) for two main reasons. The first is that most blocks are related to only a few other blocks and thus to only a few other clusters and an average RR value with all other clusters would mitigate the measure of pertinent relationships and would systematically return a low value. The second reason is that it provides an indication, at a block level, of what would be the best alternative cluster that each block could be classified in. The relative strength of this alternative link can be given by comparing \(\text{RR}_{\text{intra}}(\text{S})\) and \(\text{RR}_{\text{inter}}(\text{S})\) values at a block level, thus making the two quality indicators comparable. The two new quality indicators introduce new concepts for analyzing multimorbidity patterns. To the best of our knowledge, they are the first specific and relevant clustering indicators dedicated to this purpose.