# Adapted from the example for CFA in lavaan::cfa().
# Using only two of the factors
library(lavaan)
HS.model <-
'
visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
'
fit <- cfa(HS.model, data = HolzingerSwineford1939)
# Refit the model with the history recorded
fit_h <- record_history(fit)
fit_h
# Plot the history for selected parameters
plot(fit_h, params = c("visual=~x2", "visual=~x3",
"visual~~textual"),
last_n = 10)
plot(fit_h, params = c("visual=~x2", "visual=~x3",
"visual~~textual"),
last_n = 10,
orientation = "vertical")
Run the code above in your browser using DataLab