# Specify the population model
model_simple_med <-
"
m ~ x
y ~ m + x
"
# Specify the effect sizes (population parameter values)
model_simple_med_es <-
"
y ~ m: l
m ~ x: m
y ~ x: n
"
# Generate some datasets to check the model
sim_only <- power4test(nrep = 4,
model = model_simple_med,
pop_es = model_simple_med_es,
n = 100,
R = 50,
ci_type = "boot",
fit_model_args = list(fit_function = "lm"),
do_the_test = FALSE,
iseed = 1234)
# Do the test 'test_indirect_effect' on each datasets
test_out <- power4test(object = sim_only,
test_fun = test_indirect_effect,
test_args = list(x = "x",
m = "m",
y = "y",
boot_ci = TRUE,
mc_ci = FALSE))
# Do the test 'test_parameters' on each datasets
# and add the results to 'test_out'
test_out <- power4test(object = test_out,
test_fun = test_parameters)
# Compute and print the rejection rates for stored tests
rejection_rates(test_out)
# See the help pages of power4test_by_n() and power4test_by_es()
# for other examples.
Run the code above in your browser using DataLab