You are on page 1of 9

*********************CLASE 39*************************

***KERNEL***
* COMANDO DE INSTALACION MODULO "psmatch2"
ssc install psmatch2, replace

* OTRA FORMA DE INSTALAR EL MODULO "psmatch2"

net from http://www.stata-journal.com/software/sj5-3


net install st0026_2
cd "D:\UIGV\UIGV VIII\A_impacto\udemy\Clase 39"
use "infant birthweight.dta", clear
des

storage display value


variable name type format label variable label

bweight int %9.0g infant birthweight (grams)


mmarried byte %10.0g mmarried 1 if mother married
mhisp byte %9.0g 1 if mother hispanic
fhisp byte %9.0g 1 if father hispanic
foreign byte %9.0g 1 if mother born abroad
alcohol byte %9.0g 1 if alcohol consumed during pregnancy
deadkids byte %9.0g previous births where newborn died
mage byte %9.0g mother's age
medu byte %9.0g mother's education attainment
fage byte %9.0g father's age
fedu byte %9.0g father's education attainment
nprenatal byte %9.0g number of prenatal care visits
monthslb int %9.0g months since last birth
order byte %9.0g order of birth of the infant
msmoke byte %27.0g smoke2 cigarettes smoked during pregnancy
mbsmoke byte %9.0g mbsmoke 1 if mother smoked
mrace byte %9.0g 1 if mother is white
frace byte %9.0g 1 if father is white
prenatal byte %9.0g trimester of first prenatal care visit
birthmonth byte %9.0g month of birth
lbweight byte %9.0g 1 if low birthweight baby
fbaby byte %9.0g YesNo 1 if first baby
prenatal1 byte %9.0g YesNo 1 if first prenatal visit in 1 trimester

Sorted by:
* Objetivo: medir el impacto de que una madre fume sobre el peso de hijo
*-------------------------------------------------------------------------------
* Estimamos la Probabilidad de participación
*-------------------------------------------------------------------------------
tab msmoke
codebook mbsmoke
tab mbsmoke
cigarettes
smoked
during
pregnancy Freq. Percent Cum.

0 daily 3,778 81.39 81.39


1-5 daily 200 4.31 85.70
6-10 daily 337 7.26 92.96
11+ daily 327 7.04 100.00

Total 4,642 100.00

mbsmoke 1 if mother smoked

type: numeric (byte)


label: mbsmoke

range: [0,1] units: 1


unique values: 2 missing .: 0/4,642

tabulation: Freq. Numeric Label


3,778 0 nonsmoker
864 1 smoker

1 if mother
smoked Freq. Percent Cum.

nonsmoker 3,778 81.39 81.39


smoker 864 18.61 100.00

Total 4,642 100.00


*Debemos determinar qué variables incluir en el modelo.
1. Creamos la variable mage2
gen mage2 = mage*mage

dprobit mbsmoke mmarried mage mage2 fbaby medu

1 if mother
smoked Freq. Percent Cum.

nonsmoker 3,778 81.39 81.39


smoker 864 18.61 100.00

Total 4,642 100.00

Iteration 0: log likelihood = -2230.7484


Iteration 1: log likelihood = -2042.6734
Iteration 2: log likelihood = -2040.5088
Iteration 3: log likelihood = -2040.5061

Probit regression, reporting marginal effects Number of obs = 4642


LR chi2(5) = 380.48
Prob > chi2 = 0.0000
Log likelihood = -2040.5061 Pseudo R2 = 0.0853

mbsmoke dF/dx Std. Err. z P>|z| x-bar [ 95% C.I. ]

mmarried* -.1807788 .015976 -12.31 0.000 .699698 -.212091 -.149466


mage .0434746 .0087639 4.95 0.000 26.5045 .026298 .060651
mage2 -.0008115 .0001606 -5.04 0.000 734.056 -.001126 -.000497
fbaby* -.0535184 .0118924 -4.43 0.000 .437958 -.076827 -.03021
medu -.0215246 .0024397 -8.75 0.000 12.6896 -.026306 -.016743

obs. P .1861267
pred. P .1660298 (at x-bar)

(*) dF/dx is for discrete change of dummy variable from 0 to 1


z and P>|z| correspond to the test of the underlying coefficient being 0

probit mbsmoke mmarried mage mage2 fbaby medu


mfx
. probit mbsmoke mmarried mage mage2 fbaby medu

Iteration 0: log likelihood = -2230.7484


Iteration 1: log likelihood = -2042.6734
Iteration 2: log likelihood = -2040.5088
Iteration 3: log likelihood = -2040.5061
Iteration 4: log likelihood = -2040.5061

Probit regression Number of obs = 4,642


LR chi2(5) = 380.48
Prob > chi2 = 0.0000
Log likelihood = -2040.5061 Pseudo R2 = 0.0853

mbsmoke Coef. Std. Err. z P>|z| [95% Conf. Interval]

mmarried -.6484821 .0526991 -12.31 0.000 -.7517705 -.5451938


mage .1744327 .0352437 4.95 0.000 .1053562 .2435092
mage2 -.0032559 .0006462 -5.04 0.000 -.0045224 -.0019894
fbaby -.2175962 .0491066 -4.43 0.000 -.3138433 -.121349
medu -.0863631 .0098692 -8.75 0.000 -.1057064 -.0670198
_cons -1.558255 .4511589 -3.45 0.001 -2.44251 -.674

. mfx

Marginal effects after probit


y = Pr(mbsmoke) (predict)
= .16602975

variable dy/dx Std. Err. z P>|z| [ 95% C.I. ] X

mmarried* -.1807788 .01598 -11.32 0.000 -.212091 -.149466 .699698


mage .0434746 .00876 4.96 0.000 .026298 .060651 26.5045
mage2 -.0008115 .00016 -5.05 0.000 -.001126 -.000497 734.056
fbaby* -.0535184 .01189 -4.50 0.000 -.076827 -.03021 .437958
medu -.0215246 .00244 -8.82 0.000 -.026306 -.016743 12.6896

(*) dy/dx is for discrete change of dummy variable from 0 to 1

.
end of do-file

global X mmarried mage mage2 fbaby medu


**generarmos nuestro propensity score
predict pscore, pr

Veamos un histograma de las probabilidades predichas:

Density
6

0
histogram pscore, by(mbsmoke)

nonsmoker smoker

0 .2 .4 .6 .8 0 .2 .4 .6 .8
Pr(mbsmoke)
Graphs by 1 if mother smoked

kdensity pscore if mbsmoke==1, epanechnikov generate(x1 y1)


Density
4

0
Kernel density estimate

0 .2 .4 .6 .8
Pr(mbsmoke)
Density

kernel = epanechnikov, bandwidth = 0.0297


6

kdensity pscore if mbsmoke==0, epanechnikov generate(x0 y0)

Kernel density estimate

0 .2 .4 .6 .8
Pr(mbsmoke)
kernel = epanechnikov, bandwidth = 0.0162
twoway (line y1 x1) (line y0 x0, lpattern(dash)), ///

Densidad
ytitle(Densidad) xtitle(Probabilidad de ser tratado) title(Propensity Score ) ///
6

0
legend(order(1 "Participante=1" 2 "No participante=0"))

Propensity Score

0 .2 .4 .6 .8
Probabilidad de ser tratado

Participante=1 No participante=0
*********************CLASE 40*************************
***ESTIMANDO EL SOPORTE COMUN***
**** Encontramos la máxima probabilidad predicha para el grupo de control y tratameinto:
sum pscore if mbsmoke ==0

Variable Obs Mean Std. Dev. Min Max

pscore 3,778 .1698913 .1059434 .0074551 .7816764

scalar max_control = r(max)

sum pscore if mbsmoke ==1

Variable Obs Mean Std. Dev. Min Max

pscore 864 .2543736 .1276102 .0334317 .7803053

scalar min_D = r(min)

**** eliminamos los extremos


gen pscore_sc = pscore

replace pscore_sc=. if mbsmoke==1 & pscore > max_control


replace pscore_sc=. if mbsmoke==0 & pscore < min_D

**** Vemos cuantas observaciones perdemos al imponer esta restricción:


count if pscore_sc==.

. count if pscore_sc==.
31
**** Calidad de emparejamiento
*ningun coeficiente deb ser significativo
probit mbsmoke pscore $X

Iteration 0: log likelihood = -2230.7484


Iteration 1: log likelihood = -2040.7893
Iteration 2: log likelihood = -2035.0394
Iteration 3: log likelihood = -2035.031
Iteration 4: log likelihood = -2035.031

Probit regression Number of obs = 4,642


LR chi2(6) = 391.43
Prob > chi2 = 0.0000
Log likelihood = -2035.031 Pseudo R2 = 0.0877

mbsmoke Coef. Std. Err. z P>|z| [95% Conf. Interval]

pscore -3.790169 1.161998 -3.26 0.001 -6.067644 -1.512694


mmarried -1.373694 .2288983 -6.00 0.000 -1.822327 -.925062
mage .3634699 .0689102 5.27 0.000 .2284085 .4985314
mage2 -.0066828 .0012559 -5.32 0.000 -.0091443 -.0042212
fbaby -.4366953 .0837739 -5.21 0.000 -.6008892 -.2725015
medu -.1819435 .0311386 -5.84 0.000 -.2429741 -.1209129
_cons -1.546977 .4575473 -3.38 0.001 -2.443753 -.6502006

You might also like