Logo Studenta

Ay5

Esta es una vista previa del archivo. Inicie sesión para ver el archivo original

* Teoria Econometrica II, 1-2019
* Profesor: Tomas Rau
* Ayuante: Bastien Maire
* Ayudantia 5: Matching
clear
set more off
cd "/Users/bastien/Google Drive/Universidad/2019/Primer semestre/Ayudantias/Teoria_econometrica_II/Ayudantías/Ayudantía_5/Archivos"
use Ay5.dta, clear
/*Instalamos los paquetes necesarios para la estimacion
ssc install nnmatch
ssc install psmatch2
*/
* 1. Balance antes del tratamiento (tabla 3 DW2002)
tabstat age educ black hisp married nodegree re74 re75 u74 u75, by(treatment) stat(mean) nototal
* 2. Efecto tratamiento mediante OLS
reg re78 treatment age age_sq educ educ_sq married nodegree black hisp re74 re75 re74_sq re75_sq u74 u75 u74_hisp u74_black
* 3. NN matching en caracteristicas
nnmatch re78 treatment age age_sq educ educ_sq married nodegree black hisp re74 re75 re74_sq re75_sq u74 u75 u74_hisp u74_black, tc(att) m(1)
estimates store nn1
nnmatch re78 treatment age age_sq educ educ_sq married nodegree black hisp re74 re75 re74_sq re75_sq u74 u75 u74_hisp u74_black, tc(att) m(2)
estimates store nn2
esttab nn1 nn2, not nostar
* al agregar keep() replace, se crea una base de datos con informacion sobre el proceso de matching
* es importante fijar el directorio para que cree la nueva base
nnmatch re78 treatment age age_sq educ educ_sq married nodegree black hisp re74 re75 re74_sq re75_sq u74 u75 u74_hisp u74_black, tc(att) m(1) keep(clones) replace
use clones.dta 
use Ay5.dta
* 4. NN matching en propensity score
* manualmente:
probit treatment age age_sq educ educ_sq married nodegree black hisp re74 re75 re74_sq re75_sq u74 u75 u74_hisp u74_black
margins
predict ps
nnmatch re78 treatment ps, tc(att) m(1)
* Usando psmatch2
psmatch2 treatment age age_sq educ educ_sq married nodegree black hisp re74 re75 re74_sq re75_sq u74 u75 u74_hisp u74_black, outcome(re78) 
* note que este comando automaticamente genera variables con informacion del proceso de matching
* 5. Post-matching Balance
pstest age educ married nodegree black hisp re74 re75 u74 u75, both graph // solo funciona luego de psmatch2
* 6. Soporte comun
hist _pscore if treatment==1
hist _pscore if treatment==0 /* mucha concentracion en cero */
hist _pscore if treatment==0 & _pscore>0.1
* 7. Estimacion doblemente robusta
gen ipw=1
sum ps
replace ipw=(_pscore/(1-_pscore))/(r(mean)/(1-r(mean))) if treatment==0 
reg re78 treatment age age_sq educ educ_sq married nodegree black hisp re74 re75 re74_sq re75_sq u74 u75 u74_hisp u74_black [pw=ipw]

Continuar navegando