# Specify the model
mod <-
"m ~ x
y ~ m + x"
# Specify the population values
es <-
"
y ~ m: m
m ~ x: m
y ~ x: n
"
# Generate the simulated datasets
dats <- sim_data(nrep = 5,
model = mod,
pop_es = es,
n = 100,
iseed = 1234)
# Fit the population model to each dataset
fits <- fit_model(dats)
# Combine the results to one object
sim_out_all <- sim_out(data_all = dats,
fit = fits)
sim_out_all
# Verify that the elements of fits are set to extra$fit
library(lavaan)
parameterEstimates(fits[[1]])
parameterEstimates(sim_out_all[[1]]$extra$fit)
parameterEstimates(fits[[2]])
parameterEstimates(sim_out_all[[2]]$extra$fit)
Run the code above in your browser using DataLab