Hi!
I am trying to build
a SEM
(3 predictors, 1 mediator, 1 outcome variable). The data comes from a repeated measures experiment, so all predictors are binary (
currently
coded as 0, 1;
class is numeric). (see a single level SEM plot below)
I want to build
a SEM
(mediation) model where several observations
are nested
within participant (
varibale
pp_number
).
My code looks
as follows
:
model_bitter_mlm<-' level: 1
bitter~ m*taste + l*colour+ j*descriptor
expected_bitter~ k*colour+ h*descriptor
#mediator
bitter~ i*expected_bitter
#indirect and total effects
##descriptor
hi := h*i
total1_within :=j+hi
##colour
ki:=k*i
total2_within := l+ki
level: 2
bitter~ g*taste + f*colour+ c*descriptor
expected_bitter~ d*colour+ a*descriptor
#mediator
bitter~ b*expected_bitter
#indirect and total effects
##descriptor
ab := a*b
total1_between :=c+(a*b)
##colour
db:=d*b
total2_between := f+(d*b)
'
bitter.out_mlm<-sem(model_bitter_mlm, data=all_merged, cluster="pp_number")
summary(bitter.out_mlm, standardized=TRUE)
Problem is that the output doesn't look right. lavaan does not end normally and only after 1 iteration.
Any idea what might be the problem? Thank you, I really struggle to find helpful resources online.