cfa_fit_plot {lavaanExtra} | R Documentation |
Fit and plot CFA simultaneously
Description
Prints and saves CFA fit, as well as plots CFA factor loadings, simultaneously.
Usage
cfa_fit_plot(
model,
data,
covs = FALSE,
estimator = "MLR",
remove.items = "",
print = TRUE,
save.as.pdf = FALSE,
file.name,
...
)
Arguments
model |
CFA model to fit. |
data |
Data set on which to fit the CFA model. |
covs |
Logical, whether to include covariances on the lavaan plot. |
estimator |
What estimator to use for the CFA. |
remove.items |
Optional, if one wants to remove items from the CFA model without having to redefine it completely again. |
print |
Logical, whether to print model summary to console. |
save.as.pdf |
Logical, whether to save as PDF for a high-resolution, scalable vector graphic quality plot. Defaults to saving to the "/model" subfolder of the working directory. If it doesn't exist, it creates it. Then automatically open the created PDF in the default browser. Defaults to false. |
file.name |
Optional (when |
... |
Arguments to be passed to function lavaan::cfa. |
Value
The function returns a lavaan
fit object. However, it also: prints
a summary of the lavaan
fit object to the console, and; prints a
lavaanPlot
of the lavaan
fit object.
Illustrations
Examples
x <- paste0("x", 1:9)
(latent <- list(
visual = x[1:3],
textual = x[4:6],
speed = x[7:9]
))
HS.model <- write_lavaan(latent = latent)
cat(HS.model)
library(lavaan)
fit <- cfa_fit_plot(HS.model, HolzingerSwineford1939)