Help calculating mediation effects with binary moderator

35 views
Skip to first unread message

blairmid

unread,
Oct 14, 2024, 11:02:23 AM10/14/24
to lavaan
Hi lavaan group,

I am trying to test a moderated mediation model that utilizes multilevel data (individuals in teams) and has a binary categorical moderator coded as 0 or 1. I am specifically interested in finding the indirect and direct effect sizes.

In other mediation models I've tested, I've used the average of the moderator +/- 1 SD to get the high and the low values, but with this model, the moderator is binary (0/1). To calculate the effect sizes, am I able to directly use a 0 or 1 in my calculations (see picture below) or do I need to use a different approach?

Here is an image of the model:
Model image.png

And the code I am currently using, where 0 and 1 have been plugged in directly for calculating effect sizes:
Path model code lavaan.png

Thank you for your help!



Here is the code as text for reference:
path_model_1 <- '

Mediator_T2 ~ a1*IV + a2*Moderator + a3*IV:Moderator
DV ~ c1*IV + c2*Moderator + c3*IV:Moderator + b*Mediator

indirect.effect.mod_equals_0 :=(a1+a3*0)*(b)
indirect.effect.mod_equals_1 :=(a1+a3*1)*(b)
indirect.effect.difference := indirect.effect.mod_equals_0 - indirect.effect.mod_equals_1

direct.effect.mod_equals_0 :=c1+c3*0
direct.effect.mod_equals_1 :=c1+c3*1
direct.effect.difference := direct.effect.mod_equals_0 - direct.effect.mod_equals_1

total.effect.mod_equals_0 := direct.effect.mod_equals_0 + indirect.effect.mod_equals_0
total.effect.mod_equals_1 := direct.effect.mod_equals_1 + indirect.effect.mod_equals_1
total.effect.difference := total.effect.mod_equals_0 - total.effect.mod_equals_1

'

fit_path_model_1 <- sem(model = path_model_1, data = path_model_data_1, 
                        cluster = "Team_assignment", bootstrap = 5000)
summary(fit_path_model_1, fit.measures = TRUE)
Reply all
Reply to author
Forward
0 new messages