# ===== Simple mediation
# Set R to 5000 or 10000 in real studies
# Remove 'parallel' or set it to TRUE for faster bootstrapping
# Remove 'progress' or set it to TRUE to see a progress bar
out <- q_simple_mediation(x = "x",
y = "y",
m = "m",
cov = c("c2", "c1"),
data = data_med,
R = 40,
seed = 1234,
parallel = FALSE,
progress = FALSE)
# Suppressed printing of p-values due to the small R
# Remove `pvalue = FALSE` when R is large
print(out,
pvalue = FALSE)
# # Different control variables for m and y
# out <- q_simple_mediation(x = "x",
# y = "y",
# m = "m",
# cov = list(m = "c1",
# y = c("c1", "c2")),
# data = data_med,
# R = 100,
# seed = 1234,
# parallel = FALSE,
# progress = FALSE)
# out
# ===== Serial mediation
# Set R to 5000 or 10000 in real studies
# Remove 'parallel' or set it to TRUE for faster bootstrapping
# Remove 'progress' or set it to TRUE to see a progress bar
# out <- q_serial_mediation(x = "x",
# y = "y",
# m = c("m1", "m2"),
# cov = c("c2", "c1"),
# data = data_serial,
# R = 40,
# seed = 1234,
# parallel = FALSE,
# progress = FALSE)
# # Suppressed printing of p-values due to the small R
# # Remove `pvalue = FALSE` when R is large
# print(out,
# pvalue = FALSE)
# # Different control variables for m and y
# out <- q_serial_mediation(x = "x",
# y = "y",
# m = c("m1", "m2"),
# cov = list(m1 = "c1",
# m2 = c("c2", "c1"),
# y = "c2"),
# data = data_serial,
# R = 100,
# seed = 1234,
# parallel = FALSE,
# progress = FALSE)
# out
# ===== Parallel mediation
# Set R to 5000 or 10000 in real studies
# Remove 'parallel' or set it to TRUE for faster bootstrapping
# Remove 'progress' or set it to TRUE to see a progress bar
# out <- q_parallel_mediation(x = "x",
# y = "y",
# m = c("m1", "m2"),
# cov = c("c2", "c1"),
# data = data_parallel,
# R = 40,
# seed = 1234,
# parallel = FALSE,
# progress = FALSE)
# # Suppressed printing of p-values due to the small R
# # Remove `pvalue = FALSE` when R is large
# print(out,
# pvalue = FALSE)
# # Different control variables for m and y
# out <- q_parallel_mediation(x = "x",
# y = "y",
# m = c("m1", "m2"),
# cov = list(m1 = "c1",
# m2 = c("c2", "c1"),
# y = "c2"),
# data = data_parallel,
# R = 100,
# seed = 1234,
# parallel = FALSE,
# progress = FALSE)
# out
Run the code above in your browser using DataLab