Now I have 14 variables (7 of them are binary and the other 7 are ordinal) and I want to conduct CFA and SEM analysis, but none of my variables are continuous, so I think it's better to compute the polychoric correlation first, and then use the polychoric matrix to do the CFA and SEM. So I tried the following code in Stata:
local thevars ..."list of variables goes here"...
polychoric `thevars'
mat polychR = r(R)
forvalues i=1/`: word count `thevars' ' {
forvalues j=1/`i' {
local setcor `setcor' `=polychR[`i',`j']'
}
if `i' < `: word count `thevars' ' local setcor `setcor' \
}
local N = _N
clear
ssd init `thevars'
ssd set obs `N'
ssd set cor `setcor'
However, Stata keeps giving this error:
matrix not positive semidefinite One or more numeric values are incorrect because real data can generate only positive semidefinite covariance or correlation matrices. r(459);
So my question is, in order to do SEM, how to fix this "not positive semidefinite" matrix and feed this polychoric correlation matrix into Stata by "ssd" syntax? If the Stata code can be provided, that'll be very much appreciated.
Thanks.
Comment