Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Maarten Buis <maartenlbuis@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

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/

**Follow-Ups**:**RE: st: problem 0 likelihood ml***From:*Olivier Francois <ofrancois@arec.umd.edu>

**References**:**st: problem 0 likelihood ml***From:*Olivier Francois <ofrancois@arec.umd.edu>

- Prev by Date:
**Re: st: Nested design problem** - Next by Date:
**Re: st: Nested design problem** - Previous by thread:
**Re: st: problem 0 likelihood ml** - Next by thread:
**RE: st: problem 0 likelihood ml** - Index(es):