Hi!
I'm estimating a path model in lavaan with a mediating variable that is binary. I have both binary and continuous exogenous variables. I have more variables, but this is a simplified version of my syntax in lavaan:
path_model = '
ln_A ~ b1*ln_B + b2*ln_C + b3*D + b4*E + b5*F
D ~ b6*E + b7*F
# indirect effects
indirect_E := b3*b6
indirect_F := b3*b7
# total effects
total_E := b4 + (b3*b6)
total_F := b5 + (b3*b7)
# Fit the models
fit = sem(path_model, data = df, ordered = "D")
Everything looks fine when I estimate the model like this using the DWLS estimator.
I wanted to add covariances between the exogenous variables, but I get an error message when I try to do it in R. It seems that it's because fixed.x = TRUE and conditional.x = TRUE. I tried changing to fixed.x = FALSE, but then I also have to change to conditional.x = FALSE. When I do this I get a negative variance, so I know that the estimation is incorrect.
I'm new to statistics and lavaan, so I would highly appreciate help!
This is the error message that I get in R when I try to add covariances:
Warning messages:
1: In muthen1984(Data = X[[g]], wt = WT[[g]], ov.names = ov.names[[g]], :
lavaan WARNING: trouble constructing W matrix; used generalized inverse for A11 submatrix
2: In lav_model_vcov(lavmodel = lavmodel, lavsamplestats = lavsamplestats, :
lavaan WARNING:
The variance-covariance matrix of the estimated parameters (vcov)
does not appear to be positive definite! The smallest eigenvalue
(= -1.422309e-18) is smaller than zero. This may be a symptom that
the model is not identified.
3: In lav_object_post_check(object) :
lavaan WARNING: some estimated ov variances are negative
I wanted to add covariances between the exogenous variables