' HECKMAN1.PRG (1.0 - 6/30/98) ' example program for EViews LogL object ' revised (3/7/2007) ' ' Heckman selection model with three regressors z1, z2, z3 ' (common to both selection and regression equations) ' selection equation: lfp=1 if selected; otherwise 0 ' regression model: lw (dependent) c z1 z2 z3 (regressors) ' ' for a discussion, see Section 20.4 of Greene, William H. (1997) ' Econometric Analysis, 3rd edition, Prentice-Hall 'change path to program path %path = @runpath cd %path ' load artificial data wfopen "C:\Documents and Settings\buck\My Documents\Econ8109\eviews6\mroz.wf1" ' get starting values from 2-step Heckman ' first step: estimate probit of the selection equation smpl @all equation eq1.binary(d=n,b) inlf c AGE AGESQ FAMINC EDUC KIDZ show eq1.output ' copy starting values to selection equation params coef(6) b = eq1.@coefs ' Probit values b(1) -4 b(2) 0.18 b(3) 0.002 b(4) 0.000003 b(5) 0.09 b(6) -0.44 ' compute inverse mills ratio eq1.fit(i) xbhat series imills = @dnorm(xbhat)/@cnorm(xbhat) ' compute delta to estimate sig2 (variance) series delta = imills*(imills+xbhat/eq1.@sddep) ' run second step OLS, including the inverse mills ratio smpl @all if inlf=1 equation eq2.ls WAGE C EXPER EXPERSQ EDUC CITY imills ' OLS values c(1) -2.56 c(2) 0.03 c(3) 0.000261 c(4) 0.48 c(5) 0.449 coef(6) b2=eq2.@coefs show eq2.output ' construct estimate of correlation rho (note: uses only estimation sample of 2nd step) eq2.makeresid resid2 ' initial estimate of the regression model variance scalar sig2 = @sumsq(resid2)/eq2.@regobs+@mean(delta)*(b2(6))^2 ' show sig2 ' initial estimate of the squared correlation between the two equations ' rho2 should be constrained between 0 and 1 scalar rho2 = ((b2(6))^2)/sig2 ' show rho2 ' end of 2 step Heckman ' set up log likelihood '!pie = @acos(-1) ' the constant pie logl ll1 ll1.append @logl logl1 ' index for selection equation ll1.append I_INLF = b(1) + b(2)*AGE + b(3)*AGESQ + b(4)*FAMINC + b(5)*EDUC + b(6)*KIDZ ' log probability if not observed ll1.append logp0 = log(1-@cnorm(I_INLF) ) ' fitted values from the regression model ll1.append F_WAGE = b2(1) + b2(2)*EXPER + b2(3)*EXPERSQ + b2(4)*EDUC + b2(5)*CITY ' standardized residual from the regression model ll1.append sres = (wage-F_WAGE)/@sqrt(sig2) ' index for observed regression model ll1.append index = (I_INLF+(sres*@sqrt(rho2))/@sqrt(sig2))/@sqrt(1-rho2) ' log probability if observed ll1.append logp1 = -log(2*@acos(-1))/2-0.5*log(sig2)-(sres^2)/(2*sig2)+log(@cnorm(index)) ' specify contribution to the likelihood (uses new @recode syntax) ll1.append logl1 = @recode(inlf=0,logp0,logp1) ' do MLE and show results smpl @all ll1.ml(showopts, m=100, c=1e-5,b) show ll1.output