The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

R-CMD-check License: GPL v3

modelscompete4

Compare Nested and Non‑Nested Structural Equation Models
Built on lavaan – automatic nesting detection, chi‑square difference tests, Vuong tests, and comprehensive fit indices.


Installation

# install.packages("remotes")
remotes::install_github("ssjerf-stack/modelscompete4")

Quick Start

library(modelscompete4)
library(lavaan)

# Example data
data(HolzingerSwineford1939)

# Define models as named list of lavaan syntax strings
model_list <- list(
  "OneFactor" = "g =~ x1 + x2 + x3 + x4 + x5 + x6",
  "TwoFactor" = "
    visual  =~ x1 + x2 + x3
    textual =~ x4 + x5 + x6
  "
)

# Compare them – the function fits the models automatically
result <- compare_models(model_list, data = HolzingerSwineford1939)

# Print summary
print(result)

# Access detailed results
result$fit_table          # fit indices for all models
result$comparison_matrix  # pairwise test results

Features


Advanced Example

# Three non‑nested models with different factor structures
models <- list(
  "M1" = "F1 =~ x1 + x2 + x3",
  "M2" = "F1 =~ x1 + x2 + x3 + x4",
  "M3" = "
    F1 =~ x1 + x2 + x3
    F2 =~ x4 + x5 + x6
  "
)

result <- compare_models(models, data = HolzingerSwineford1939)
print(result)

Output Structure

The returned object of class modelscompete4 contains:

Component Description
$fit_list List of fitted lavaan objects
$fit_table Data frame with fit indices for all models
$comparison_matrix Matrix with pairwise test results
$test_results Detailed statistical tests (LRT / Vuong)
$bootstrap_summary Bootstrapped estimates (if requested)

License

See https://www.gnu.org/licenses/gpl-3.0 for the full license.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.