Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RE thread: SEM with categorical variables


From   William Buchanan <[email protected]>
To   [email protected]
Subject   Re: st: RE thread: SEM with categorical variables
Date   Wed, 13 Mar 2013 07:42:52 -0700

I don't think it's a problem with Stas's code:

clear
set obs 1000
set seed 123412345
loc thevars hewsonstrong hewsonknowo hewsonint hewsoninspi hewsonmoral hewsoncom hewsondecent hewsondepend hewsonrel hewsonsens
foreach v of loc thevars {
	qui: g id=runiform()
	qui: sort id
	/* Create categorical variables */
	qui: egen `v' = cut(id), group(5) 
	/* Recode the variables to have a scale of 1-5 */
	qui: replace `v'=`v'+1
	qui: drop id
	ta `v'
}
di `"`thevars'"'
polychoric `thevars'

You should get the matrix below:

hewsonstrong   hewsonknowo     hewsonint   hewsoninspi   hewsonmoral     hewsoncom  hewsondecent  hewsondepend     hewsonrel    hewsonsens
hewsonstrong             1
 hewsonknowo     .00757784             1
   hewsonint    -.01262061    -.02690757             1
 hewsoninspi    -.02231892     .00686848    -.05248286             1
 hewsonmoral    -.01757277     .03654591    -.01172315     .00876538             1
   hewsoncom     .02118915    -.01551056    -.01772426    -.00254414    -.01837419             1
hewsondecent    -.04116923     .01386142     .01676589     .02919821     .02132269    -.03298761             1
hewsondepend    -.05280085    -.04659978     .04573638     .01585641     .06480197    -.01835768    -.02216604             1
   hewsonrel     .02682836    -.00184872    -.00382025     .01606113    -.03550408     -.0348673     .06411171    -.02613873             1
  hewsonsens     .02954704     -.0527784     .01723573    -.06313792     .00313384     .01654635     .02302709    -.00659043     -.0318338             1




On Mar 13, 2013, at 7:21 AM, Laura Maria Schwirz <[email protected]> wrote:

> I am referring to a previous thread (RE: sem with categorical
> variables, September 2012) as I have similar problems. I tried using
> Stas' code for polychoric to sem analysis but the local command
> appears to be a problem. If I type
> 
>> local thevars hewsonstrong hewsonknowo hewsonint hewsoninspi hewsonmoral hewsoncom hewsondecent hewsondepend hewsonrel hewsonsens
>> display `thevars'
>> polychoric `thevars'
> varlist required
> 
> It as actually empty so i can't proceed with the polychor command
> Any thoughts/ideas of where I am going wrong?
> 
> Thanks,
> Laura
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index