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 |
Olivier Francois <ofrancois@arec.umd.edu> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
st: problem 0 likelihood ml |

Date |
Fri, 16 Nov 2012 14:45:27 +0000 |

Hi, 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. Since it wasn't working I went back to something simpler to make sure I was getting the commands right... A simple probit. I tried with my data but it wasn't working and so tried with some artificial data. Here is what I code and problems: //creating the data clear set more off set seed 12345 set obs 1000 matrix C = I(4) drawnorm z v e x, corr(C) replace z = sqrt(2)*z scalar a0 = 2 scalar a1 = -1 gen D = (a0 + a1*z > v) gen Y = 0.5 - 0.5*x + e //Probit model apture program drop myprobit program myprobit version 11.2 args lnf xgam quietly { if $ML_y1 == 0 { replace `lnf' = ln(normal(-`xgam')) } else if $ML_y1 == 1 { replace `lnf' = ln(normal(`xgam')) } } end //first model tried ml model lf myprobit (xgam: D = z), vce(robust) technique(nr bhhh dfp bfgs) ml check /*I get the following error: opt__eval_cycle(): 3301 subscript invalid opt__eval(): - function returned error _optimize_evaluate(): - function returned error _mopt__evaluate(): - function returned error mopt__check_test1(): - function returned error _moptimize_check(): - function returned error Mopt_check(): - function returned error <istmt>: - function returned error */ //second model tried ml model lf myprobit (xgam: D = z), vce(robust) technique(nr) ml check //This time, no subscript invalid error... ml check passes all the tests. Does anybody know why? //Please feel free to refer to online material, I couldn't find anything by myself. //Here I get another problem, however, with ml search ml search //initial: log pseudolikelihood = 0 //rescale: log pseudolikelihood = 0 //I get a value of 0. Sometimes the intital value is fine, but it goes to 0 when ml search does rescale sq (couldn't find what it is either). For example, with another data draw I get: //initial: log pseudolikelihood = -10.211373 //rescale: log pseudolikelihood = -10.211373 //rescale eq: log pseudolikelihood = 0 // I get it also using my own data. I don't understand why. //The direct stata probit command works fine. Thanks for any help, Olivier * * 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:*Maarten Buis <maartenlbuis@gmail.com>

**Re: st: problem 0 likelihood ml***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**Re: st: Nested design problem** - Next by Date:
**Re: st: problem 0 likelihood ml** - Previous by thread:
**st: How can I change Stata's regular expression parser to use Perl's parser, so that I can use perl compatible regular expressions (i.e. the same regular expression syntax that I use with Perl)** - Next by thread:
**Re: st: problem 0 likelihood ml** - Index(es):