# Specify the population model
mod <-
"m ~ x
y ~ m + x"
# Specify the effect sizes (population parameter values)
es <-
"
y ~ m: m
m ~ x: m
y ~ x: n
"
# Generate several simulated datasets
data_all <- sim_data(nrep = 5,
model = mod,
pop_es = es,
n = 100,
iseed = 1234)
# Fit the population model to each datasets
fit_all <- fit_model(data_all)
fit_all[[1]]
# Fit the population model using the MLR estimator
fit_all_mlr <- fit_model(data_all,
estimator = "MLR")
fit_all_mlr[[1]]
# Fit a model different from the population model,
# with the MLR estimator
mod2 <-
"m ~ x
y ~ m"
fit_all_mlr2 <- fit_model(data_all,
mod2,
estimator = "MLR")
fit_all_mlr2[[1]]
Run the code above in your browser using DataLab