model2 <- '#Regressions
Y ~ c*X + b*M
M ~ a*X
#variances and covariances
Y ~~ Y
M ~~ M
#indirect effect
ab := a*b
#total effect
tot := c + (a*b) '
--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at http://groups.google.com/group/lavaan?hl=en.
Hi there,
Is it possible to do a moderated mediation where I have two categorical independent variables (two categories), one categorical mediator (5 categories), and where the relationship between the mediator and the dependant variable is moderated by the two categorical independent variables
Starting from the previous syntax in this post, I would say that, it should be something like:
Y ~ c*X + c(b1,b2,b3,
b4, b5)*M
M ~ c(a1,a2,a3,a4,
a5)*X
...
ab1 :=
a1*b1
ab2 :=
a2*b2
ab3 :=
a3*b3
ab4 := a4*b4
ab5 := a5*b5
tot1
:= c1 + (a1*b1)
tot2
:= c2 + (a2*b2)
tot3
:= c3 + (a3*b3)
tot4 := c4 + (a4*b4)
tot5 := c5 + (a4*b4)
However, I don’t know how to add, if it is possible, the other independent variable??
If it is not possible (or even if it s possible), can I just create a latent variable with the two independent variables (I have a theoretical justification for it), and just do:
X =~ IND1 + IND2
Y ~ c*X + c(b1,b2,b3,
b4, b5)*M
M ~ c(a1,a2,a3,a4, a5)*X
...
ab1 :=
a1*b1
ab2 :=
a2*b2
ab3 :=
a3*b3
ab4 := a4*b4
ab5 := a5*b5
tot1
:= c1 + (a1*b1)
tot2
:= c2 + (a2*b2)
tot3
:= c3 + (a3*b3)
tot4 := c4 + (a4*b4)
tot5 := c5 + (a4*b4)
Thank you!
I would like to calculate the conditional indirect effects of X on Y given a set of values for the moderator (W). Both X and the moderator are continuous. Could you provide some direction for structuring the model syntax?
model <- '
Y ~ c*X + cw*XW + b*MM ~ a*X + aw*XW## indirect and total effects, conditional on W == 0ab0 := a*b # + 0*aw*b
total0 := ab0 + c # + 0*cw## indirect and total effects, conditional on W == 1ab1 := ab0 + 1*aw*btotal1 := ab1 + c + 1*cw## indirect and total effects, conditional on W == 2ab2 := ab0 + 2*aw*btotal2 := ab2 + c + 2*cw'
Theoretical model (see picture)
Script:
#Create interaction variable
LofData$I_PartPerSacrifice <- LofData$PartPerSacrifice * LofData$WFCtotal
#Covariance between PartPerSacrifice and WFCtotal
WFCtotal ~~ I_PartPerSacrifice
model3 =model3 ='
DistancingVrouw ~ c1*WFCtotal + cw*I_PartPerSacrifice + b1*PerSacrifice
PerSacrifice ~ a1*WFCtotal + aw*I_PartPerSacrifice
#Indirect effects and total effect, conditional on I_PartPerSacrifice == 0.
Indirect1:= a1*b1
total1 := c + (a1*b1)
XW agencyc negAffectc intMotivc1 3.833333 1.3215196 -0.59085684 0.97703782 4.512269 0.3770862 -0.02892351 -0.28552893 1.777767 -0.7340471 -0.59085684 -0.35629554 5.918972 0.2200196 0.57580982 0.35493785 7.777750 0.5992862 0.90914316 0.8103711
modMed <- '#direct effectsposAffect ~ c*agencyc + b*intMotivcintMotivc ~ a1*agencyc + a2*negAffectc + a3*XW#indirect and total effects, conditional on negAffectc == 0ab0 := a1*b
total0 := ab0 + c
#indirect and total effects, conditional on negAffectc == 1ab1 := a1*b + a3*b
total1 := ab1 + c
#indirect and total effects, conditional on negAffectc == 2ab2 := a1*b + 2*a3*b
total2 := ab2 + c
'
fsem4 <- sem(modMed, data = dat, se = "bootstrap", bootstrap = 1000
summary(modMed)
\n #direct effects\n posAffect ~ c*agencyc + b*intMotiv\n intMotiv ~ a1*agencyc + a2*negAffect + a3*XW\n #indirect and total effects, conditional on negAffect == 0\n ab0 := a1*b\n total0 := ab0 + c\n #indirect and total effects, conditional on negAffect == 1\n ab1 := a1*b + a3*b\n total1 := ab1 + c\n #indirect and total effects, conditional on negAffect == 2\n ab2 := a1*b + 2*a3*b\n total2 := ab2 + c\n
1
when I run this code ... I don't get any parameter output
summary(fsem4 )
A further question I have, is how I might be able to compute my conditional indirect effects at percentiles of the moderator (or standard deviations), as is done with PROCESS? I'm not 100% clear what we are conditioning here in this code, except for when W = 0 and W = 1.
quantile(dat$negAffectc, probs = c(.1, .5, .9))
The regression equation you have in the probing interaction line (ab0 := a*b # + 0*aw*b) suggest adding a product of w, aw and b paths, and not products of b path separately with a, aw and w paths
ModMed <- 'Policy ~ c*sdo.c + b2*Discrim + d*Legit
Discrim ~ a_2*sdo.c + b1*Legit
Legit ~ a*sdo.c + w*threat.c + aw*sdo_threat
IndirectLeg := (a*b1)+(w*aw*b1) #or should this be (a*b1)+(w*b1)+(aw*b1)
IndirectDis := a_2*b2
Total := c + (a*b1)+(w*aw*b1)+(a_2*b2) #so, this would be c + (a*b1)+(a*b1)+(w*b1)+(aw*b1)+(a_2*b2)
a_wm1 := a + aw*(-1)
a_w0 := a # + aw*0
a_wp1 := a + aw*1
--
You received this message because you are subscribed to a topic in the Google Groups "lavaan" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lavaan/RW_3TMARGhY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lavaan+un...@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.