Moderated mediation with binary independent and dependent variable

200 views
Skip to first unread message

Carina Hörst

unread,
Jun 15, 2019, 12:14:54 PM6/15/19
to lavaan
I am measuring the effect of belonging to an experimental condition (0,1) on a dichotomous dv, mediated by a continous variable. The path between X and M can be theoretically justified as being moderated by another contiouns variable. I tried:

model <- 'cso ~ a*cond + w*cn + aw*cond:cn
pet_sign ~ c*cond + b*cso

ab0 := a*b + 0*w

ab1 := ab0 + 1*w'

(cso= M; cond = X; cn = W; pet_sign = Y)

when I run the model i get the error message:

"some variables have no values (only missings) or no variance", I assume this is the case because my X is dichotomous and 0 and 1.

Please, does anybody know how to approach this the best? And whether the syntax is correct at all?

Thank you
Carina





Carina Hörst

unread,
Jun 16, 2019, 10:42:47 AM6/16/19
to lavaan
I have updated my matrix to:

empower_mod.mod <- 'conf ~ a1*cond + a2*cn.c + a3*cond:cn.c
pet_sign ~ cdash1*cond + cdash2*cn.c + cdash3*cond:cn.c + b1*conf

cn.c ~ cn.c.mean*1

cn.c ~~ cn.c.var*cn.c

indirect.SDbelow := (a1 + a3*(cn.c.mean-sqrt(cn.c.var)))*b1
indirect.SDabove := (a1 + a3*(cn.c.mean+sqrt(cn.c.var)))*b1

direct.SDbelow := cdash1 + cdash3*(cn.c.mean-sqrt(cn.c.var))
direct.SDabove := cdash1 + cdash3*(cn.c.mean+sqrt(cn.c.var))

total.SDbelow := direct.SDbelow + indirect.SDbelow
total.SDabove := direct.SDabove + indirect.SDabove

prop.mediated.SDbelow := indirect.SDbelow / total.SDbelow
prop.mediated.SDabove := indirect.SDabove / total.SDabove

index.empower_mod := a3*b1'

However, I still get the same error (assuming it is STILL my dummy coded condition variable (0,1) which causes the problem. But I cant find any approach how to bypass this problem..

Terrence Jorgensen

unread,
Jun 17, 2019, 5:22:45 PM6/17/19
to lavaan
"some variables have no values (only missings) or no variance", I assume this is the case because my X is dichotomous and 0 and 1.

Is X the variable with no variance, or no observations?  These are your variable names:

myVars <- c("cond","cn","conf","pet_sign")


Check whether any are all missing:

sapply(myData[myVars], function(x) all(is.na(x)))


Check whether any have zero variance (i.e., they are all the same value, so constant rather than variable):

sapply(myData[myVars], function(x) sd(x, na.rm = TRUE) == 0)



whether the syntax is correct at all?

No, you are treating "w" like the moderating effect of the moderator on "a", instead of the simple effect of the moderator.  "aw" is the degree to which "a" changes as the moderator increases.

ab0 := (a + 0*aw)*b
ab1
:= (a + 1*aw)*b
ab2
:= (a + 2*aw)*b
# etc...

Your second post looks correct, with (a1 + a3*...).

Terrence D. Jorgensen
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam

Carina Hörst

unread,
Jun 25, 2019, 8:11:20 AM6/25/19
to lavaan
Thank you for that! In the meanwhile I had to change my model radically so that I no longer have to test a moderated mediation but a mediation only. However, I am becoming desperate: I cant find a way how to compute OR of a mediation with a binary outcome variable in lavaan. Is there any way to do so? I know there is when you apply glm but I cant find any way in lavaan..

Thank you!

Terrence Jorgensen

unread,
Jun 25, 2019, 11:00:51 AM6/25/19
to lavaan
I cant find a way how to compute OR of a mediation with a binary outcome variable in lavaan. Is there any way to do so? 

An odds ratio is the exponentiation of a logistic regression slope.  lavaan does not offer the logit link, only the probit link.  But you can make user-defined parameters that calculate expected probabilities from slopes and intercepts/thresholds at levels of the predictor you are interested in comparing, then use those probabilities to calculate the odds ratio.  See slide 25 for the syntax example (whole example on slides 22-26).

Reply all
Reply to author
Forward
0 new messages