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)
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
test_invariance(model, data, group, ...)lavaanmodels (at least configural, metric, and scalar).lavaanobjects, ready to be passed directly tocompare_model_fit()for evaluation.semTools::measEq.syntax()as a backend for generating the syntax to ensure robustness.Example Usage