I'm trying to bootstrap confidence intervals for my point-estimates of the indirect effects of a mediation model. Because it is actually (first-stage, a-path) moderated mediation, I need to actually do this three times, to find the indirect effect when my moderator (fiscal
below) is at the mean(fiscal) and +- 1 standard deviation.
I have estimated my model in two ways:
1. Using the mediation
package.
summary(model_m <- lm(unaccept_i ~ condition*fiscal, data=d1))
summary(model_y <- lm(redis_i ~ condition*fiscal + unaccept_i, data=d1))
mod_med <- mediation::mediate(model_m, model_y,
covariates = list(fiscal = 0),
treat="condition",
mediator="unaccept_i",
boot=T,
sims = 5000)
2. Using the psych
package.
psy_med <- psych::mediate(redis_i ~ condition*fiscal + (unaccept_i),
data=d1, plot=F, n.iter=5000)
I can either try to access the indirect effects from either of the two approaches above (if it that's possible? It's unclear) or by directly calculating it myself:
#conditional effect of X on Y through M: (a1 + a3*W)*b
a1 <- mod_med$model.m$coefficients[2]
a3 <- mod_med$model.m$coefficients[4]
b <- mod_med$model.y$coefficients[4]
cond_fx_pap <- tibble(fis_val = c(mean(d1$fiscal)-sd(d1$fiscal),
mean(d1$fiscal),
mean(d1$fiscal)+sd(d1$fiscal)),
cond_ind_fx = (a1 + a3*fis_val)*b)
The only problem is that this approach doesn't give me confidence intervals.
Is anyone able to figure out how to bootstrap/Monte Carlo simulate confidence intervals so I can plot the conditional indirect effects (a*b) at the mean and +- 1 SD of my moderator?
Thanks SO much in advance!
PS: Here is a slice of what the data look like:
df <- tibble(
redis_i = c(1.6666667, -1.3333333, 2.0000000, -0.6666667, 0.0000000, 1.3333333, 3.0000000, 4.3333333, -0.3333333, 3.3333333),
condition = c(0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5),
fiscal = c(3, 0, -2, -3, -1, -1, 1, 0, 1, -1),
unaccept_i = c(3.3333333, 1.2222222, 3.2222222, 2.2222222, -0.2222222, 2.2222222, 4.3333333, 5.0000000, 2.1111111, 1.1111111))