# Re: st: Question about ML

 From Cameron Hooper To statalist@hsphsun2.harvard.edu Subject Re: st: Question about ML Date Mon, 2 May 2005 21:51:30 -0400

I forgot to add I want to write program to do this specific maximization.

On May 2, 2005, at 9:46 PM, Cameron Hooper wrote:

Sorry for not being clear. Actually I think I may have misrepresented my problem. My main concern is numerical optimization. The function just happens to be a likelihood. The function is of the form:

L = sum(l)

where

l = log( exp(-2*e*T) * ( (1-a) * e^(B+S) + a*d*exp(-u*T) * (e^B) * (u+e)^s +
a * (1-d) * exp(-u*T) * (u+e)^B * (u+e)^B * e^S ) )

subject to the constraints: 0 <= a, d <= 1 and e, u >= 0. T is a constant.

The summation is over observations of B and S.

I would like to find the values of a,d,e,u that maximize the function and to estimate their standard errors.

Does this make sense? Can this even be done is Stata?

Cameron

On May 2, 2005, at 7:04 PM, Richard Williams wrote:

```At 01:23 PM 5/2/2005 -0400, Cameron Hooper wrote:
```
Hi

I have a question about using the -ml- command. I've had a look at the reference manual, but it's a bit over my head. I've seen the book about ML available from Stata, but I thought someone on this list might be able to help me out.
Cameron, I don't think it is clear what the question is. Are you just asking "How do I write a program to do this" or is there a more specific question you have in mind?

I found that I had pretty good luck copying large chunks of the code from the ML book verbatim. The tricky part, I think, is writing the likelihood evaluator and the other code that is unique to your problem.

*
* 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/

```*
*   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/

```
```*
*   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/
```