Statalist


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

Re: st: Re: Method lf evaluator code for heckman model


From   Glenn Goldsmith <[email protected]>
To   [email protected]
Subject   Re: st: Re: Method lf evaluator code for heckman model
Date   Tue, 19 May 2009 10:57:39 +0100

<>

I've not really thought through your code in detail, but
-1-normal(`x')- can often cause numerical problems. Replacing it with
-normal(-`x')- may help.

Glenn.

"Vincent, David" <[email protected]> wrote:

I would be most grateful if someone could advise me how to code method
lf for evaluating the log-likelihood function for the Heckman model. I
need to compute the MLE's for a range of sample selection type models
(options not available in STATA) and being new to programming, wanted
to start off with this well known model. The latent variable
specifications are:

yi*=x1i'b1+e1   (coded $ML_y1)
ti*=x2i'b2+e2   (coded $ML_y2)

And the code I have written is:


program dv2mle_lf
args lnf theta1 theta2 sd2 rho
tempvar A B C D
quietly {
      gen double `A'=ln(1-normal(`theta1'))
      gen double `B'=`theta1'-`rho'*(1/`sd2')*($ML_y2-`theta2')
      gen double `C'=sqrt(1-`rho'^2)
      gen double `D'=ln(normalden(($ML_y2-`theta2')/`sd2'))
      replace `lnf'=(1-$ML_y1)*`A'+$ML_y1*ln(normal(`B'/`C'))-$ML_y1*ln(`sd2')+$ML_y1*`D'
}
end


When I type:   ml model lf dv2mle_lf (theta1: y t = x1 x2 x3) (x1 x2)
() ()   STATA reports that the log likelihood = infinity and cannot be
evaluated. Any help would be gratefully appreciated!

Many thanks,
David.
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index