Hi all,
I am trying to run a Moderation mediation model with a latent Exogenous and a binary moderator and binary/ continuous mediators with a binary Response using lavaan::sem.
I have defined the equations for indirect and direct effects. I don't know how do we define the min and max of the interaction term, in this case, to calculate the indirect effect of X on response and test whether it is significant or not???? And also, how do we test whether the interaction term should be in the model or not?
Any guidance will be appreciated,
Farideh
# Exogenous= Latent variable X
# Moderator= PnP ( A binary variable/0 AND 1), affects only the relationship between latent variable and mediators
# Mediators are NSP (continuous), CAS and OS1 ( 0/1)
# PATHS : X-->CAS-->STI; X-->OS1-->STI; X--NSP-->OS1-->STI; X-->NSP-->CAS-->STI
# Endogenous variale= STI (0/1)
model <- '
# Latent Variables
X =~ TASP + TMT ## TASP is a likert scale 1 to 6 and TMT is a continuous 2 to 37
# Interaction term
XP =~ X*PnP ## How do we define the min and max of interaction term when a moderator is binary?
# regressions
NSP ~ a1*X + a4*XP
CAS ~ a2*X + a5*XP+d1*NSP
OS1 ~ a3*X + a6*XP+d2*NSP
STI ~ c*X + b2*CAS+ b3*OS1
# residual covariances
CAS ~~ OS1
# define indirect effects of x on STI via CAS only ; model: CAS= a2*X+a5*XP+d1*NSP ; NSP= a1*X+a4*XP
a5b2 := a5*b2*PnP ## It was a5*b2*XP , I defined the slop as the indirect effect ?????I think the problem is over here.
a2b2 := a2*b2
# define indirect effects of x on STI via OS1 only; Model: OS1=a3*X+a6*XP+d2*NSP
a6b3 := a6*b3*PnP
a3b3 := a3*b3
# define indirect effects of x on STI via CAS and OS1
a1b2d1:= a1*b2*d1
a1b3d2:= a1*b3*d2
a4b2d1P:= a4*b2*d1*PnP
a4b3d2P:= a4*b3*d2*PnP
Indirect := a2b2 + a3b3+a5b2+a6b3+a1b2d1+a1b3d2+a4b2d1P+a4b3d2P
Low_Indirect := a2b2 + a3b3+a5b2+a6b3+a1b2d1+a1b3d2 ## When moderator, PnP=0
HI_Indirect := a2b2 + a3b3+a5b2+a6b3+a1b2d1+a1b3d2+1*a4b2d1+1*a4b3d2
## When moderator, PnP=1
Total_Indirect := HI_Indirect-Low_Indirect
Total := c + Total_Indirect
Prop := Total_Indirect/Total'
fit<-lavaan::sem(model, data=data, ordered=c("CAS","OS1","STI"))
summary(fit,fit.measures=TRUE, modindices = TRUE )
Error in lav_partable_constraints_def(partable, con = LIST, debug = debug) :
lavaan ERROR: unknown label(s) in variable definition(s): PnP a4b2d1 a4b3d2
In addition: Warning message:
In lav_data_full(data = data, group = group, cluster = cluster, :
lavaan WARNING: some observed variances are (at least) a factor 1000 times larger than others; use varTable(fit) to investigate
>