| esem_compare | R Documentation |
Fits a user-specified CFA model on the same data and compares it against an
esem_fit object using fit indices and, where applicable, a chi-square
difference test (when models are nested).
esem_compare(esem_model, cfa_model, data = NULL, estimator = NULL, ...)
esem_model |
An |
cfa_model |
A lavaan model string for the comparison CFA. All items must be the same as in the ESEM. |
data |
A |
estimator |
Estimator for the CFA model. Defaults to the same estimator
used in |
... |
Additional arguments passed to |
A list of class "esem_comparison" with:
fit_tableA data.frame of fit indices for both models.
esem_fitThe original esem_fit object.
cfa_fitThe fitted lavaan CFA object.
lavtestOutput of lavaan::lavTestLRT() if models are nested, else NULL.
esem
data("HolzingerSwineford1939", package = "lavaan")
d <- HolzingerSwineford1939[, paste0("x", 1:9)]
# Fit ESEM
esem_result <- esem(d, nfactors = 3)
# Define comparison CFA (no cross-loadings)
cfa_model <- "
Visual =~ x1 + x2 + x3
Textual =~ x4 + x5 + x6
Speed =~ x7 + x8 + x9
"
comparison <- esem_compare(esem_result, cfa_model, data = d)
print(comparison)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.