0

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))
wscampbell
  • 351
  • 2
  • 11
  • A naive bootstrap should be pretty easy with the package boot, although there are often validity issues that require refinements. The usual recommendation is to acquire and read the book on which that package is based. So votiong to close for two reasons: no effort at researching methods for bootstrapping, and no apparent effort at actually constructing code for bootstrapping. – IRTFM Mar 20 '19 at 16:04
  • Hi, thanks for your comment! I tried using the `boot` package but was unsuccessful since the estimate that I'm interested in isn't a term from the regression but rather a constructed term (a-estimate * b-estimate for a given level of my moderator, `fiscal`). As such I couldn't get the `boot` syntax working. But if you knew how, that'd be much appreciated! – wscampbell Mar 20 '19 at 16:09
  • 1
    I don't see how I (or anyone) could know how to fix such an issue since you failed to include any code for the failed bootstrap and also failed to include a way of constructing a test dataset. – IRTFM Mar 20 '19 at 16:12
  • Can you at least post sample data? Please edit **the question** with the output of `dput(d1)`. Or, if it is too big with the output of `dput(head(d1, 20))`. – Rui Barradas Mar 20 '19 at 16:12
  • @42-: So sorry about fumbling that. Didn't realize that you'd need that. I deleted my failed attempts at getting `boot` to work, but will work on recreating that now. – wscampbell Mar 20 '19 at 16:26
  • @RuiBarradas, thanks so much for the suggestion! I tried `dput` and even using `head` it proved to be way, way to ugly to repost (my data are 89 columns wide, with several of them being multi-sentence strings). Instead I added as a post script a sample of what my data look like. Is that enough? – wscampbell Mar 20 '19 at 16:28
  • Possible duplicate of [How to calculate confidence interval using the "bootstrap function" in R](https://stackoverflow.com/questions/53533829/how-to-calculate-confidence-interval-using-the-bootstrap-function-in-r) – jay.sf Mar 20 '19 at 17:09
  • @jay.sf Thanks SO much for the tip! Unfortunately that's not quite what I'm looking for. That approach--which I was able to on my own before posting--gives me the CI for the estimate of the indirect effect. With my ultimate goal being a plot of the indirect effect with confidence intervals, I need CI's around each estimate for each value of the moderator (`fiscal`). Thanks for trying, though. – wscampbell Mar 20 '19 at 18:31

0 Answers0