Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: disequilibrium model
From
Boon Ping Hong <[email protected]>
To
[email protected]
Subject
st: disequilibrium model
Date
Mon, 17 Feb 2014 03:23:30 +0000
Hi,
Im writing stata codes for disequilibrium model as set up on Maddala and Nelson (1974). I tried with the basic lf method first before into the first and second derivatives, but still errors.
Anyone like to check the codes for me?
The following are the underlying model and log likelihood:
Dt = B1X1t + u1t
St = B2X2t + u2t
Qt = min(Dt, St)
Dt and St are unobserved variables, only Qt is observed.
X1t and X2t are vectors of observable exogenous variables.
f1(Qt) and f2(Qt) are the probability density functions of Qt, and F1 and F2 are cumulative density function of Qt.
the log likelihood function is :
Log [ f1*F2 + f2*F1 ]
Below is the stata code i wrote:
program mydiseq
version 10
args todo b lnf
tempvar theta1 theta2 s1 s2 G
mleval 'theta1'='b'
mleval 'theta2'='b', eq(2)
mleval ‘s1’=‘b’, eq(3), scalar
mleval ‘s2’=‘b’, eq(4), scalar
scalar ‘s1’=exp(‘s1’)
scalar ‘s2’=exp(‘s2’)
quitely gen double 'G' = ((1/s1)*normalden($ML_y1,'theta1','s1')*normal($ML_y1,'theta2','s2'))+((1/s2)*normalden($ML_y1,'theta2','s2')*normal($ML_y1,'theta1','s1'))
mlsum 'lnf' = ln('G')
Please check the codes for me and your help is very much appreciated.
Thanks.
Matt
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/