chisq_decomp: Per-Group Chi-Square Decomposition for Invariance Fits

View source: R/chisq_decomp.R

chisq_decompR Documentation

Per-Group Chi-Square Decomposition for Invariance Fits

Description

Extracts the per-group contribution to the WLSMV (or ML) chi-square at each invariance level of an esem_invariance object. Optionally compares against Mplus's Chi-Square Contribution From Each Group table, which is useful for pinpointing whether a basin difference between R and Mplus is driven by a single group or distributed across all of them.

Usage

chisq_decomp(x, mplus_dir = NULL, levels = NULL)

Arguments

x

An esem_invariance object.

mplus_dir

Optional directory containing Mplus output files named besem_inv_<level>.out. When supplied, the result includes chisq_M, mplus_group, and delta = chisq_R - chisq_M.

levels

Character vector of levels to include. Defaults to all levels present in x$models.

Details

lavaan's stat.group is the raw (unscaled) per-group chi-square; Mplus prints the scaled per-group contribution that sums to the scaled total. To compare on the same scale, R per-group values are rescaled by the global ratio chisq.scaled / chisq from fitMeasures.

Value

A data frame of class "chisq_decomp" with columns level, group, chisq_R (rescaled to scaled scale), and when mplus_dir is supplied, mplus_group, chisq_M, delta.

Examples

data("HolzingerSwineford1939", package = "lavaan")

spec <- specify_model(
  Visual  = c("x1", "x2", "x3"),
  Textual = c("x4", "x5", "x6"),
  Speed   = c("x7", "x8", "x9"),
  data  = HolzingerSwineford1939,
  group = "school"
)


inv <- esem_invariance(spec)
chisq_decomp(inv)


## Not run: 
# Supply a folder of Mplus .out files to add side-by-side deltas.
chisq_decomp(inv, mplus_dir = "validation/_bfi_g4_mplus_inv")

## End(Not run)

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