| run_comparison | R Documentation |
Takes a model specification from specify_model and
automatically fits CFA, ESEM, and B-ESEM in R, optionally runs all
three in Mplus, and returns a comparison table plus all fitted objects.
run_comparison(
spec,
mplus_folder = NULL,
mplus_command = "Mplus",
run_alignment = TRUE,
group_equal = NULL,
n_starts = 30L
)
spec |
An |
mplus_folder |
Character. Path to a folder for Mplus files. If
|
mplus_command |
Character. Path or command used to invoke Mplus.
Default |
run_alignment |
Logical. Run alignment check? Default |
group_equal |
Character vector of lavaan equality constraints
(e.g. |
n_starts |
Integer. Random rotation starts for the B-ESEM rotation
search. Default |
An object of class "esem_comparison_pipeline" containing:
specThe original model specification.
fit_cfalavaan CFA fit object.
fit_esemesem_fit object.
fit_besembesem_fit object.
alignmentalignment_check result (if run).
comparison_tableData frame of fit indices.
mplus_resultsList of Mplus readModels results (if run).
data("HolzingerSwineford1939", package = "lavaan")
spec <- specify_model(
Visual = c("x1", "x2", "x3"),
Textual = c("x4", "x5", "x6"),
Speed = c("x7", "x8", "x9"),
data = HolzingerSwineford1939,
label = "Holzinger-Swineford"
)
# Fit CFA, ESEM, and B-ESEM in R and build the comparison table
results <- run_comparison(spec, n_starts = 5L)
print(results)
# Access individual fits
summary(results$fit_esem, fit.measures = TRUE, standardized = TRUE)
std_loadings(results$fit_besem, suppress = 0.10)
factor_correlations(results$fit_esem)
## Not run:
# Also run all three models in Mplus and compare side by side.
# Requires a licensed Mplus installation reachable via `mplus_command`.
results <- run_comparison(spec, mplus_folder = tempfile("mplus_"))
print(results)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.