run_mplus_besem_invariance: Generate, Run, and Compare B-ESEM Invariance Models Against...

View source: R/invariance.R

run_mplus_besem_invarianceR Documentation

Generate, Run, and Compare B-ESEM Invariance Models Against Mplus

Description

Creates complete Mplus .inp files for every level fitted in inv (configural, weak, strong, strict and, when esem_invariance() was run with through, latent var/cov and latent means), runs them via MplusAutomation, then prints a side-by-side comparison of fit statistics against the R results from esem_invariance.

Usage

run_mplus_besem_invariance(
  inv,
  output_folder,
  mplus_command = "mplus",
  group_labels = NULL,
  missing_code = -999,
  difftest = TRUE
)

Arguments

inv

An esem_invariance object (from model = "besem").

output_folder

Character. Folder where data.dat, .inp, and .out files will be written. Created if it does not exist.

mplus_command

Character. Full path to the Mplus executable. Default "mplus" (works if Mplus is on the system PATH).

group_labels

Named character vector mapping group values to Mplus labels, e.g. c("1" = "MALE", "2" = "FEMALE"). If NULL (default) labels are auto-derived as G1, G2, ...

missing_code

Numeric. Missing value sentinel written to the data file. Default -999.

difftest

Logical. Generate DIFFTEST constraint files for chained nested-model comparisons (strong vs weak, strict vs strong). Default TRUE.

Value

A data frame (invisibly) with _R, _Mplus, and delta_ columns for each fit statistic. Printed as a table.

See Also

esem_invariance

Examples

## Not run: 
# Requires a licensed Mplus installation reachable via `mplus_command`.
inv <- esem_invariance(spec, model = "besem")
cmp <- run_mplus_besem_invariance(
  inv,
  output_folder = tempfile("mplus_inv_"),
  mplus_command = "C:/Program Files/Mplus/mplus.exe",
  group_labels  = c("1" = "MALE", "2" = "FEMALE")
)

## End(Not run)


bifactory documentation built on Oct. 28, 2026, 1:06 a.m.