Estimates the number of dimensions of a given dataset or correlation matrix
using the graphical lasso (EBICglasso.qgraph
) or the
Triangulated Maximally Filtered Graph (TMFG
)
network estimation methods.
EGA(
data,
n = NULL,
uni = TRUE,
corr = c("cor_auto", "pearson", "spearman"),
model = c("glasso", "TMFG"),
model.args = list(),
algorithm = c("walktrap", "louvain"),
algorithm.args = list(),
plot.EGA = TRUE,
plot.type = c("GGally", "qgraph"),
plot.args = list(),
verbose = TRUE,
...
)
Matrix or data frame.
Variables (down columns) or correlation matrix.
If the input is a correlation matrix,
then argument n
(number of cases) is required
Integer.
Sample size if data
provided is a correlation matrix
Boolean.
Should unidimensionality be checked?
Defaults to TRUE
.
Set to FALSE
to check for multidimensionality only.
If TRUE
, then the same number of variables as the original
data (i.e., from argument data
) up to 12 are generated from a factor
model with one factor and loadings of .70. These data are then
appended to the original data and dimensionality is checked.
If the number of dimensions is one or two, then the original
data are unidimensional; otherwise, the data are multidimensional
(see Golino, Shi, et al., 2020 for more details)
Type of correlation matrix to compute. The default uses cor_auto
.
Current options are:
cor_auto
Computes the correlation matrix using the cor_auto
function from
qgraph
.
pearson
Computes Pearson's correlation coefficient using the pairwise complete observations via
the cor
function.
spearman
Computes Spearman's correlation coefficient using the pairwise complete observations via
the cor
function.
Character. A string indicating the method to use. Current options are:
glasso
Estimates the Gaussian graphical model using graphical LASSO with
extended Bayesian information criterion to select optimal regularization parameter.
This is the default method
TMFG
Estimates a Triangulated Maximally Filtered Graph
List.
A list of additional arguments for EBICglasso.qgraph
or TMFG
A string indicating the algorithm to use or a function from igraph
Current options are:
walktrap
Computes the Walktrap algorithm using cluster_walktrap
louvain
Computes the Walktrap algorithm using cluster_louvain
List.
A list of additional arguments for cluster_walktrap
, cluster_louvain
,
or some other community detection algorithm function (see examples)
Boolean.
If TRUE
, returns a plot of the network and its estimated dimensions.
Defaults to TRUE
List.
A list of additional arguments for the network plot.
For plot.type = "qgraph"
:
vsize
Size of the nodes. Defaults to 6.
For plot.type = "GGally"
(see ggnet2
for
full list of arguments):
vsize
Size of the nodes. Defaults to 6.
label.size
Size of the labels. Defaults to 5.
alpha
The level of transparency of the nodes, which might be a single value or a vector of values. Defaults to 0.7.
edge.alpha
The level of transparency of the edges, which might be a single value or a vector of values. Defaults to 0.4.
legend.names
A vector with names for each dimension
color.palette
The color palette for the nodes. For custom colors,
enter HEX codes for each dimension in a vector.
See color_palette_EGA
for
more details and examples
Boolean.
Should network estimation parameters be printed?
Defaults to TRUE
.
Set to FALSE
for no print out
Additional arguments.
Used for deprecated arguments from previous versions of EGA
Returns a list containing:
A symmetric network estimated using either the
EBICglasso.qgraph
or TMFG
A vector representing the community (dimension) membership
of each node in the network. NA
values mean that the node
was disconnected from the network
A scalar of how many total dimensions were identified in the network
The zero-order correlation matrix
Two community detection algorithms, Walktrap (Pons & Latapy, 2006) and
Louvain (Blondel et al., 2008), are pre-programmed because of their
superior performance in simulation studies on psychological
data generated from factor models (Christensen & Golino; 2020; Golino et al., 2020).
Notably, any community detection algorithm from the igraph
can be used to estimate the number of communities (see examples).
# 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, P10008.
# Compared all igraph community detections algorithms, introduced Louvain algorithm, simulation with continuous and polytomous data Christensen, A. P., & Golino, H. (under review). Estimating factors with psychometric networks: A Monte Carlo simulation comparing community detection algorithms. PsyArXiv. 10.31234/osf.io/hz89e
# Original simulation and implementation of EGA Golino, H. F., & Epskamp, S. (2017). Exploratory graph analysis: A new approach for estimating the number of dimensions in psychological research. PLoS ONE, 12, e0174035.. 10.1371/journal.pone.0174035
Golino, H. F., & Demetriou, A. (2017). Estimating the dimensionality of intelligence like data using Exploratory Graph Analysis. Intelligence, 62, 54-70. 10.1016/j.intell.2017.02.007
# Current implementation of EGA, introduced unidimensional checks, continuous and dichotomous data Golino, H., Shi, D., Christensen, A. P., Garrido, L. E., Nieto, M. D., Sadana, R., & Thiyagarajan, J. 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. 10.1037/met0000255
# Walktrap algorithm Pons, P., & Latapy, M. (2006). Computing communities in large networks using random walks. Journal of Graph Algorithms and Applications, 10, 191-218. 10.7155/jgaa.00185
bootEGA
to investigate the stability of EGA's estimation via bootstrap
and CFA
to verify the fit of the structure suggested by EGA using confirmatory factor analysis.
# NOT RUN {
# Estimate EGA
## plot.type = "qqraph" used for CRAN checks
## plot.type = "GGally" is the default
ega.wmt <- EGA(data = wmt2[,7:24], plot.type = "qgraph")
# Summary statistics
summary(ega.wmt)
# Estimate EGAtmfg
ega.wmt <- EGA(data = wmt2[,7:24], model = "TMFG", plot.type = "qgraph")
# Estimate EGA with Louvain algorithm
ega.wmt <- EGA(data = wmt2[,7:24], algorithm = "louvain", plot.type = "qgraph")
# Estimate EGA with Spinglass algorithm
ega.wmt <- EGA(data = wmt2[,7:24],
algorithm = igraph::cluster_spinglass, plot.type = "qgraph")
# Estimate EGA
ega.intel <- EGA(data = intelligenceBattery[,8:66], model = "glasso", plot.EGA = FALSE)
# Summary statistics
summary(ega.intel)
# }
# NOT RUN {
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab