Lavaan Mediation Code, Error: Object not found

Hey everyone, on very short notice I had to change plans for my uni project and do a mediation analysis via SEM using lavaan in R. Since I don't have a lot of knowledge in R, I've been following tutorials and code examples, however I can't get the model right, for some reason. Can someone take a look and tell me why I get the errors "object not found" for the paths a1-a4?

library(lavaan)
myModel <-'
SWM_KAT ~ b1*DERS_MEAN + b2*CTI_MEAN + b3*MASTERY_MEAN + b4*ED_SE_MEAN + c*SOB_MEAN

DERS_MEAN ~ a1*SOB_MEAN
CTI_MEAN ~ a2*SOB_MEAN
MASTERY_MEAN ~ a3*SOB_MEAN
ED_SE_MEAN ~ a4*SOB_MEAN

indirect1 := a1 * b1
indirect2 := a2 * b2
indirect3 := a3 * b3
indirect4 := a4 * b4
ind_x1_y1 := indirect1 + indirect2 + indirect3 + indirect4
tot_x1_y1 := ind_x1_y1 + c

DERS_MEAN ~~ CTI_MEAN
DERS_MEAN ~~ MASTERY_MEAN
CTI_MEAN ~~ MASTERY_MEAN
DERS_MEAN ~~ ED_SE_MEAN
CTI_MEAN ~~ ED_SE_MEAN
MASTERY_MEAN ~~ ED_SE_MEAN
'

From what I can tell, I'm not doing anything different than the examples and tutorials I've seen. If someone could help I'd be more than thankful!!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.