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: problem 0 likelihood ml


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: problem 0 likelihood ml
Date   Fri, 16 Nov 2012 16:08:27 +0100

On Fri, Nov 16, 2012 at 3:45 PM, Olivier Francois wrote:
> I needed to create my own likelihood function and have been running into problems. I have been trying to use program and the ml commands, but there is something I must not do correctly.
<snip>
>     if $ML_y1 == 0 {
>         replace `lnf' = ln(normal(-`xgam'))
>     }
>
>     else if $ML_y1 == 1 {
>             replace `lnf' = ln(normal(`xgam'))
>     }

The way you have used -if- means that it takes a scalar, in this case
the first observation of the dependent variable, and checks whether it
is 0 or 1, and applies the likelihood computation for all observations
based on that test, compare -help if- with -help ifcmd-. What you want
is to tell Stata to check for each observation whether the dependent
variable is 0 or 1 and choose the appropriate log likelihood function
accordingly. You can do that as folows:

replace `lnf' = ln(normal(-`xgam')) if $ML_y1 == 0
replace `lnf' = ln(normal( `xgam')) if $ML_y1 == 1

alternatively:

replace `lnf' = $ML_y1*ln(normal(`xgam') + (1-$ML_y1)*ln(normal(-`xgam'))

The latter will allow you to estimate a probit and a fractional probit.

Hope this helps,
Maarten

---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------
*
*   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