Learn R Programming

EGAnet (version 1.2.3)

invariance: Measurement Invariance of EGA Structure

Description

Estimates metric invariance of EGA or specified structure

Usage

invariance(
  data,
  groups,
  iter = 500,
  memberships = NULL,
  type = c("loadings"),
  corr = c("cor_auto", "pearson", "spearman"),
  uni.method = c("expand", "LE", "louvain"),
  model = c("glasso", "TMFG"),
  model.args = list(gamma = 0),
  algorithm = c("walktrap", "leiden", "louvain"),
  algorithm.args = list(),
  consensus.method = c("highest_modularity", "most_common", "iterative", "lowest_tefi"),
  consensus.iter = 100,
  ncores,
  progress = TRUE
)

Value

Returns a list containing:

memberships

Original memberships provided in memberships or from EGA if NULL

EGA

Original EGA results for the sample

groups

  • EGA EGA results for each group

  • loadings Network loadings for each group

  • loadingsDifference Difference between the dominant loadings of each group

permutation

  • groups Permutated groups acorss iterations

  • loadings Loadings for each group for each permutation

  • loadingsDifference Difference between the dominant loadings of each group for each permutation

results

Data frame of the results (which are printed)

Arguments

data

Matrix or data frame. Variables to be used in the analysis

groups

Vector. Group membership corresponding to each case in data

iter

Numeric. Number of iterations to perform for the permutation. Defaults to 500

memberships

Vector. Node membership for each community or factor. Defaults to NULL. When NULL, EGA is used to compute node memberships

type

Character. Type of measurement invariance to estimate. Only includes "loadings" at the moment

corr

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.

uni.method

Character. What unidimensionality method should be used? Defaults to "louvain". Current options are:

  • expand Expands the correlation matrix with four variables correlated .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 is the method used in the Golino et al. (2020) Psychological Methods simulation.

  • LE Applies the Leading Eigenvalue algorithm (cluster_leading_eigen) on the empirical correlation matrix. If the number of dimensions is 1, then the Leading Eigenvalue solution is used; otherwise, regular EGA is used. This is the final method used in the Christensen, Garrido, and Golino (2021) simulation.

  • louvain Applies the Louvain algorithm (cluster_louvain) on the empirical correlation matrix using a resolution parameter = 0.95. If the number of dimensions is 1, then the Louvain solution is used; otherwise, regular EGA is used. This method was validated in the Christensen (2022) simulation.

model

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

model.args

List. A list of additional arguments for EBICglasso.qgraph or TMFG. By default, gamma is set to 0 in EBICglasso.qgraph

algorithm

A string indicating the algorithm to use or a function from igraph Current options are:

algorithm.args

List. A list of additional arguments for cluster_walktrap, cluster_louvain, or some other community detection algorithm function (see examples)

consensus.method

Character. What consensus clustering method should be used? Defaults to "highest_modularity". Current options are:

  • highest_modularity Uses the community solution that achieves the highest modularity across iterations

  • most_common Uses the community solution that is found the most across iterations

  • iterative Identifies the most common community solutions across iterations and determines how often nodes appear in the same community together. A threshold of 0.30 is used to set low proportions to zero. This process repeats iteratively until all nodes have a proportion of 1 in the community solution.

  • lowest_tefi Uses the community solution that achieves the lowest tefi across iterations

consensus.iter

Numeric. Number of iterations to perform in consensus clustering for the Louvain algorithm (see Lancichinetti & Fortunato, 2012). Defaults to 100

ncores

Numeric. Number of cores to use in computing results. Defaults to parallel::detectCores() / 2 or half of your computer's processing power. Set to 1 to not use parallel computing

If you're unsure how many cores your computer has, then use the following code: parallel::detectCores()

progress

Boolean. Should progress be displayed? Defaults to TRUE. For Windows, FALSE is about 2x faster

Author

Laura Jamison <lj5yn@virginia.edu>, Alexander P. Christensen <alexpaulchristensen@gmail.com>, and Hudson F. Golino <hfg9s at virginia.edu>

Examples

Run this code
# Load data
wmt <- wmt2[-1,7:24]

# Groups
groups <- rep(1:2, each = nrow(wmt) / 2)

if (FALSE) {
# Measurement invariance
results <- invariance(wmt, groups, ncores = 2)}

Run the code above in your browser using DataLab