# Measurement Invariance Workflow

This vignette shows how to prepare a small multigroup dataset for measurement invariance analysis.

    library(PsychoMatic)
    data(psychomatic_multigroup)

    table(psychomatic_multigroup$group)
    #>
    #>  A  B
    #> 70 70
    head(psychomatic_multigroup)
    #>          mg1         mg2        mg3        mg4        mg5         mg6 group
    #> 1 -0.4463447 -0.01640293  0.1831621 -0.2703497 -0.4175806  0.91629766     A
    #> 2  0.5010886  0.15321729 -1.4712071  0.1754183  0.6088400  0.20421379     A
    #> 3 -0.7826698 -0.70986766 -1.8686623 -0.3995529 -0.5384254 -0.12112080     A
    #> 4  2.1959812  1.35356597  3.0867854  2.1035482  1.6856730  1.68979830     A
    #> 5  1.1758965  0.14786369  1.8625270  0.2716819  0.6699287  0.03527708     A
    #> 6  0.9166738  0.26417150  0.8650117  0.2800986  0.7013515 -0.30536607     A

## Model

    model <- "
    factor1 =~ mg1 + mg2 + mg3
    factor2 =~ mg4 + mg5 + mg6
    "

## Sequential Invariance Testing

The full workflow fits configural, metric, scalar, and strict models. It is not evaluated by default in CRAN vignette checks because multi-group CFA can be computationally heavier than a minimal example.

    invariance <- factorial_invariance_auto(
      psychomatic_multigroup,
      group = "group",
      model = model,
      estimator = "ML",
      language = "eng",
      report = FALSE
    )
    summary(invariance)