Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# Re: st: Problem with ml maximize: numerical derivatives are approximate

 From Amir Fekrazad To statalist@hsphsun2.harvard.edu Subject Re: st: Problem with ml maximize: numerical derivatives are approximate Date Tue, 30 Nov 2010 00:44:32 +0330

```Thank you so much Maarten for your comments. My program returns log-likelihood.
One of my concerns is that whether Mata functions work well with
double-precision variables. In addition, is it possible to write a
complete MLE program in Mata or should I write functions with Mata and
then integrate them in my Stata program?

On Tue, Nov 30, 2010 at 12:26 AM, Maarten buis <maartenbuis@yahoo.co.uk> wrote:
> --- On Mon, 29/11/10, Amir Fekrazad wrote:
>> I wrote a program to estimate the elements of the inverse
>> variance-covariance matrix (Q=inverse(V)) of a joint
>> student t distribution.  <snip>
>> however, it never converges and I get the following message
>> with different datasets and data sizes:
>>
>> numerical derivatives are approximate
>> flat or discontinuous region encountered
>
> That typically means that there is an error your program.
> Anyone who has programmed has been where you are now. The best
> advise I can give you is to let it rest for a couple of days
> and after that look again at with fresh eyes.
>
> I did not check the entire program in detail, but there are a
> couple of things that struck me: Are you returning the likelihood
> or the log-likelihood? Given the names you used when you replaced
> `lnf' it looks like the likelihood, while -ml- expects the
> log-likelihood. The other thing I noticed is that you used Stata's
> matrix commands. That is not a good idea. Either go for Mata when
> you want to think in terms of matrices or use Stata when you
> prefer to think in terms of variables.
>
> Hope this helps,
> Maarten
>
> --------------------------
> Maarten L. Buis
> Institut fuer Soziologie
> Universitaet Tuebingen
> Wilhelmstrasse 36
> 72074 Tuebingen
> Germany
>
> http://www.maartenbuis.nl
> --------------------------
>
>
>
>
> *
> *   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/
>

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