Statalist


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

Re: st: RE: difficult ML program


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: difficult ML program
Date   Tue, 4 Mar 2008 21:08:14 +0000 (GMT)

If `theta1' = `theta2' than you can just replace all instances of
`theta2' with `theta1'. That is the whole point of that constraint. 

Also, if this is a survival model, have you looked at whether it is not
already implemented in -streg-?

Finally, if you want to use -ml- than "Maximum Likelihood Estimation
with Stata" by William Gould, Jeffrey Pitblado, and William Sribney
(http://www.stata.com/bookstore/mle.html) is invaluable.

Hope this helps,
Maarten


--- Lenny Stoeldraijer <lennystoeldraijer@gmail.com> wrote:

> Hi Maarten,
> 
> But how can I do that if the coefficient is multiplied by different
> covariates? Then I have a problem in defining the 'ml model lf
> myml'-part.
> 
> [I saw the redundancy too: it had something to do with how the ml
> function looked. But that would not give a problem, doesn't it?]
> 
> Best,
> 
> Lenny
> 
> 2008/3/4, Maarten buis <maartenbuis@yahoo.co.uk>:
> > generally, if you want to use the same parameter twice in a
> likelihood
> > function, than just do exactly that, i.e. use `theta1' both times
> and
> > remove `theta2' from the -args- command.
> >
> > also there is some redundancy:
> >
> > qui gen double `ua' = exp(...)
> > qui replace `lnf' = log(`ua')
> >
> > can be replaced by:
> >
> > qui replace `lnf' = ...
> >
> > -- Maarten
> >
> > --- Nick Cox <n.j.cox@durham.ac.uk> wrote:
> >
> > > My guess is that you need to hide less and show and explain more.
> > >
> > > If you -set trace on- where does the program crash?
> > >
> > > The error code you cite, 111, is invalid syntax, which by itself
> is
> > > not helpful.
> > >
> > > replace`lnf' = log(`ua')
> > >
> > > would very probably not work. There needs to be a space after
> > > -replace-.
> > >
> > >
> > > Nick
> > > n.j.cox@durham.ac.uk
> > >
> > > Lenny Stoeldraijer
> > >
> > > I'm trying to make my own maximum likelihood model, but I can't
> get
> > > it
> > > right. The first part looks okay (I think), but then I have to
> define
> > > the function which is called ua, which looks like:
> > > exp(uncc*(b+hazu)-exp(b)*survu), where b is the coefficient to be
> > > estimated. This coefficient is thus used twice but once with an
> > > exponential. So far, my code looks like this (I've left some
> parts
> > > out):
> > >
> > > program define myml
> > > args lnf covu lu0 lu1 lu2 ... theta1 theta2
> > > tempvar hazu survu ua
> > > quietly gen double `hazu' =
> `covu'+`lu0'+dtu1*`lu1'+dtu2*`lu2'+...
> > > quietly gen double `survu' =
> > > exp(`covu'+`lu0')*(btu0+btu1*exp(`lu1')+btu2*exp(`lu2')+...
> > > quietly gen double `ua' = exp(`theta1'+uncc*`hazu'-`theta2')
> > > replace`lnf' = log(`ua')
> > > end
> > > ml model lf myml (covu: ... , nocons) (luo: ... , nocons)
> (lu1:...)
> > > (lu2:...) ... (theta1: uncc) (theta2: `survu'), technique(bhhh)
> > >
> > > In the code I thus have different estimates for the b (once in
> theta1
> > > and once in theta2). I've tried to include a constraint (e.g.
> > > b1=log(b2)), but then I get errors (111 for example).
> > >
> > >
> > > *
> > > *   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/
> > >
> >
> >
> > -----------------------------------------
> > Maarten L. Buis
> > Department of Social Research Methodology
> > Vrije Universiteit Amsterdam
> > Boelelaan 1081
> > 1081 HV Amsterdam
> > The Netherlands
> >
> > visiting address:
> > Buitenveldertselaan 3 (Metropolitan), room Z434
> >
> > +31 20 5986715
> >
> > http://home.fsw.vu.nl/m.buis/
> > -----------------------------------------
> >
> >
> >      __________________________________________________________
> > Sent from Yahoo! Mail.
> > A Smarter Inbox. http://uk.docs.yahoo.com/nowyoucan.html
> > *
> > *   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/
> 


-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      __________________________________________________________
Sent from Yahoo! Mail.
A Smarter Inbox. http://uk.docs.yahoo.com/nowyoucan.html
*
*   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