Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# Re: st: SEM with categorical variables

 From Duru To statalist@hsphsun2.harvard.edu Subject Re: st: SEM with categorical variables Date Fri, 31 Aug 2012 12:23:27 +0200

```Thanks for the comments, and this code works well. But, when I feed
that correlation matrix into SEM in Stata it does not take into
account that the data is ordinal while calculating fit indices. I
don't know if this is really a problem, but Mplus' black box procedure
uses weighted least squares and probit regressions while estimating
the model and they mention that they make adjustments to obtain a
correct p-value etc.

Another thing is that my model will also include continuous predictors
then I need to calculate those correlations separately and combine it
with the polychoric correlation matrix which seems to require some
craftiness -as yours- with macros.

Best,

Duru

On Tue, Aug 28, 2012 at 7:37 PM, Stas Kolenikov <skolenik@gmail.com> wrote:
>
> So do you know exactly what Mplus does? Having the software decide for
> you what to do is good for exploratory phases, but for real research,
> you have to know what you are doing, and make sure the suggested
> default is appropriate for your analysis.
>
> Incidentally, I've been doing some polychoric-to-sem work earlier
> yesterday. Here's the outline:
>
> local thevars <varlist of the variables of interest>
> 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'
> sem ( your model structure comes here)
>
> Not terribly elegant, but that's way better than nothing. (Don't
> assume this will work as a black box; you would be much better off
> understanding what each line does.)
>
> On Tue, Aug 28, 2012 at 3:41 AM, Duru <duru80@gmail.com> wrote:
> > Dear all,
> > I am trying to estimate a structural equations model with Stata 12. I
> > have ordinal items for my latent dependent variable and categorical
> > manifest independent variables.
> > I am not clear on how to handle this. I have read somewhere on the web
> > that estimating polychoric correlations and feeding them into SEM
> > could be an option or specifying another estimation method (than ML)
> > would suffice? In Mplus I just need to specify those variables as
> > categorical and it chooses the proper method by default.
> >
> > Many thanks,
> >
> > Duru
> > *
> > *   For searches and help try:
> > *   http://www.stata.com/help.cgi?search
> > *   http://www.stata.com/support/statalist/faq
> > *   http://www.ats.ucla.edu/stat/stata/
>
>
>
> --
> -- Stas Kolenikov  ::  http://stas.kolenikov.name
> -- Senior Survey Statistician, Abt SRBI  ::  work email kolenikovs at
> srbi dot com
> -- Opinions stated in this email are mine only, and do not reflect the
> position of my employer
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```