Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: Problems in maximising a likelihood function


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: Problems in maximising a likelihood function
Date   Fri, 16 Jun 2006 09:11:05 +0100

One source of weird bugs is if any of 
your scalar names is interpretable as
a variable name. Using temporary names
for your scalars would fix that. 

This is discussed for example in Tip 
31 of Stata Journal 6(2). 

Nick 
n.j.cox@durham.ac.uk 

> There may be a moral here, but that scalars
> are a disaster for holding constants and 
> that temporary variables are better really 
> cannot be inferred from the story you 
> present. In essence, you assert that, 
> but present no evidence. I suspect some
> other explanation for your problems, but 
> I do not know what it is. 
> 
> Nick 
> n.j.cox@durham.ac.uk 
> 
> Deepankar Basu
>  
> > Nick,
> > 
> > There is a world of difference between scalars and 
> temporary variables
> > (generated as -double-) at least in the context of -ml- 
> > estimation. As I
> > discovered the hard way, after several days of labour.
> > 
> > When I had first written the program there were several mistakes. I
> > corrected them over many iterations, with help and advice from
> > statlisters. But, I also changed my temporary variables to 
> > scalars, and
> > that was a disaster. 
> > 
> > Because, when I had corrected everything else in the program, I was 
> > still not getting convergence because of scalars. I had tried 
> > everything
> > and was almost on the verge of giving up; then it struck me 
> > as a passing
> > thought that maybe I should just try using temporary variables once
> > again. I did so and presto! There was convergence!
> > 
> > Moral of the story: never use scalars in -ml- estimation; use 
> > temporary
> > variables (if you need them) and generate them as -double-. 
> > And only as
> > -double-.
> > 
> > Deepankar
> > 
> > On Thu, 2006-06-15 at 21:48 +0100, Nick Cox wrote:
> > > Quite so. I spoke too soon on that detail. 
> > > 
> > > Nick 
> > > n.j.cox@durham.ac.uk 
> > > 
> > > Deepankar Basu
> > >  
> > > > But I cannot clean up the expression for the log likelihood 
> > > > any further.
> > > > As I had said earlier, the log likelihood for each 
> > > > observation is of the
> > > > following form: ln(a+b); where 'a' and 'b' are huge expressions
> > > > involving exponentials, etc. I don't see how I can 
> simplify it any
> > > > further; 
> 

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



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index