Lab 08: Mediation Answers

Lab 8

Published

April 18, 2024

Load Data

You can read in data from osf directly.

Code
library(tidyverse)
library(MeMoBootR)
library(lavaan)
library(easystats)
library(knitr)

url <- "https://osf.io/4yfwq//?action=download"

filename <- "Data.txt"

data <- read.delim(url, 
                   header = TRUE, 
                   sep = "\t",
                   dec = ".")

Tidy

  • Clean up the dataset from OSF
Code
med1 <- data %>% filter(mPFC.LAmyg_post !="N/A", emobiasscore != "N/A") %>%
  mutate(L_amyg_post=as.numeric(mPFC.LAmyg_post), emobias = as.numeric(emobiasscore), group=Group..1.inc..2.dec., L_amyg_pre=as.numeric(`mPFC.LAmyg_pre`)) %>%
  select(group, emobias, L_amyg_post, L_amyg_pre) %>%
  mutate(group=ifelse(group==1, -0.5, 0.5))

Simple mediation

Code
# fit regular mediation
library(JSmediation)

mediation_fit <- mdt_simple(med1,
             IV =group,
             DV = emobias,
             M  = L_amyg_post)

add_index(mediation_fit)
Test of mediation (simple mediation)
==============================================

Variables:

- IV: group 
- DV: emobias 
- M: L_amyg_post 

Paths:

====  ==============  =====  =======================
Path  Point estimate     SE  APA                    
====  ==============  =====  =======================
a             -0.087  0.030  t(145) = 2.86, p = .005
b              1.466  0.621  t(140) = 2.36, p = .020
c             -0.458  0.224  t(141) = 2.05, p = .042
c'            -0.313  0.228  t(140) = 1.37, p = .173
====  ==============  =====  =======================

Indirect effect index:

- type: Indirect effect 
- point estimate: -0.127 
- confidence interval:
  - method: Monte Carlo (5000 iterations)
  - level: 0.05 
  - CI: [-0.294; -0.0125]

Fitted models:

- X -> Y 
- X -> M 
- X + M -> Y 
  • The mdt_simple package does not allow for covars. You might get a sig total path if you do not include the pre-intervention measure. This differs from the paper. Below is how you can include the covariate.

Simple mediation with covariate

Code
library(MeMoBootR)

med1 <- mediation1(x =group,
             y = emobias,
             m  = L_amyg_pos, 
           cvs=c("L_amyg_pre"))

Lavaan

Here we are fitting a mediation model with lavaan (controlling for pre-intervention scores)

Code
library(lavaan)

sem1 <- '
#b and cp and covar
emobias ~ b * L_amyg_post + cp * group + covar*L_amyg_pre
#a
L_amyg_post ~ a * group
# indirect 1
indirect1 := a * b

# total
total := cp + (a * b) 

#prob mediated
#prop_indirect1
prop_med_1 := indirect1 / (indirect1+cp)
'

fit <- sem(model = sem1, data = med1, se = "bootstrap",  bootstrap = 5000)

# you should run 5000-10000 bootstraps
Code
lavaan::parameterestimates(fit, ci=TRUE, boot.ci.type = "perc") %>%
  kable()
lhs op rhs label est se z pvalue ci.lower ci.upper
emobias ~ L_amyg_post b 1.5057497 0.5480137 2.7476498 0.0060024 0.3713559 2.5768553
emobias ~ group cp -0.2813766 0.2392675 -1.1759916 0.2395983 -0.7644369 0.1843690
emobias ~ L_amyg_pre covar 0.6311997 0.4111107 1.5353522 0.1246973 -0.1425049 1.5130583
L_amyg_post ~ group a -0.0993187 0.0296157 -3.3535850 0.0007977 -0.1584107 -0.0417437
emobias ~~ emobias 1.6805662 0.2325273 7.2273918 0.0000000 1.2152160 2.1230316
L_amyg_post ~~ L_amyg_post 0.0313923 0.0077814 4.0342570 0.0000548 0.0172898 0.0473159
group ~~ group 0.2499878 0.0000000 NA NA 0.2499878 0.2499878
group ~~ L_amyg_pre -0.0108294 0.0000000 NA NA -0.0108294 -0.0108294
L_amyg_pre ~~ L_amyg_pre 0.0339821 0.0000000 NA NA 0.0339821 0.0339821
indirect1 := a*b indirect1 -0.1495492 0.0640000 -2.3367073 0.0194544 -0.2833115 -0.0313879
total := cp+(a*b) total -0.4309257 0.2268580 -1.8995393 0.0574936 -0.8724973 0.0215636
prop_med_1 := indirect1/(indirect1+cp) prop_med_1 0.3470416 34.0472892 0.0101929 0.9918674 -0.8055791 2.1192353

Write-up

Mediation analysis was carried out using the lavaan package in R. I tested whether left amygdala-mPFC connectivity post-intervention mediates the association between Condition and Positive Emotional Memory Bias. I controlled for the effects of pre-intervention amygdala-mPFC connectivity on the mediator and outcome variable. 10,000 bootstrap samples were used. I replicated the patterns of significance found by Cho et al. (2023). Effect estimates slightly varied from the original study, which may be due to the use of bootstrapping which involves random sampling.

In the present model (Figure 1), the bootstrapped indirect effect was significant, ab = -0.15, p = 0.02, 95% CI [-0.29,-0.029], standardized effect = -0.049. The direct effect was not significant, c’ = -0.279, p = 0.236, 95% CI [-0.756, 0.178] , standardized effect = -0.104. The total effect was not significant, c = -0.412, p = 0.068, 95% CI [-0.858, 0.028], standardized effect = -0.153. Thus, according to the causal steps approach, there was no mediation (the total path was no significant). However, according to the joint significance test and the boostrapped test, there was a significant mediation effect. Thus, the results indicate that post-intervention amygdala-mPFC connectivity mediated the association between Condition and bias scores. I really appreciate that the authors shared their data openly on OSF and OpenNeuro. However, the authors indicated in the paper that analysis material was also available, but I wasn’t able to find this. This would have been helpful to confirm how they specified their mediation model.