Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mediation function cannot run on models with multiple mediators #586

Open
polisci-quant-nerd opened this issue Dec 19, 2022 · 0 comments
Open

Comments

@polisci-quant-nerd
Copy link

Hi,

I'm running some multilevel mediation analysis using brms and trying to use the mediation function from bayestestR to see the effect table. However, every time I run it gives me an error message. I think it's due to the fact the mediation function does not support more than one mediators?I have two mediators in the model:

f1 <- bf(outcome ~ lag_outcome + mediator_a + mediator_b + treatment_1 + treatment_2+control_vars + (1|group), family = "bernoulli")

f2 <- bf(mediator_a ~ lag_outcome + treatment_1 + treatment_2+control_vars + (1|group), family = "gaussian")

f3 <- bf(mediator_2 ~ lag_outcome + treatment_1 + treatment_2+control_vars + (1|group), family = "gaussian")

med_mod <- brm(f1 +
f2+
f3,
set_rescor(FALSE),
seed=1234,
data=df,
iter=5000,
warmup=2500,
control = list(adapt_delta = 0.99, max_treedepth=12),
chains = 2, cores = 2,
backend = "cmdstanr", threads = threading(2),
prior= c(set_prior("normal(0,10)", class = "b")))

How can I utilise the mediation function in this situation? I really like the output of the mediation function which mimics the easy-to-read output from the mediation package.

Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant