duplicate model element - lavaan

167 Views Asked by At

I am running a SEM with lavaan for mediation analysis and am running into this error:

lavaan ERROR: duplicate model element in: Outcome ~ b*mediator + covariate + covariate + covariate + covariate

What does the error mean? Thank you!

model_1 <- ' # direct effect
             Outcome ~ c*Variable + covariate + covariate + covariate + covariate
             
           # mediator (indirect effect)
             mediator ~ a*Variable +covariate + covariate + covariate + covariate
             Outcome ~ b*mediator + covariate + covariate + covariate + covariate

           # indirect effect (a*b)
             indirect := a*b
           # total effect
             total := c + (a*b)
             direct := c
         '
fit_1 <- sem(model_1, 
           data = data, 
           missing = "ML")
1

There are 1 best solutions below

0
On

I means you have specified the same parameter multiple times. This is because you specify the same variable name covariate repeatedly on the right-hand side of an equation.