# \donttest{
# control parameters
n <- 100
a <- b <- c <- 0.4
# generate data
set.seed(20200309)
x <- rnorm(n)
m <- a * x + rnorm(n)
y <- b * m + c * x + rnorm(n)
simulated_data <- data.frame(x, y, m)
# perform boostrap tests
indices <- boot_samples(n, R = 5000)
robust_boot <- test_mediation(simulated_data,
x = "x", y = "y", m = "m",
robust = TRUE,
indices = indices)
summary(robust_boot)
ols_boot <- test_mediation(simulated_data,
x = "x", y = "y", m = "m",
robust = FALSE,
indices = indices)
summary(ols_boot)
# }
Run the code above in your browser using DataLab