when I add an exogenous binary variable, residual variances of two indicators (njob, skill) become negative
$cov
inc001 wh0001 skill mwh21 njob ahtedu hleadr migrtd
income001 0.000
wh0001 -0.015 0.000
skill 0.059 -0.133 -0.016
mwh21 0.001 -0.016 0.012 0.000
njob 0.031 0.164 0.000 0.149 -0.021
ahtedu 0.022 -0.025 0.097 0.005 0.016 0.000
hleadera 0.002 -0.006 0.003 0.003 0.008 0.000 0.000
migrated 0.022 -0.033 -0.025 0.008 -0.003 0.000 0.002 0.000
In the above residual covariance matrix, residual variances of skill and njob become negative when migrated (binary) is added.
If I add non-binary variable, for example tedu01 (schooling years) while keeping njob and skill in model then residual variances of skill and njob are 0
$cov
inc001 wh0001 skill mwh21 njob ahtedu hleadr tedu01
income001 0.000
wh0001 -0.019 0.000
skill 0.036 -0.143 0.000
mwh21 0.001 -0.021 0.012 0.000
njob 0.029 0.148 0.000 0.170 0.000
ahtedu 0.018 -0.027 0.087 0.005 0.014 0.000
hleadera 0.001 -0.006 0.003 0.003 0.007 0.000 0.000
tedu01 0.015 -0.053 0.115 0.005 0.044 0.109 0.008 0.000
I try to remove both njob and skill from measurement part, then no issue occurs even when a binary variable is added
$cov
inc001 wh0001 mwh21 ahtedu hleadr prisct
income001 0.000
wh0001 -0.009 0.000
mwh21 0.000 -0.004 0.000
ahtedu 0.032 -0.020 0.003 0.000
hleadera 0.002 -0.007 0.004 0.000 0.000
prisect -0.015 0.157 -0.011 0.000 -0.016 0.000
It seems that, the inclusion of exogenous binary variables makes the model invalid if covariances between exogenous variables are allowed.
How should I solve this issue?
1. In lavaan syntax, to allow such co-variances, I use two options: "fixed.x = FALSE,conditional.x = FALSE"so the command will be: sem(fit, data=data,std.lv = TRUE,fixed.x = FALSE,conditional.x = FALSE)Is that correct?
2. The above command only work with exogenous variables that have at least three values. When I add an exogenous binary variable, errors show up"Error in eigen(VarCov, symmetric = TRUE, only.values = TRUE) :infinite or missing values in 'x'In addition: Warning message:In sqrt(A1[[g]]) : NaNs produced"I don't understand why this happens and how to overcome it?