In my example, I have 2 mediators (M1 & M2) and 2 moderators (C & D). My predictor is X and my dependent variable is Y. So far I know how to handle multiple mediators:

multipleMediation <- '

Y ~ b1 * M1 + b2 * M2 + c * X

M1 ~ a1 * X

M2 ~ a2 * X

indirect1 := a1 * b1

indirect2 := a2 * b2

contrast := indirect1 – indirect2

total := c + (a1 * b1) + (a2 * b2)

M1 ~~ M2

'

How should I add the moderators to this example?

Any feedback would be much appreciated!

Kind regards,

Christoff

LikeLike

]]>I’d delete my comment because it’s such a silly mistake, but maybe others will make similar mistakes. Thanks!

This is the code without the effect of C that I ended up using:

myModel <- '

Y ~ b1 * M1 + b2 * M2 + c1 * X1 + c2 * X2

M1 ~ a1 * X1 + a2 * X2

M2 ~ a3 * X1 + a4 * X2

#indirect effects

indirect1 := a1 * b1

indirect2 := a3 * b2

indirect3 := a2 * b1

indirect4 := a4 * b2

# contrasts

con1 := a1 * b1 – a3 * b2

con2 := a2 * b1 – a4 * b2

con3 := (a1-a2) * b1

con4 := (a3-a4) * b2

# total effect

total1 := c1 + (a1 * b1) + (a3 * b2)

total2 := c2 + (a2 * b1) + (a4 * b2)

# covariates

M1 ~~ M2

'

LikeLike

]]>“Error in lav_data_full(data = data, group = group, cluster = cluster, :

lavaan ERROR: missing observed variables in dataset: c3 a5 a6”

Do you have any idea what this error could be? Thanks very much!

LikeLike

]]>How would you specify the correct error term for the logistic regression?

LikeLike

]]>LikeLike

]]>LikeLike

]]>LikeLike

]]>LikeLike

]]>LikeLike

]]>