Statalist The Stata Listserver


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

st: ML model with sequential sample selection


From   "Geraldo Cerqueiro" <[email protected]>
To   [email protected]
Subject   st: ML model with sequential sample selection
Date   Fri, 02 Mar 2007 19:02:21 +0100

Dear all,

I'm estimating the following model:

I1*=Z1d1+e1
I2*=Z2d2+e2 (observed if I1*>0)
Y=Xb+u (observed if I1*>0 and I2*>0)

where (e1,e2,u) are trivariate normal. In terms of ML there are 3 contributions: P(e1<-Z1d1), P(e2<-Z2d2,e1<Z1d1) and f(Y|e1<Z1d1,e2<Z2d2)=P(e1<Z1d1,e2<Z2d2|u)*f(u) 

First, I estimate this model using the Heckman's two-step approach and use the estimates as starting values for the full ML model
The problem is that the Ml is not accepting the starting values of the correlation parameters (it returns error r(491)). Also, the ML model is converging to very extreme  values of the correlation parameters.
Can anyone take a look at the program and tell me whether I disregarded something? Thanks a lot!



capture program drop experim_lf
program experim_lf
	version 9.2
	args lnf z1d1 z2d2 xb sigma rho12 rho1u rho2u
	tempvar u cum1 cum2 rho
	quietly {
		scalar `rho12'=0
		gen double `u'=$ML_y3-`xb'
		gen double `cum1'=((`z1d1'-`u'*`rho1u'/`sigma')/sqrt(1-`rho1u'^2))	
		gen double `cum2'=((`z2d2'-`u'*`rho2u'/`sigma')/sqrt(1-`rho2u'^2))
		gen double `rho'=`rho12'-`rho1u'*`rho2u'
					
		replace `lnf'=ln(normal(-`z1d1')) if $ML_y1==0						

		replace `lnf'=ln(binormal(`z1d1',-`z2d2',-`rho12')) if $ML_y2==0

		replace `lnf'=ln(binormal(`cum1',`cum2',`rho'))+ln(normalden(`u',0,`sigma')) if $ML_y2==1 
							
		}
end




Geraldo


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index