This function will run N number of CFA where N = length(group)
, and report the fit measures of CFA in each group.
The function is intended to help you get a better understanding of which group has abnormal fit indicator
cfa_groupwise(data, ..., group, model = NULL, ordered = FALSE)
data frame
CFA items. Support dplyr::select()
syntax.
character. group variable. Support dplyr::select()
syntax.
explicit lavaan
model. Must be specify with model = lavaan_model_syntax
.
logical. default is FALSE
. If it is set to TRUE
, lavaan will treat it as a ordinal variable and use DWLS
instead of ML
a data.frame
with group-wise CFA result
All argument must be explicitly specified. If not, all arguments will be treated as CFA items
# The example is used as the illustration of the function output only.
# It does not imply the data is appropriate for the analysis.
cfa_groupwise(
data = lavaan::HolzingerSwineford1939,
group = "school",
x1:x3,
x4:x6,
x7:x9
)
#> group cfi rmsea tli
#> 1 Pasteur 0.9031037 0.10376088 0.8546555
#> 2 Grant-White 0.9413704 0.08896312 0.9120556