# Approaches to Detect Unidimensional Communities

Source:`R/community.unidimensional.R`

`community.unidimensional.Rd`

A function to apply several approaches to detect a unidimensional community in
networks. There have many different approaches recently such as expanding
the correlation matrix to have orthogonal correlations (`"expand"`

),
applying the Leading Eigenvalue community detection algorithm
`cluster_leading_eigen`

to the correlation matrix
(`"LE"`

), and applying the Louvain community detection algorithm
`cluster_louvain`

to the correlation matrix (`"louvain"`

).
Not necessarily intended for individual use – it's better to use `EGA`

## Arguments

- data
Matrix or data frame. Should consist only of variables that are desired to be in analysis

- n
Numeric (length = 1). Sample size if

`data`

provided is a correlation matrix- corr
Character (length = 1). Method to compute correlations. Defaults to

`"auto"`

. Available options:`"auto"`

— Automatically computes appropriate correlations for the data using Pearson's for continuous, polychoric for ordinal, tetrachoric for binary, and polyserial/biserial for ordinal/binary with continuous. To change the number of categories that are considered ordinal, use`ordinal.categories`

(see`polychoric.matrix`

for more details)`"cor_auto"`

— Uses`cor_auto`

to compute correlations. Arguments can be passed along to the function`"pearson"`

— Pearson's correlation is computed for all variables regardless of categories`"spearman"`

— Spearman's rank-order correlation is computed for all variables regardless of categories

For other similarity measures, compute them first and input them into

`data`

with the sample size (`n`

)- na.data
Character (length = 1). How should missing data be handled? Defaults to

`"pairwise"`

. Available options:`"pairwise"`

— Computes correlation for all available cases between two variables`"listwise"`

— Computes correlation for all complete cases in the dataset

- model
Character (length = 1). Defaults to

`"glasso"`

. Available options:`"BGGM"`

— Computes the Bayesian Gaussian Graphical Model. Set argument`ordinal.categories`

to determine levels allowed for a variable to be considered ordinal. See`?BGGM::estimate`

for more details`"glasso"`

— Computes the GLASSO with EBIC model selection. See`EBICglasso.qgraph`

for more details`"TMFG"`

— Computes the TMFG method. See`TMFG`

for more details

- uni.method
Character (length = 1). What unidimensionality method should be used? Defaults to

`"louvain"`

. Available options:`"expand"`

— Expands the correlation matrix with four variables correlated 0.50. If number of dimension returns 2 or less in check, then the data are unidimensional; otherwise, regular EGA with no matrix expansion is used. This method was used in the Golino et al.'s (2020)*Psychological Methods*simulation`"LE"`

— Applies the Leading Eigenvector algorithm (`cluster_leading_eigen`

) on the empirical correlation matrix. If the number of dimensions is 1, then the Leading Eigenvector solution is used; otherwise, regular EGA is used. This method was used in the Christensen et al.'s (2023)*Behavior Research Methods*simulation`"louvain"`

— Applies the Louvain algorithm (`cluster_louvain`

) on the empirical correlation matrix. If the number of dimensions is 1, then the Louvain solution is used; otherwise, regular EGA is used. This method was validated Christensen's (2022)*PsyArXiv*simulation. Consensus clustering can be used by specifying either`"consensus.method"`

or`"consensus.iter"`

- verbose
Boolean. Whether messages and (insignificant) warnings should be output. Defaults to

`FALSE`

(silent calls). Set to`TRUE`

to see all messages and warnings for every function call- ...
Additional arguments to be passed on to

`auto.correlate`

,`network.estimation`

,`community.consensus`

, and`community.detection`

## Value

Returns the memberships of the community detection algorithm.
The memberships will output *regardless* of whether the
network is unidimensional

## References

**Expand approach**

Golino, H., Shi, D., Christensen, A. P., Garrido, L. E., Nieto, M. D., Sadana, R., Thiyagarajan, J. A., & Martinez-Molina, A. (2020).
Investigating the performance of exploratory graph analysis and traditional techniques to identify the number of latent factors:
A simulation and tutorial.
*Psychological Methods*, *25*, 292-320.

**Leading Eigenvector approach**

Christensen, A. P., Garrido, L. E., Guerra-Pena, K., & Golino, H. (2023).
Comparing community detection algorithms in psychometric networks: A Monte Carlo simulation.
*Behavior Research Methods*.

**Louvain approach**

Christensen, A. P. (2023).
Unidimensional community detection: A Monte Carlo simulation, grid search, and comparison.
*PsyArXiv*.

## Author

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

## Examples

```
# Load data
wmt <- wmt2[,7:24]
# Louvain with Consensus Clustering (default)
community.unidimensional(wmt)
#> Algorithm: Louvain
#>
#> Number of communities: 2
#>
#> wmt1 wmt2 wmt3 wmt4 wmt5 wmt6 wmt7 wmt8 wmt9 wmt10 wmt11 wmt12 wmt13
#> 1 1 1 1 1 2 2 2 2 1 2 2 2
#> wmt14 wmt15 wmt16 wmt17 wmt18
#> 2 2 2 2 2
# Leading Eigenvector
community.unidimensional(wmt, uni.method = "LE")
#> Algorithm: Leading Eigenvector
#>
#> Number of communities: 2
#>
#> wmt1 wmt2 wmt3 wmt4 wmt5 wmt6 wmt7 wmt8 wmt9 wmt10 wmt11 wmt12 wmt13
#> 1 1 1 1 1 1 2 2 2 1 2 2 2
#> wmt14 wmt15 wmt16 wmt17 wmt18
#> 2 2 2 2 2
# Expand
community.unidimensional(wmt, uni.method = "expand")
#> wmt1 wmt2 wmt3 wmt4 wmt5 wmt6 wmt7 wmt8 wmt9 wmt10 wmt11 wmt12 wmt13
#> 1 1 1 1 1 2 2 2 2 2 2 2 2
#> wmt14 wmt15 wmt16 wmt17 wmt18
#> 2 2 2 2 2
```