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

st: difficult ML program

From   "Lenny Stoeldraijer" <>
Subject   st: difficult ML program
Date   Tue, 4 Mar 2008 15:22:05 +0100


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

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' =
quietly gen double `ua' = exp(`theta1'+uncc*`hazu'-`theta2')
replace`lnf' = log(`ua')
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:

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