clear all cap log close set more 1 set dp comma *cd "H:\mestrado\avaliação\dif-dif" cd "C:\Elaine\app_pos\2017\aula pratica difdif" ************************************************************ *************PROFICIENCIA EM MATEMÁTICA********************** ************************************************************ *ssc install psmatch2 *PROBIT use "completo_2009_2011_limpo.dta", clear keep if ano==2009|ano==2011 qui dprobit escola_estadual NUM_FUNCIONARIOS esc_mae_ef /// esc_mae_em esc_mae_sup esc_mae_n_sabe prof_sem_superior /// prof_superior_completo prop_recebe_bolsa_fam prop_tem_computador_casa /// dreg1-dreg10 urbana prof_mt if ano==2009 estimates store probit1 *ssc install estout estout probit1, cells(b(star fmt(%9.3f)) se(par)) /// stats(N, fmt(%9.3f %9.0g) ) legend label collabels(, none) /// varlabels(_cons Constante) posthead("") prefoot("") /// postfoot("") varwidth(30) modelwidth(12) delimiter("") starlevels (* 0.10 ** 0.05 *** 0.01) margin predict pscore_mt4 if ano==2009, pr histogram pscore_mt4 if ano==2009, by(escola_estadual) **PSMATCH2 set seed 1000 gen x=uniform() so x *ssc install psmatch2 psmatch2 escola_estadual if ano==2009, pscore(pscore_mt4) out (prof_mt) neighbor(1) cal (0.01) com norepl *psmatch2 escola_estadual if ano==2009, pscore(pscore_mt4) out (prof_mt) neighbor(2) cal (0.01) com *psmatch2 escola_estadual if ano==2009, pscore(pscore_mt4) out (prof_mt) kernel com psgraph pstest NUM_SALAS_EXISTENTES NUM_FUNCIONARIOS esc_mae_ef esc_mae_em esc_mae_sup esc_mae_n_sabe prof_sem_superior prof_superior_completo prop_recebe_bolsa_fam prop_tem_computador_casa dreg1- dreg10 urbana prof_mt, both so cod_escola ano replace _weight=2 if _weight[_n-1]==1 & ano==2011 & /// cod_escola[_n-1]==cod_escola tab _weight escola_estadual, mi tab _weight ano, mi **** diferenças em diferenças na amostra pareada - normal gen tempo=0 replace tempo=1 if ano==2011 gen interacao=tempo*escola_estadual tab escola_estadual tempo if _weight~=., sum(prof_mt) * a titulo de comparação, como foi a evolução dos indicadores na amostra toda, pré-matching tab escola_estadual tempo, sum(prof_mt) ** cross-section com todas as escolas reg prof_mt escola_estadual if ano==2011 estimates store dd1 reg prof_mt escola_estadual NUM_SALAS_EXISTENTES NUM_FUNCIONARIOS esc_mae_ef esc_mae_em esc_mae_sup esc_mae_n_sabe prof_sem_superior prof_superior_completo prop_recebe_bolsa_fam prop_tem_computador_casa dreg1- dreg10 urbana if ano==2011 estimates store dd2 *** dif em dif simples reg prof_mt interacao tempo escola_estadual estimates store dd3 reg prof_mt interacao tempo escola_estadual NUM_SALAS_EXISTENTES NUM_FUNCIONARIOS esc_mae_ef esc_mae_em esc_mae_sup esc_mae_n_sabe prof_sem_superior prof_superior_completo prop_recebe_bolsa_fam prop_tem_computador_casa dreg1- dreg10 urbana estimates store dd4 ** dif em dif com pareamento reg prof_mt interacao tempo escola_estadual if _weight~=. estimates store dd5 reg prof_mt interacao tempo escola_estadual NUM_SALAS_EXISTENTES /// NUM_FUNCIONARIOS esc_mae_ef esc_mae_em esc_mae_sup /// esc_mae_n_sabe prof_sem_superior prof_superior_completo /// prop_recebe_bolsa_fam prop_tem_computador_casa /// dreg1- dreg10 urbana if _weight~=. estimates store dd6 estout dd1 dd2, cells(b(star fmt(%9.3f)) se(par)) stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) legend label collabels(, none) varlabels(_cons Constante) posthead("") prefoot("") postfoot("") varwidth(30) modelwidth(12) delimiter("") starlevels (* 0.10 ** 0.05 *** 0.01) estout dd3 dd4 dd5 dd6, cells(b(star fmt(%9.3f)) se(par)) stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) legend label collabels(, none) varlabels(_cons Constante) posthead("") prefoot("") postfoot("") varwidth(30) modelwidth(12) delimiter("") starlevels (* 0.10 ** 0.05 *** 0.01) histogram pscore_mt4 if ano==2009 & _weight~=., by(escola_estadual) ** estimando com dif em dif normal reg prof_mt interacao tempo escola_estadual estimates store simples ** estimando com efeitos fixos gen escola_estadual_alt = 0 if ano==2009 replace escola_estadual_alt = escola_estadual if ano==2011 so cod_escola ano iis cod_escola tis ano xtreg prof_mt escola_estadual_alt tempo, fe estimates store ef *** estimando com 1as diferenças so cod_escola ano by cod_escola: gen dif_prof = prof_mt - prof_mt[_n-1] reg dif_prof escola_estadual_alt estimates store primeira_dif estout simples ef primeira_dif, cells(b(star fmt(%9.3f)) se(par)) stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) legend label collabels(, none) varlabels(_cons Constante) posthead("") prefoot("") postfoot("") varwidth(30) modelwidth(12) delimiter("") starlevels (* 0.10 ** 0.05 *** 0.01)