get_individual_algebra_results {mxsem} | R Documentation |
evaluates algebras for each subject in the data set. This function is useful if you have algebras with definition variables (e.g., in mnlfa).
get_individual_algebra_results(
mxModel,
algebra_names = NULL,
progress_bar = TRUE
)
mxModel |
mxModel with algebras |
algebra_names |
optional: Only compute individual algebras for a subset of the parameters |
progress_bar |
should a progress bar be shown? |
a list of data frames. The list contains data frames for each of the algebras. The data frames contain the individual specific algebra results as well as all definition variables used to predict said algebra
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)