Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: simulate maximum likelihood estimation--where to construct the random variables


From   "Jun Xu" <[email protected]>
To   [email protected]
Subject   st: simulate maximum likelihood estimation--where to construct the random variables
Date   Sat, 27 Aug 2005 12:15:36 -0500

A while ago, Professor Stephen P. Jenkins and Arne Uhlenforff had exchanges on this:

Arne Uhlenforff <[email protected]> wants to estimate a MNL model with a random intercept using simulated ML (rather than using -gllamm-).

**********
I haven't looked at your program in detail, but one thing that strikes me is that I think you are not treating the pseudo-random uniform draws correctly. You want 50 replications/draws per ML iteration, but are creating them anew every iteration -- you shouldn't. They should be created just once. (See e.g. the gory details of the code underlying -mvprobit- or associated SJ article.) I don't know if this is having knock-on effects elsewhere.

good luck
Stephen
***********

I am also trying to write some codes on simulated ml as practice. I did it in two ways, a first method is to generate 100 random variables outside the loop as below; a second method is to create `ed`i' (the random variable) anew in each iteration.

Method 1:
forval i = 1/100 {
tempname ed`i'
gen double `ed`i'' = ...whatever ways to generate the random variable
}

qui forval i = 1/100 {
replace `sp'= `sp' * (invlogit(`xb' + `ed`i'')) if $ML_y1 == 1
replace `sp'= `sp' * (invlogit(-(`xb' + `ed`i''))) if $ML_y1 == 0
}

qui replace `lnf' = ln(`sp')

Method 2:
forval i = 1/100 {
tempname ed`i'

}

qui forval i = 1/100 {
gen double `ed`i'' = ...whatever ways to generate the random variable
replace `sp'= `sp' * (invlogit(`xb' + `ed`i'')) if $ML_y1 == 1
replace `sp'= `sp' * (invlogit(-(`xb' + `ed`i''))) if $ML_y1 == 0
}

qui replace `lnf' = ln(`sp')

Strangely enough Method 1 will converge and Method 2 will never converge. I am not sure if this is what Professor Jenkins talked about and why it is so? I will appreciate any thoughts on this.

Jun Xu
Ph.D. Candidate
Department of Sociology
Indiana University at Bloomington

_________________________________________________________________
On the road to retirement? Check out MSN Life Events for advice on how to get there! http://lifeevents.msn.com/category.aspx?cid=Retirement

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index