Bayesian mediation in Blavaan

120 views
Skip to first unread message

Nico Polis

unread,
May 27, 2023, 8:24:06 AM5/27/23
to lavaan
Dear collective wisdom,

I am trying to understand bayesian mediation analyses but I am strugling with different issues. No matter the dozens of videos and papers I went through, some difficulties remain.

I have a standard model: 
mod2 <- "
          # a path
         Social_Environmental ~ a * Ideology

         # b path
         Behavioral ~ b1 * Social_Environmental

         # c prime path
         Behavioral ~ cp * Ideology

         # indirect and total effects
         ab := a * b
         total := cp + ab"


And explore it with the following code:

fit2 <- bsem(mod2, data = Etude.1.Jasp)
summary(fit2)

The result is as following : 
blavaan (0.4-7) results of 1000 samples after 500 adapt/burnin iterations Number of observations 514 Statistic MargLogLik PPP Value -1790.046 0.479 Regressions: Estimate Post.SD pi.lower pi.upper Rhat Prior Social_Environmental ~ Ideology (a) -0.304 0.080 -0.462 -0.147 1.000 normal(0,10) Behavioral ~ Scl_Envrn (b) 0.403 0.043 0.320 0.486 1.000 normal(0,10) Ideology (cp) -0.973 0.075 -1.125 -0.829 1.000 normal(0,10) Variances: Estimate Post.SD pi.lower pi.upper Rhat Prior .Socl_Envrnmntl 1.931 0.123 1.704 2.188 1.000 gamma(1,.5)[sd] .Behavioral 1.759 0.111 1.558 1.983 1.000 gamma(1,.5)[sd] Defined Parameters: Estimate Post.SD pi.lower pi.upper Rhat Prior ab -0.123 0.035 -0.191 -0.054 total -1.096 0.081 -1.255 -0.937



So first I suppose that the default priors do not fit well with the analyses. If I understood Liu et al., 2022 paper well, the priors for paths a and b, without specific assumptions, should be .50 (so the mediation path would be .25). How could I change these priors as the "normal(0,10)" corresponds to the "mean, SD"?

Second issue, how may I interpret a probability against the null hypothesis here? 

As I mentioned early, I am a newbie in bayesian mediation so any help would be super helpfull. I tried to find step by step explanations but surprisingly I was not able to find clear (at least for my level ^^) content.

Thank you all for your help !

Nicolas


Łukasz Stasiełowicz

unread,
May 28, 2023, 3:29:48 AM5/28/23
to lavaan

Hi,

Just to let you know: There is a dedicated blavaan group. 

The official website includes two vignettes which seem relevant in your case.

Mauricio Garnier-Villarreal

unread,
May 29, 2023, 3:46:50 PM5/29/23
to lavaan
I do not understand where is the problem. What do you mean by " If I understood Liu et al., 2022 paper well, the priors for paths a and b, without specific assumptions, should be .50 (so the mediation path would be .25) "?
Are those the results from the example data set? Please gice enough information without us having to go read the paper

If you are doing Bayesian and want to test a "null" hypothesis can follow my tutorial on probability of direction as pointed out in the previous answer

Nico Polis

unread,
May 30, 2023, 5:22:51 AM5/30/23
to lavaan
I think I miss the "publish" button in my previous answer.

So I read your tutorials that were super nice! Thank you for your work.

So, for the first experiment, I have a model with like  X -> M -> Y (simple one ^^). Following (if I did it correctly) your tuto, I did it with non-informed priors. In the second experiment, I am trying to build upon the first results and use the mean and variance (precision) with the prior function as "X*prior("normal(Mean,Precision)")" I observed in the first experiment (I took the mean of the descriptive stats in the first experiment, am I correct ?).

I also used the following function "hypothesis(mc_out, "indirect > total", alpha = 0.05) " to check the indirect total effect proportion.

I hope I understood everything correctly :)

Mauricio Garnier-Villarreal

unread,
May 30, 2023, 12:13:24 PM5/30/23
to lavaan
3 things here, first, from the summary of the blavaan object, you can use the "Estimate" from experiment 1 as the mean, and "Post.SD" as the standard deviation for the priors, yes
Second, the priors as in the form of normal(mean, sd), not with the precision. so by sure to use th correct metric. Also, I wouldnt recommend to use the same SD as before, as that might be too strong of a prior, Would recommend to use at least 3*SD. And would need to do a prior sensitivity analysis to be sure that is not too strong of a prior
Third, "hypothesis(mc_out, "indirect > total", alpha = 0.05) , this would test what proportion of the indirect effect is higher than the total effect, is that the proportion you want to test?
Reply all
Reply to author
Forward
0 new messages