# Specify the model
model_simple_med <-
"
m1 ~ x
m2 ~ x
y ~ m1 + m2 + x
"
# Specify the population values
model_simple_med_es <-
"
y ~ m1: s
m1 ~ x: m
y ~ m2: s
m2 ~ x: l
y ~ x: n
"
# Simulate the data
sim_only <- power4test(nrep = 5,
model = model_simple_med,
pop_es = model_simple_med_es,
n = 100,
R = 100,
do_the_test = FALSE,
iseed = 1234)
# Do the test in each replication
test_ind <- power4test(object = sim_only,
test_fun = test_k_indirect_effects,
test_args = list(x = "x",
y = "y",
mc_ci = TRUE))
print(test_ind,
test_long = TRUE)
# Set omnibus = "all_sig" to declare
# significant only if all paths are
# significant
test_ind_all_sig <- power4test(
object = sim_only,
test_fun = test_k_indirect_effects,
test_args = list(x = "x",
y = "y",
mc_ci = TRUE,
omnibus = "all_sig"))
print(test_ind_all_sig,
test_long = TRUE)
Run the code above in your browser using DataLab