# st: RE: Maximum Likelihood Code Not Converging

 From "Nassar" <[email protected]> To <[email protected]> Subject st: RE: Maximum Likelihood Code Not Converging Date Tue, 25 Jan 2005 09:55:50 +0100

```Jason,

Can you track the value of the LogLike for each observation?
That can help you to identify why & for which observations are you getting
those large values.
It happens that for special observations, you can simplify your formulaes in
order to avoid numerical prob.
For example : f(lambda)=(1-exp(-n*lambda))/n
To be replaced by :
if (n<1e-20) f(lambda)=lambda else f(lambda)=(1-exp(-n*lambda))/n

When you can't simplify the formulae, you can to add a very small constant
to log expressions or to denominator in order to avoid locally and
temporarely log(0) or 1e-200/0 during the iterations. For the value of the
small term, you'll have to look carefully & closely to your data in oder to
avoid incongruent large values but not to alter computations..
or f(lambda)=(1-exp(-(n+err)*lambda))/(n+err)

Best regards
Naji

-----Message d'origine-----
De : [email protected]
[mailto:[email protected]]De la part de Jason Hwang
Envoye : mardi 25 janvier 2005 04:15
A : [email protected]
Objet : st: Maximum Likelihood Code Not Converging

Dear Statalist Users,

I'm trying to write a maximum likelihood estimation code for a probit
model with many endogenous variables. There is an existing procedure,
ivprob, which does this when you have a single endogenous variable (so
errors are assumed bivariate normal) but I'm trying to extend this to a
four-endogenous-variable case. The expressions that go into the likelihood
function are extremely long and messy but this is in principle a
straightforward generalization of the bivariate case so I think it should
work.

My ml program has passed "ml check" and I've searched for initial values
using "ml search" (I'm using the lf method.) However I am running into
numerical difficulties. I keep getting an error message saying

could not calculate numerical derivatives
missing values encountered

I've looked at the value of the log likelihood and I'm getting impossibly
large values. For example, one line I get before the program crashes says

rescale:  log likelihood = 6.18e+307

I can check my equations again but they all come from manipulations of
matrices in Mathematica so I doubt my formulas are wrong.

I've searched for this error message in the archive and on google as well

I would very much appreciate any advice from other users. Thanks very much

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