Skip to content

[Feature] Create a helper function for specifying invariance models #21

@brianmsm

Description

@brianmsm

User Story

As a researcher, writing the code to specify and fit a sequence of measurement invariance models (configural, metric, scalar, strict) is tedious, repetitive, and prone to error. I want a single function that automates this entire process for me.

Acceptance Criteria

  • Create a new high-level function, e.g., test_invariance(model, data, group, ...)
  • The function should take a base model syntax, the dataset, and the grouping variable name.
  • It should automatically generate, fit, and return a sequence of nested lavaan models (at least configural, metric, and scalar).
  • The return value should be a list of fitted lavaan objects, ready to be passed directly to compare_model_fit() for evaluation.
  • Consider using semTools::measEq.syntax() as a backend for generating the syntax to ensure robustness.

Example Usage

model <- 'F  =~ x1 + x2 + x3'

# Desired outcome: This one function call runs all the models
invariance_results <- test_invariance(model, data = my_data, group = "gender")

# The output can then be directly used by our enhanced comparison function
compare_model_fit(invariance_results)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions