Generate metric and scalar invariance models and their partial invariance versions.
Usage
measurement_invariance_models(
cfa_out,
max_free = 1,
metric = TRUE,
scalar = TRUE,
progress = TRUE
)
Arguments
- cfa_out
The output of
lavaan::cfa()
.- max_free
The maximum number of constraints to be released when generating the partial invariance models. For example, if set to 1, then only the partial metric invariance model only has at most one item allowed to have different loadings across group. Default is 1. If set to zero, then no partial invariance models will be generated.
- metric
Logical. If
TRUE
, the default, then metric invariance model and its partial invariance versions are generated.- scalar
Logical. If
TRUE
, the default, then scalar invariance model and its partial invariance versions are generated.- progress
Logical. If
TRUE
, the default, progress bars will be displayed when fitting partial invariance models.
Value
A list of lavaan::cfa()
output. The names are automatically
generated to indicate whether a model
is configural, metric, or scalar
invariance, or the item(s) without
between-group constraints on the
loadings (for partial metric
invariance) or intercepts (for
partial scalar invariance).
Details
This a helper function to generate, based on a multigroup confirmatory factor analysis (CFA) model with no between-group equality constraints, the following models:
A metric invariance model (loadings constrained to be equal across groups).
A scalar invariance model (intercepts and loadings constrained to be equal across groups).
Partial invariance versions of the previous two models, such as a model with the loadings of all items, except for one, constrained to be equal across groups.
The models generated can then be used
in model_set()
to compute BPPs.
Requirements
The model used as the input needs to be fitted with no between group constrains, that is, it is a configural invariance model. Although not a must, it is advised to use the default way to identify each factor (that is, fixing a loading to one).
Implementation
This function simply use the
group.partial
and group.equal
argument of lavaan::cfa()
to
generate the models.
Author
Shu Fai Cheung https://orcid.org/0000-0002-9871-9448
Examples
library(lavaan)
data(HolzingerSwineford1939)
# For illustration, only two factors are used
HSmod <-
"
spatial =~ x1 + x2 + x3
verbal =~ x4 + x5 + x6
"
fit_config <- cfa(model = HSmod,
data = HolzingerSwineford1939,
group = "school")
fit_mi <- measurement_invariance_models(fit_config)
#>
#> Fitting 4 partial metric invariance models:
#>
#> Fitting 6 partial scalar invariance models:
names(fit_mi)
#> [1] "config" "metric" "scalar" "spatial=~x2" "spatial=~x3"
#> [6] "verbal=~x5" "verbal=~x6" "x1~1" "x2~1" "x3~1"
#> [11] "x4~1" "x5~1" "x6~1"
# Need to add 'skip_check_sem_out = TRUE' to use multigroup models.
out <- model_set(sem_out = fit_mi,
skip_check_sem_out = TRUE,
progress = FALSE,
parallel = FALSE)
print(out)
#>
#> Call:
#> model_set(sem_out = fit_mi, parallel = FALSE, progress = FALSE,
#> skip_check_sem_out = TRUE)
#>
#> Number of model(s) fitted : 13
#> Number of model(s) converged : 13
#> Number of model(s) passed post.check: 13
#>
#> The models (sorted by BPP):
#> model_df df_diff Prior BIC BPP cfi rmsea
#> x3~1 23 NA 0.077 5151.234 0.987 0.967 0.078
#> x2~1 23 NA 0.077 5162.048 0.004 0.950 0.096
#> metric 20 NA 0.077 5163.002 0.003 0.970 0.079
#> verbal=~x5 19 NA 0.077 5163.444 0.002 0.977 0.072
#> x1~1 23 NA 0.077 5164.566 0.001 0.946 0.100
#> scalar 24 NA 0.077 5165.205 0.001 0.938 0.105
#> verbal=~x6 19 NA 0.077 5165.527 0.001 0.974 0.077
#> spatial=~x3 19 NA 0.077 5167.629 0.000 0.971 0.081
#> spatial=~x2 19 NA 0.077 5167.970 0.000 0.970 0.082
#> x4~1 23 NA 0.077 5168.654 0.000 0.940 0.106
#> x5~1 23 NA 0.077 5169.318 0.000 0.939 0.107
#> x6~1 23 NA 0.077 5170.871 0.000 0.936 0.109
#> config 16 NA 0.077 5175.449 0.000 0.980 0.072
#>
#> Note:
#> - BIC: Bayesian Information Criterion.
#> - BPP: BIC posterior probability.
#> - model_df: Model degrees of freedom.
#> - df_diff: Difference in df compared to the original/target model.
#> - To show cumulative BPPs, call print() with 'cumulative_bpp = TRUE'.
#> - Since Version 0.1.3.5, the default values of exclude_feedback and
#> exclude_xy_cov changed to TRUE. Set them to FALSE to reproduce
#> results from previous versions.