library(mxsem)
set.seed(123)
dataset <- simulate_moderated_nonlinear_factor_analysis(N = 50)
model <- "
xi =~ x1 + x2 + x3
eta =~ y1 + y2 + y3
eta ~ {a := a0 + data.k*a1}*xi
"
fit <- mxsem(model = model,
data = dataset) |>
mxTryHard()
algebra_results <- get_individual_algebra_results(mxModel = fit,
progress_bar = FALSE)
# the following plot will only show two data points because there is only
# two values for the definition variable k (0 or 1).
plot(x = algebra_results[["a"]]$k,
y = algebra_results[["a"]]$algebra_result)
Run the code above in your browser using DataLab