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

From |
Maarten buis <maartenbuis@yahoo.co.uk> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: difficult ML program |

Date |
Tue, 4 Mar 2008 20:38:53 +0000 (GMT) |

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/

**Follow-Ups**:**Re: st: RE: difficult ML program***From:*"Lenny Stoeldraijer" <lennystoeldraijer@gmail.com>

- Prev by Date:
**Re: st: linear and quadratic trend analysis** - Next by Date:
**RE: st: RE: difficult ML program** - Previous by thread:
**st: linear and quadratic trend analysis** - Next by thread:
**Re: st: RE: difficult ML program** - Index(es):

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