

















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


















** Probit MLE Estimation */
new ;
load dat[1962,25] = mwpsid82.db ; @ Data on married women from PSID @
@ OPEN OUTPUT FILE @
output file = probit.out reset ;
nlf = dat[.,1] ; @ dummy variable for non-labor-force @ emp = dat[.,2] ; @ dummy varrable for employed workers @ wrate = dat[.,3] ; @ hourly wage rate @ lrate = dat[.,4] ; @ log of (hourly wage rate ($)+1) @ edu = dat[.,5] ; @ years of schooling @ urb = dat[.,6] ; @ dummy variable for urban resident @ minor = dat[.,7] ; @ dummy variable for minority race @ age = dat[.,8] ; @ age @ tenure = dat[.,9] ; @ # of months under current employer @ expp = dat[.,10] ; @ years of experience since age 18 @ regs = dat[.,11] ; @ dummy variable for South @ occw = dat[.,12] ; @ dummy variable for white collar @ occb = dat[.,13] ; @ dummy variable for blue collar @ indumg = dat[.,14] ; @ dummy variable for manufacturing industry @ indumn = dat[.,15] ; @ dummy variable for non-manu. industry @ unionn = dat[.,16] ; @ dummy variable for union membership @ unempr = dat[.,17] ; @ local unemployment rate @ ofinc = dat[.,18] ; @ other family income in 1980 ($) @ lofinc = dat[.,19] ; @ log of (other family income + 1) @ kids = dat[.,20] ; @ # of children of age <= 17 @
wune80 = dat[.,21] ; @ UNKNOWN @ hwork = dat[.,22] ; @ hours of house work per week @ uspell = dat[.,23] ; @ # of unemployed weeks in 1980h @ search = dat[.,24] ; @ # of weeks looking for job in 1980 @ kids5 = dat[.,25] ; @ # of children of age <= 5 @
@ DEFINE # of OBSERVATIONS @
n = rows(dat) ;
@ Dependent variable @
yy = emp ; vny = {"emp"};
@ Regressors @
xx = ones(n,1)~edu~urb~minor~age~expp~kids~kids5~lofinc ; vnx = {"cons", "edu", "urb", "minor", "age", "expp", "kids", "kids5", "lofinc" };
bb = invpd(xx'xx)*(xx'yy) ;
library optmum; #include optmum.ext; optset ;
proc f(b) ; local ltt ; ltt = yy.ln( cdfn(xxb) ) + (1-yy).ln( 1-cdfn(xxb) ) ; RETP( -sumc(ltt) ) ; ENDP ;
serob = sqrt(diag(covrob)) ; stathess = b~sehess~(b./sehess); statbhhh = b~sebhhh~(b./sebhhh); statrob = b~serob~(b./serob); yyhess = vnx~stathess; yybhhh = vnx~statbhhh; yyrob = vnx~statrob;
dependent variable: emp log likelihood: -1167. Pseudo R-square: 0. LR test, df, p-val: 377.2165 8.0000 0.
Using Hessian variable coeff. std. err. t-st cons 2.2010 0.5087 4. edu 0.0846 0.0153 5. urb 0.1553 0.0667 2. minor 0.0480 0.0671 0. age -0.0344 0.0040 -8. expp 0.0743 0.0059 12. kids 0.0593 0.0264 2. kids5 -0.5566 0.0513 -10. lofinc -0.2595 0.0556 -4.
Using BHHH variable coeff. std. err. t-st cons 2.2010 0.5226 4. edu 0.0846 0.0151 5. urb 0.1553 0.0679 2. minor 0.0480 0.0736 0. age -0.0344 0.0041 -8. expp 0.0743 0.0059 12. kids 0.0593 0.0259 2. kids5 -0.5566 0.0470 -11. lofinc -0.2595 0.0566 -4.
Using Robust variable coeff. std. err. t-st cons 2.2010 0.4975 4. edu 0.0846 0.0156 5. urb 0.1553 0.0658 2. minor 0.0480 0.0614 0. age -0.0344 0.0039 -8. expp 0.0743 0.0059 12. kids 0.0593 0.0273 2. kids5 -0.5566 0.0576 -9. lofinc -0.2595 0.0548 -4.
kids = dat[.,20] ; @ # of children of age <= 17 @ wune80 = dat[.,21] ; @ UNKNOWN @ hwork = dat[.,22] ; @ hours of house work per week @ uspell = dat[.,23] ; @ # of unemployed weeks in 1980 @ search = dat[.,24] ; @ # of weeks looking for job in 1980 @ kids5 = dat[.,25] ; @ # of children of age <= 5 @
@ DEFINE # of OBSERVATIONS @
n = rows(dat) ;
@ Dependent variable @
yy = uspell ; vny = {"uspell"};
@ Regressors @
xx = ones(n,1)~kids5~kids~edu~lofinc~age~expp~wrate~occw~occb ; vnx = {"cons", "kids5", "kids", "edu", "lofinc", "age", "expp", "wrate", "occw", "occb" };
bb = invpd(xx'xx)(xx'yy) ; ss = sqrt((yy-xxbb)'(yy-xx*bb)/n) ; bb = bb|ss ;
@ dummy variable for yy @
v = 0 ; yd = dummy(yy,v); yd = yd[.,2] ;
vnx1 = {"sigma"}; vnx = vnx|vnx1 ;
library optmum; #include optmum.ext; optset ;
proc f(b) ; local ltt, q ;
q = rows(b); ltt = yd.( -.5ln(2pi) -.5ln(b[q]^2) -(.5/b[q]^2).(yy-xxb[1:q-1])^2 )
retp( -sumc(ltt) ) ; endp ;
proc gradien(b) ; local q, i, gge, g1, g2, gap, gac, poi,e ;
q = rows(b) ; gge= zeros(q,1) ;
i = 1; do while i <= n;
gap = pdfn(xx[i,.]b[1:q-1]/b[q]) ; gac = cdfn(xx[i,.]b[1:q-1]/b[q]) ; poi = xx[i,.]b[1:q-1]/b[q] ; e = yy[i] -xx[i,.]b[1:q-1] ; g1 = yd[i]e/b[q]^2xx[i,.]'
g2 = yd[i]( -1/b[q] + 1/b[q]^3e^2 )
gge = gge + (g1|g2) ;
{b,func,grad,retcode} = optmum(&f,b0) ;
@ value of likelihood function @
logl = -func ;
@ Covariance matrix by Hessian @
covhess = invpd(hessi(b)) ;
@ Covariance matrix by BHHH @
proc ff(b) ; local ltt, q;
q = rows(b); ltt = yd.( -.5ln(2pi) -.5ln(b[q]^2) -(.5/b[q]^2).(yy-xxb[1:q-1])^2 )
retp( ltt ) ; endp ;
gtt = gradp(&ff,b); covbhhh = invpd(gtt'gtt) ;
@ Robust covariance matrix @
covrob = covhessinvpd(covbhhh)covhess ;
@ Computing Standard errors @
sehess = sqrt(diag(covhess)); sebhhh = sqrt(diag(covbhhh)); serob = sqrt(diag(covrob)) ;
stathess = b~sehess~(b./sehess); statbhhh = b~sebhhh~(b./sebhhh);
statrob = b~serob~(b./serob); yyhess = vnx~stathess; yybhhh = vnx~statbhhh; yyrob = vnx~statrob;
let mask[1,4] = 0 1 1 1; let fmt[4,3] = "-.s" 8 8 ".lf" 10 4 ".lf" 10 4 ".lf" 10 4;
format /rd 10,4 ; "" ; "Tobit Estimation Result" ; "------------------------" ; " dependent variable: " $vny ; "" ; " log likelihood: " logl ; "" ; " Using Hessian "; "" ; "variable coeff. std. err. t-st " ; yyprin = printfm(yyhess,mask,fmt); " " ; " Using BHHH "; "" ; "variable coeff. std. err. t-st " ; yyprin = printfm(yybhhh,mask,fmt); "" ; " Using Robust "; "" ; "variable coeff. std. err. t-st " ; yyprin = printfm(yyrob,mask,fmt);
output off ;
** Truncation MLE Estimation */
new ;
@ LOADING DATA @
load dat[1962,25] = mwpsid82.db ; @ Data on married women from PSID 82 @
output file = turnc.out reset ;
@ DEFINE VARIABLES @
dat = delif(dat,dat[.,2] .== 0) ; @Delete nonemployed people@ nlf = dat[.,1] ; @ dummy variable for non-labor-force @ emp = dat[.,2] ; @ dummy varrable for employed workers @ wrate = dat[.,3] ; @ hourly wage rate @ lrate = dat[.,4] ; @ log of (hourly wage rate ($)+1) @ edu = dat[.,5] ; @ years of schooling @ urb = dat[.,6] ; @ dummy variable for urban resident @ minor = dat[.,7] ; @ dummy variable for minority race @ age = dat[.,8] ; @ age @ tenure = dat[.,9] ; @ # of months under current employer @ expp = dat[.,10] ; @ years of experience since age 18 @ regs = dat[.,11] ; @ dummy variable for South @ occw = dat[.,12] ; @ dummy variable for white collar @ occb = dat[.,13] ; @ dummy variable for blue collar @ indumg = dat[.,14] ; @ dummy variable for manufac. industry @ indumn = dat[.,15] ; @ dummy variable for non-manufac. industry @ unionn = dat[.,16] ; @ dummy variable for union membership @ unempr = dat[.,17] ; @ local unemployment rate @ ofinc = dat[.,18] ; @ other family income in 1980 ($) @ lofinc = dat[.,19] ; @ log of (other family income + 1) @
bb = invpd(xx'xx)(xx'yy) ; ss = sqrt((yy-xxbb)'(yy-xx*bb)/n) ; bb = bb|ss ;
library optmum; #include optmum.ext; optset ;
proc f(b) ; local ltt, q ;
q = rows(b); ltt = (-.5ln(2pi)-.5ln(b[q]^2)-(.5/b[q]^2).(yy-xxb[1:q-1])^2 ) -ln( cdfn( xxb[1:q-1]/abs(b[q]) ) ) ;
retp( -sumc(ltt) ) ; endp ;
b0 = bb ; __title = "Tobit MLE "; _opgtol = 1e-6; _opstmth = "bfgs,half"; __output = 1 ;
{b,func,grad,retcode} = optmum(&f,b0) ;
@ value of likelihood function @
logl = -func ;
@ Covariance matrix by Hessian @
covhess = invpd(hessp(&f,b)) ;
@ Covariance matrix by BHHH @
proc ff(b) ; local ltt, q;
q = rows(b); ltt = (-.5ln(2pi)-.5ln(b[q]^2)-(.5/b[q]^2).(yy-xx*b[1:q-1])^2 )
retp( ltt ) ; endp ;
gtt = gradp(&ff,b); covbhhh = invpd(gtt'gtt) ;
@ Robust covariance matrix @
covrob = covhessinvpd(covbhhh)covhess ;
@ Computing Standard errors @
sehess = sqrt(diag(covhess)); sebhhh = sqrt(diag(covbhhh)); serob = sqrt(diag(covrob)) ;
stathess = b~sehess~(b./sehess); statbhhh = b~sebhhh~(b./sebhhh); statrob = b~serob~(b./serob); yyhess = vnx~stathess; yybhhh = vnx~statbhhh; yyrob = vnx~statrob;
** Heckman's two-step estimation */ new ;
@ LOADING DATA @ load dat[1962,25] = mwpsid82.db ; @ Data on married women from PSID 82 @
@ OPEN OUTPUT FILE @ output file = heckman1.out reset ;
@ DEFINE VARIABLES @ nlf = dat[.,1] ; @ dummy variable for non-labor-force @ emp = dat[.,2] ; @ dummy varrable for employed workers @ wrate = dat[.,3] ; @ hourly wage rate @ lrate = dat[.,4] ; @ log of (hourly wage rate ($)+1) @ edu = dat[.,5] ; @ years of schooling @ urb = dat[.,6] ; @ dummy variable for urban resident @ minor = dat[.,7] ; @ dummy variable for minority race @ age = dat[.,8] ; @ age @ tenure = dat[.,9] ; @ # of months under current employer @ expp = dat[.,10] ; @ years of experience since age 18 @ regs = dat[.,11] ; @ dummy variable for South @ occw = dat[.,12] ; @ dummy variable for white collar @ occb = dat[.,13] ; @ dummy variable for blue collar @ indumg = dat[.,14] ; @ dummy variable for manufac. industry @ indumn = dat[.,15] ; @ dummy variable for non-manufac. industry @ unionn = dat[.,16] ; @ dummy variable for union membership @ unempr = dat[.,17] ; @ local unemployment rate @ ofinc = dat[.,18] ; @ other family income in 1980 ($) @ lofinc = dat[.,19] ; @ log of (other family income + 1) @ kids = dat[.,20] ; @ # of children of age <= 17 @ wune80 = dat[.,21] ; @ UNKNOWN @ hwork = dat[.,22] ; @ hours of house work per week @ uspell = dat[.,23] ; @ # of unemployed weeks in 1980 @ search = dat[.,24] ; @ # of weeks looking for job in 1980 @ kids5 = dat[.,25] ; @ # of children of age <= 5 @
@ DEFINE # of OBSERVATIONS @ n = rows(dat) ;
@ DEFINE DEPENDENT VARIABLE AND REGRESSORS @
@ Dependent variable @ yy1 = lrate ; vny1 = {"lrate"} ;