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

RE: st: RE: simulated maximum likelihood estimation


From   "Jun Xu" <mystata@hotmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   RE: st: RE: simulated maximum likelihood estimation
Date   Mon, 09 May 2005 13:13:12 -0500

Sorry for that mistake. The following is a revised version. Still encounter difficulty calculating numerical derivatives. I don't think it's data problem. I tried to look into mvprob_ll.ado by Dr. Cappellari and Dr. Jenkins, and I am stuck there. No one is responsible for solving my problem, except myself; however, I do need some even slight hint to get me through.

********************************
set trace off
set more off
cap program drop my_ll
program my_ll
version 8.2
args lnf xb
tempname b sp0
sca `b' = 5

forval i = 1/100 {
tempname ed`i' like`j' sp`i'
gen double `sp`i'' = 0
}

gen double `sp0' = 1

qui replace `lnf' = 0
forval i = 1/100 {
loc j = `i' - 1
qui gen double `ed`i'' = -ln(uniform())*`b'
qui replace `sp`i''= `sp`j''*(invlogit( `xb'+`ed`i'')) if $ML_y1 == 1
qui replace `sp`i''= `sp`j''*(invlogit(-(`xb'+`ed`i''))) if $ML_y1 == 0
}

qui replace `lnf' = ln(`sp100')
end

use binlfp2.dta, clear
ml model lf my_ll (lfp = k5 k618 age), technique(nr bhhh dfp bfgs)
ml search
ml maximize

**************************************************

Jun Xu
Ph.D. Candidate
Department of Sociology
Indiana University at Bloomington
http://mypage.iu.edu/~junxu/home





From: "Nick Cox" <n.j.cox@durham.ac.uk>
Reply-To: statalist@hsphsun2.harvard.edu
To: <statalist@hsphsun2.harvard.edu>
Subject: st: RE: simulated maximum likelihood estimation
Date: Mon, 9 May 2005 01:11:33 +0100

I am not sure exactly what you are trying
to do here. It is usually better to set
up a log likelihood function directly. What
you are logging here does not have the usual
form of a likelihood function.

Nick
n.j.cox@durham.ac.uk

Jun Xu

> I am not sure if some expert could give me some hint about
> where to go. Here
> I am trying to estimate a logit with an added expotential
> distributed random
> error (with mean of 5). I am using simualted mle with 100
> replications, but
> cannot get it converged. Not sure if I had a correct setup.
>
>
> set trace off
> set more off
> cap program drop my_ll
> program my_ll
>     version 8.2
>     args lnf xb
>     tempname b
>     sca `b' = 5
>
>     forval j = 1/100 {
>         tempname ed`j'
>     }
>
>     qui replace `lnf' = 0
>     forval i = 1/100 {
>         qui gen double `ed`i'' = -ln(uniform())*`b'
>         qui replace `lnf'= `lnf' + invlogit( `xb'+`ed`i'')
>   if $ML_y1 ==
> 1
>         qui replace `lnf'= `lnf' + invlogit(-(`xb'+`ed`i''))
>   if $ML_y1 ==
> 0
>     }
>
>     qui replace `lnf' = ln(`lnf')
> end
>
> use binlfp2.dta, clear
> ml model lf my_ll (lfp = k5 k618 age), technique(nr bhhh dfp bfgs)
> ml maximize
>
>
> initial:       log likelihood =   2948.488
> alternative:   log likelihood =  2952.4599
> rescale:       log likelihood =  2952.4599
> (setting optimization to Newton-Raphson)
> numerical derivatives are approximate
> flat or discontinuous region encountered
> Iteration 0:   log likelihood =  2949.0411  (not concave)
> numerical derivatives are approximate
> flat or discontinuous region encountered
> Iteration 1:   log likelihood =  2950.7797  (not concave)
> numerical derivatives are approximate
> flat or discontinuous region encountered
> no observations
> r(2000);
>

*
*   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/
_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/

*
* 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index