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: component order for fmm


From   Scott Merryman <[email protected]>
To   [email protected]
Subject   Re: st: component order for fmm
Date   Tue, 21 Aug 2012 12:28:21 -0500

To assign stocks into different portfolios it might be easier to
-collapse- the data based on the latent class membership, sort on the
average return, designate the various levels, and then re-merge- back
to the original data.

For example:

clear
qui {
set seed 891234
set obs 3
gen id = _n
expand 100
gen y = rnormal(50,10) if id == 1
replace y = rnormal(100,10) if id == 2
replace y = rnormal(150,10) if id == 3
save foo,replace

fmm y , components(3) mix(normal) from(50 100 150 1 1 1 1 1)
fmmlc, savec
noisily: tab _cla id
save foo1.dta,replace
collapse y, by(_class_1)
sort y
gen level = "low" in 1
replace level = "medium" in 2
replace level = "high" in 3
merge 1:m _class using foo1
noisily:  tabstat y , by(level)

//Components will be the reverse order
use foo,clear
fmm y , components(3) mix(normal) from(150 100 50  1 1 1 1 1)
fmmlc, savec
noisily: tab _cla id
save foo2.dta,replace
collapse y, by(_class_1)
sort y
gen level = "low" in 1
replace level = "medium" in 2
replace level = "high" in 3
merge 1:m _class using foo1
noisily: tabstat y , by(level)
}


Scott


On Tue, Aug 21, 2012 at 11:16 AM, YANNAN SHEN <[email protected]> wrote:
> Scott,
> Thank you so much for your reply and advice! It matters because I try to use the fmm identification to assign stocks into two portfolios- the portfolio that consists higher constant  stocks and the one with lower constant stocks.
>
> I am running the fmm command every month and with shuffled identification, I need to check and edit my result data to make sure they are in the right place.
>
> I appreciate your help very much but I cannot help asking a question: I know initial values are important for EM algorithm and different starting points may lead to different results, will this somewhat alter my results?
>  Thanks!
> Best
>
*
*   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/


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