Hi,
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).
Does anyone have a suggestion how to model this? I really appreciate
any advices.
Best, Lenny
ps: I have the program in TSP also where it works fine. I can sent
that also if it is helpful
*
* 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/