Mediation question using brms


#1
  • Operating System: Mac OSX
  • brms Version: 2.30

I’m attempting to do a multilevel mediation analysis. The dv is a likert scale response which I am modeling with a cumulative distribution (logit link). The mediator is categorical (Yes / No). When calculating the ab path, I am wondering if I can multiply the a and b coefficients directly (as below).

Knowledge_Judgment_mod <- bf(KnowledgeResponse ~ Condition + CounterfactualResponse + (1|Subject), family = “cumulative”)

Counterfactual_mod <- bf(CounterfactualResponse ~ Condition + (1|Subject), family = “bernoulli”)

model1 <- brm(Knowledge_Judgment_mod +
Counterfactual_mod,
set_rescor(FALSE),
data=data1,
iter=3000,
warmup=1500,
control = list(adapt_delta = .90),
prior = c(set_prior(“normal(0,1)”, class = “b”)))

a <- posterior_samples(model1, pars = “CounterfactualResponse_ConditionSpecific”)
b <- posterior_samples(model1, pars = “KnowledgeResponse_CounterfactualResponse”)
a_b <- a*b

summary(a_b)

CI_Model1_Mediation <- quantile(a_b$b_CounterfactualResponse_ConditionSpecific, probs = c(.025,.975))

CI_Model1_Mediation


#2

That approach seems to be right from what I see.


#3

Maybe this is of interest for you: I have drafted a function, mediation(), that prints a compact summary especially for mediation analysis (similar to the output from the mediation package).

You can see examples in a vignette here:
https://strengejacke.github.io/sjstats/articles/bayesian-statistics.html#summary-of-mediation-analysis

There’s a comparison of brms to the mediation package, and the results look good!

You need the current dev-version of sjstats to check out the mediation()-function.