/******************* session 6: Matching G8alt students to their G8new counterparts Johanna Sophie Quis Bamberg Graduate School of Social Sciences (BAGSS) University of Bamberg Data: National Educational Panel Study (NEPS) - Additional Study Baden-Wurttemberg(BW A72 & A73, Version D_2-0-0) Procedure 1. logit 2. compute propensity scores 3. Satisfaction 4. Histograms 5. t-Tests 6. Summary Stats for all interesting variables 7. first regressions ********************/ // initialize working environment *run "init.do" local sessionnum 2a // open log file *capture log close smcl *log using "${logDir}/session`sessionnum'.smcl", smcl replace name(smcl) set more off use "${dataDir}mentalhealthnostd", clear capture drop g8alt capture drop matchedto1 capture drop matchedto2 capture drop matchedto3 capture drop matchedto4 capture drop matchedto5 cap drop dropg8alt gen g8alt= (txg8==1 & wave==1) replace g8alt = . if txg8==0 fre g8alt global treatment g8alt global ylist GSEscore // stressscore healthscore t1a t1f global xlist migration agem female sports repeated books mas2_sc1 *nnmatch $ylist $treatment $xlist , keep(matches) replace gsort -g8alt teffects nnmatch ($xlist ) ($treatment ), generate(matchedto) ematch(female) // the matchedto variables contain the observation numbers of the nearest neighbors // there may be more than one matchedto observation in case there are ties replace matchedto1= 0 if g8alt== 0 replace matchedto2= 0 if g8alt== 0 replace matchedto3= 0 if g8alt== 0 // this is to ensure that in the following code only students of the second wave are used for matching gen dropg8alt =0 forvalues i = 1/50{ //because there are 50 g8alt students replace dropg8alt= 1 if ([_n] == matchedto1[`i']) *replace dropg8alt= 1 if ([_n] == matchedto2[`i']) *replace dropg8alt= 1 if ([_n] == matchedto3[`i']) } replace dropg8alt= 2 if g8alt==1 fre dropg8alt *br g8alt matchedto1 dropg8alt if g8alt!=. *describe $treatment $ylist $xlist *sum $treatment $ylist $xlist *bysort $treatment: summarize $ylist $xlist *reg $ylist $treatment *reg $ylist $treatment $xlist *pscore $treatment $xlist, pscore(myscore) blockid(myblock) comsup *fre myscore *fre myblock *attnd $ylist $treatment $xlist, pscore(myscore) comsup boot reps($breps) dots *drop myscore myblock save "${dataDir}mentalhealthadjusted", replace // close log files *log close smcl