* PROPENSITY SCORE MATCHING * ESEMPIO 1 use easySHARE_rel8-0-0.dta, clear *Scopo: studiare l’effetto di rimanere senza figli sulla salute *psicologica (Eurod = sintomi di depressione) nell'ultima wave * di SHARE. * GESTIONE DEI DATI tab1 ch001 eurod age isced1997_r female country *seleziono solo wave 8 senza missing drop if wave!=8 | ch001<0 | eurod<0 | isced1997_r<0 recode ch001 (0=1)(1/19=0),gen(childless) recode isced1997_r (0/2=1 "low") (3 4=2 "med") (5 6=3 "high"),gen(educ) recode educ(95 97=.) ****************************************************************** * MODELLI DI SELEZIONE PER DEFINIRE LA PROPENSIONE AL TRATTAMENTO ****************************************************************** logit childless c.age##c.age i.country i.educ if female==1 & age>49 *PREDIZIONI= prob. predette di rimanere senza figli predict pr1_logit if e(sample) *PROBIT probit childless c.age##c.age i.country i.educ if female==1 & age>49 predict pr1_prob if e(sample) *distribuzione della propensione o propensity score hist pr1_logit,by(childless) hist pr1_prob, by(childless) two(hist pr1_prob if childless==0,bc(gs10)) (hist pr1_prob if childless==1), legend(order(1 "control" 2 "treated")) tabstat pr1_prob, by(childless) st(min max n mean) *matrice dati sort pr1_prob br mergeid pr1_prob pr1_log childless age country educ ******************************************* * eliminiamo gli uomini e quelli meno di 50 * così non dobbiamo sepre ripetere la condizione if... drop if age<50 | female==0 | eurod<0 ****************************************** ***************************************** *Nearest Neighbor matching ***************************************** psmatch2 childless c.age##c.age i.country i.educ if female==1 & age>49 , /// out(eurod) n(1) common caliper(.002) /* sort _pscore *per i trattati gen sample=1 if _n1!=. & _support==1 * per i controlli dobbiamo trovare le unità abbinate forvalues x=1/20 { replace sample=1 if sample==. & (_id==_n1[_n-`x'] | _id==_n1[_n+`x']) } */ tab _treat if _weight!=. ************************************************* *diagnostica: i gruppi hanno una simile distribuzione *del pscore? hist _pscore if sample==1 ,by(_treat) pstest c.age##c.age i.country i.educ, both pstest c.age##c.age i.educ, both graph label notable psgraph *stima della relazione tra età e depressione *prima del match two (scatter eurod age if childless==0, symbol(Oh) mc(gs13) jitter(5)) //// (scatter eurod age if childless==1, symbol(Th) mc(gs10) jitter(5)) /// (lfit eurod age if childless==0) (lfit eurod age if childless==1), /// legend(order(1 "control" 2 "treated")) ytitle(depression) *dopo match two (scatter eurod age if childless==0 [aw=_weight], symbol(Oh) mc(gs13) jitter(5)) /// (scatter eurod age if childless==1 [aw=_weight], symbol(Th) mc(gs10) jitter(5)) /// (lfit eurod age if childless==0 [aw=_weight]) (lfit eurod age if childless==1 [aw=_weight]) /// , legend(order(1 "control" 2 "treated")) ytitle(depression) ****************************************************** ** Nearest Neighbor matching senza replacement psmatch2 childless c.age##c.age i.country i.educ if female==1 & age>49, noreplacement /// out(eurod) n(1) common caliper(.002) tab _weight _treat ****************************************************** ** Nearest Neighbor matching : 5 unità più vicine psmatch2 childless c.age##c.age i.country i.educ if female==1 & age>49, /// out(eurod) n(5) common caliper(.002) tab _weight _treat tab educ _treat [aw=_weight],col tab educ _treat ,col pstest i.educ, both ****************************************************** *** caliper / radius matching psmatch2 childless c.age##c.age i.country i.educ if female==1 & age>49, /// out(eurod) radius common caliper(.002) pstest i.educ, both pstest age, both density pstest age, both box pstest c.age##c.age i.country i.educ, both hist hist _weight hist _weight if _treat==0 & _weight<.4 ****************************************************** *** kernel psmatch2 childless c.age##c.age i.country i.educ if female==1 & age>49, /// out(eurod) common kernel k(normal) bw(0.05) pstest age, both density