# Applies the Consensus Clustering Method (Louvain only)

Source:`R/community.consensus.R`

`community.consensus.Rd`

Applies the consensus clustering method introduced by (Lancichinetti & Fortunato, 2012). The original implementation of this method applies a community detection algorithm repeatedly to the same network. With stochastic networks, the algorithm is likely to identify different community solutions with many repeated applications.

## Arguments

- network
Matrix or

`igraph`

network object- order
Character (length = 1). Defaults to

`"higher"`

. Whether`"lower"`

or`"higher"`

order memberships from the Louvain algorithm should be obtained for the consensus. The`"lower"`

order Louvain memberships are from the first initial pass of the Louvain algorithm whereas the`"higher"`

order Louvain memberships are from the last pass of the Louvain algorithm- resolution
Numeric (length = 1). A parameter that adjusts modularity to allow the algorithm to prefer smaller (

`resolution`

> 1) or larger (0 <`resolution`

< 1) communities. Defaults to`1`

(standard modularity computation)- consensus.method
Character (length = 1). Defaults to

`"most_common"`

. Available options for arriving at a consensus (*Note*: All methods except`"iterative"`

are considered experimental until validated):`"highest_modularity"`

---**EXPERIMENTAL.**Selects the community solution with the highest modularity across the applications. Modularity is a reasonable metric for identifying the number of communities in a network but it comes with limitations (e.g., resolution limit)`"iterative"`

--- The original approach proposed by Lancichinetti & Fortunato (2012). See "Details" for more information`"most_common"`

--- Selects the community solution that appears the most frequently across the applications. The idea behind this method is that the solution that appears most often will be the most likely solution for the algorithm as well as most reproducible. Can be less stable as the number of nodes increase requiring a larger value for`consensus.iter`

. This method is the**default**`"lowest_tefi"`

---**EXPERIMENTAL.**Selects the community solution with the lowest Total Entropy Fit Index (`tefi`

) across the applications. TEFI is a reasonable metric to identify the number of communities in a network based on Golino, Moulder et al. (2020)

- consensus.iter
Numeric (length = 1). Number of algorithm applications to the network. Defaults to

`1000`

- correlation.matrix
Symmetric matrix. Used for computation of

`tefi`

. Only needed when`consensus.method = "tefi"`

- allow.singleton
Boolean (length = 1). Whether singleton or single node communities should be allowed. Defaults to

`FALSE`

. When`FALSE`

, singleton communities will be set to missing (`NA`

); otherwise, when`TRUE`

, singleton communities will be allowed- membership.only
Boolean. Whether the memberships only should be output. Defaults to

`TRUE`

. Set to`FALSE`

to obtain all output for the community detection algorithm- ...
Not actually used but makes it easier for general functionality in the package

## Value

Returns either a vector with the selected solution
or a list when `membership.only = FALSE`

:

- selected_solution
Resulting solution from the consensus method

- memberships
Matrix of memberships across the consensus iterations

- proportion_table
For methods that use frequency, a table that reports those frequencies alongside their corresponding memberships

## Details

The goal of the consensus clustering method is to identify a stable solution across
algorithm applications to derive a "consensus" clustering. The standard or "iterative"
approach is to apply the community detection algorithm *N* times. Then, a co-occurrence
matrix is created representing how often each pair of nodes co-occurred across the
applications. Based on some cut-off value (e.g., 0.30), co-occurrences below this value
are set to zero, forming a "new" sparse network. The procedure proceeds until all nodes
co-occur with all other nodes in their community (or a proportion of 1.00).

Variations of this procedure are also available in this package but are
**experimental**. Use these experimental procedures with caution.
More work is necessary before these experimental procedures are validated

*At this time, seed setting for consensus clustering is not supported*

## References

**Louvain algorithm**

Blondel, V. D., Guillaume, J.-L., Lambiotte, R., & Lefebvre, E. (2008).
Fast unfolding of communities in large networks.
*Journal of Statistical Mechanics: Theory and Experiment*, *2008*(10), P10008.

**Consensus clustering**

Lancichinetti, A., & Fortunato, S. (2012).
Consensus clustering in complex networks.
*Scientific Reports*, *2*(1), 1–7.

**Entropy fit indices**

Golino, H., Moulder, R. G., Shi, D., Christensen, A. P., Garrido, L. E., Nieto, M. D., Nesselroade, J., Sadana, R., Thiyagarajan, J. A., & Boker, S. M. (2020).
Entropy fit indices: New fit measures for assessing the structure and dimensionality of multiple latent variables.
*Multivariate Behavioral Research*.

## Author

Hudson Golino <hfg9s at virginia.edu> and Alexander P. Christensen <alexpaulchristensen@gmail.com>

## Examples

```
# Load data
wmt <- wmt2[,7:24]
# Estimate correlation matrix
correlation.matrix <- auto.correlate(wmt)
# Estimate network
network <- EBICglasso.qgraph(data = wmt)
# Compute standard Louvain with highest modularity approach
community.consensus(
network,
consensus.method = "highest_modularity"
)
#> Consensus Method: Highest Modularity (1000 iterations)
#> Algorithm: Louvain
#> Order: Higher
#>
#> Number of communities: 3
#>
#> wmt1 wmt2 wmt3 wmt4 wmt5 wmt6 wmt7 wmt8 wmt9 wmt10 wmt11 wmt12 wmt13
#> 1 1 1 1 1 2 2 2 3 3 2 2 3
#> wmt14 wmt15 wmt16 wmt17 wmt18
#> 3 2 3 2 2
# Compute standard Louvain with iterative (original) approach
community.consensus(
network,
consensus.method = "iterative"
)
#> Consensus Method: Iterative (1000 iterations)
#> Algorithm: Louvain
#> Order: Higher
#>
#> Number of communities: 3
#>
#> wmt1 wmt2 wmt3 wmt4 wmt5 wmt6 wmt7 wmt8 wmt9 wmt10 wmt11 wmt12 wmt13
#> 1 1 1 1 1 2 2 2 3 3 2 2 3
#> wmt14 wmt15 wmt16 wmt17 wmt18
#> 3 2 3 2 2
# Compute standard Louvain with most common approach
community.consensus(
network,
consensus.method = "most_common"
)
#> Consensus Method: Most Common (1000 iterations)
#> Algorithm: Louvain
#> Order: Higher
#>
#> Number of communities: 3
#>
#> wmt1 wmt2 wmt3 wmt4 wmt5 wmt6 wmt7 wmt8 wmt9 wmt10 wmt11 wmt12 wmt13
#> 1 1 1 1 1 2 2 2 3 3 2 2 3
#> wmt14 wmt15 wmt16 wmt17 wmt18
#> 3 2 3 2 2
# Compute standard Louvain with lowest TEFI approach
community.consensus(
network,
consensus.method = "lowest_tefi",
correlation.matrix = correlation.matrix
)
#> Consensus Method: Lowest TEFI (1000 iterations)
#> Algorithm: Louvain
#> Order: Higher
#>
#> Number of communities: 3
#>
#> wmt1 wmt2 wmt3 wmt4 wmt5 wmt6 wmt7 wmt8 wmt9 wmt10 wmt11 wmt12 wmt13
#> 1 1 1 1 1 2 2 2 3 3 2 2 3
#> wmt14 wmt15 wmt16 wmt17 wmt18
#> 3 2 3 2 2
```