Skip to contents

R-CMD-check pkgdown License: MIT DOI

📦 R package for Mixture Multigroup SEM (MMG-SEM). MMG-SEM performs clustering of a SEM model based on the structural parameters while allowing for a combination of group-specific and invariant parameters in the measurement model. For more information about the method, please see: Mixture Multigroup Structural Equation Modeling: A Novel Method for Comparing Structural Relations Across Many Groups.

Installation

It is possible to download the (in development) mmgsem package from GitHub by:

library("pak")
pak::pak("AndresFPA/mmgsem")

Quick start

The Quick start guide walks through fitting a model, selecting the number of clusters, and computing standard errors with the example data.

Tutorial

An in-depth tutorial on how to use this package has been published in Structural Equation Modeling: A Multidisciplinary Journal; please see: Using Mixture Multigroup Structural Equation Modeling to Compare Structural Relations Across Many Groups: An Introduction to the mmgsem R Package (only for cross-sectional data). An accompanying R script for the tutorial is also available in this complementary GitHub Repository.

Graphical User Interface (GUI)

A point-and-click GUI for mmgsem was developed by cahitgs and is openly available at this repository. It can be downloaded as a standalone Windows app (running R in the background) or run directly in R. A quick start (i.e., installation and use) is available in the original repository, including the data example used in mmgsem’s tutorial paper.

(Main) Functions

  • mmgsem(): The main function performs the clustering based on the structural parameters.
  • lmmgsem(): Longitudinal extension that estimates group state transitions over time.
  • ModelSelection(): Wrapper function. It runs MMG-SEM multiple times with different numbers of clusters and returns model selection measures.
  • compute_mi_long_stepwise_score(): Stepwise measurement-invariance analysis for longitudinal data.
  • compute_se(): Wrapper function. It computes the standard errors of the resulting MMG-SEM parameters.

MMG-SEM

mmgsem() performs clustering at the group level (e.g., clusters of nations). It deals with regression parameter differences. For instance, one can ask: which countries show a similar relation between negative emotions and life satisfaction? For its estimation, we use a step-wise approach based on the Structural-After-Measurement approach (see SAM).

Model Selection

The ModelSelection() wrapper computes several model selection measures. Specifically, it computes the AIC, AIC3, the CHull, ICL, and the BIC. The BIC is computed in two different forms: (1) BICG with the number of groups as sample size, and (2) BICN with the number of observations as sample size. Performance of the different measures was studied in detail at Selecting the number of clusters in Mixture Multigroup Structural Equation Modeling.

Standard Errors

The compute_se() wrapper function computes standard errors from the Hessian matrix of the parameters. It uses numerical differentiation to compute the second derivative of the log-likelihood with respect to the parameters. Note that it also computes the corrected standard errors based on Bakk et al. (2014).

Longitudinal extension

For multi-wave data, lmmgsem() extends MMG-SEM with a Latent Markov model. Every group must have data at all time points. The longitudinal extension is still in development, so interpret its results with caution. See the Quick start guide for an example of fitting and selecting longitudinal models.

References

Bakk, Z., Oberski, D. L., & Vermunt, J. K. (2014). Relating Latent Class Assignments to External Variables: Standard Errors for Correct Inference. Political Analysis, 22(4), 520–540. DOI

Perez Alonso, A. F., Rosseel, Y., Vermunt, J. K., & De Roover, K. (2024). Mixture multigroup structural equation modeling: A novel method for comparing structural relations across many groups. Psychological Methods. DOI

Perez Alonso, A. F., Vermunt, J. K., Rosseel, Y., & Roover, K. D. (2025). Selecting the number of clusters in Mixture Multigroup Structural Equation Modeling. Methodology, 21(1), 1–26. DOI

Perez Alonso, A. F., Vermunt, J. K., Rosseel, Y., Zhao, H., & De Roover, K. (2026). Using Mixture Multigroup Structural Equation Modeling to Compare Structural Relations Across Many Groups: An Introduction to the mmgsem R Package. Structural Equation Modeling: A Multidisciplinary Journal, 1–28. DOI

Perez Alonso, A. F. (2026). mmgsem: Mixture Multigroup Structural Equation Modeling (MMG-SEM) (Version 0.0.1) [R package]. Zenodo. DOI

Rosseel, Y., & Loh, W. W. (2022). A structural after measurement approach to structural equation modeling. Psychological Methods. DOI

Funding

The research behind this R package was funded by a Vidi grant VI.Vidi.201.133 awarded to Kim De Roover by the Netherlands Organization for Scientific Research (NWO).