clear all use "C:\NCME 2016\RMPW\Riverside.dta" log using "C:\NCME 2016\RMPW\Riverside_log.log", replace ********** Include the step that identifies the common support ********* ***** Run binary logit *** quietly logit emp emp_prior pqtrunc50 pqtrunc51 pqtrunc52 pqtrunc53 pqtrunc30 hispanic pqtrunc49 nevmar if treat==0 predict p0, pr predict xb0, xb quietly logit emp emp_prior pqtrunc50 pqtrunc51 pqtrunc52 pqtrunc53 pqtrunc30 hispanic pqtrunc49 nevmar if treat==1 predict p1, pr predict xb1, xb **** Run ordered logit *** quietly ologit empcat emp_prior pqtrunc50 pqtrunc51 pqtrunc52 pqtrunc53 pqtrunc30 hispanic pqtrunc49 nevmar if treat==0 predict p00 p01 p02, pr predict xbo0, xb quietly ologit empcat emp_prior pqtrunc50 pqtrunc51 pqtrunc52 pqtrunc53 pqtrunc30 hispanic pqtrunc49 nevmar if treat==1 predict p10 p11 p12, pr predict xbo1, xb **** Run binary logit for teen-parents as moderator forvalues j=0(1)1 { forvalues k=0(1)1 { quietly logit emp emp_prior pqtrunc50 pqtrunc51 pqtrunc52 pqtrunc53 pqtrunc30 hispanic pqtrunc49 nevmar if treat==`j' & teen_parent==`k' predict pt`j'`k', pr predict xbt`j'`k', xb } } ******************************************** ******* Exclusion for binary case ******* forvalues a=0(1)1 { qui sum xb`a' sca sd`a'=r(sd) forvalues i=0(1)1 { forvalues j=0(1)2 { qui sum xb`a' if treat==`i' & emp==`j' sca max`a'`i'`j'=r(max) + .2*sd`a' sca min`a'`i'`j'=r(min) - .2*sd`a' } } } gen exclude=0 forvalues a=0(1)1 { replace exclude=1 if xb`a'min(max`a'00, max`a'01, max`a'10, max`a'11) } *********************************************** ******* Exclusion for 3-category case ******* forvalues a=0(1)1 { qui sum xbo`a' sca sdo`a'=r(sd) forvalues i=0(1)1 { forvalues j=0(1)2 { qui sum xbo`a' if treat==`i' & empcat==`j' sca max`a'`i'`j'=r(max) + .2*sdo`a' sca min`a'`i'`j'=r(min) - .2*sdo`a' } } } gen exclude3=0 forvalues a=0(1)1 { replace exclude3=1 if xbo`a'>min(max`a'00, max`a'01, max`a'02, max`a'10, max`a'11, max`a'12) replace exclude3=1 if xbo`a'min(xbt`a'00`c'max,xbt`a'01`c'max,xbt`a'10`c'max,xbt`a'11`c'max)) } } ******************************************************* tab exclude treat tab exclude3 treat tab excludet treat ******* Generate weights ******** ****** Binary ******* gen rmpw=1 replace rmpw=p0/p1 if treat==1 & emp==1 replace rmpw=(1-p0)/(1-p1) if treat==1 & emp==0 ********** Binary non-parametric 3x3 ********** centile xb1, centile(33 67) gen h1=3 replace h1=1 if xb1<=r(c_1) replace h1=2 if xb1>r(c_1) & xb1<=r(c_2) forvalues j=1(1)3 { centile xb0 if h1==`j', centile(33 67) gen h0`j'=3 replace h0`j'=1 if xb0<=r(c_1) replace h0`j'=2 if xb0>r(c_1) & xb0<=r(c_2) } gen strata=. replace strata=0 if h1==1 & h01==1 replace strata=1 if h1==1 & h01==2 replace strata=2 if h1==1 & h01==3 replace strata=3 if h1==2 & h02==1 replace strata=4 if h1==2 & h02==2 replace strata=5 if h1==2 & h02==3 replace strata=6 if h1==3 & h03==1 replace strata=7 if h1==3 & h03==2 replace strata=8 if h1==3 & h03==3 forvalues i=0(1)1 { forvalues j=0(1)8 { qui sum emp if treat==`i' & strata==`j' & exclude==0 sca pr`i'`j'=r(mean) } } gen nrmpw33=1 forvalues j=0(1)8 { replace nrmpw33= (1-pr0`j')/(1-pr1`j') if treat==1 & strata==`j' & emp==0 replace nrmpw33= pr0`j'/pr1`j' if treat==1 & strata==`j' & emp==1 } ********** Binary non-parametric 4x4 ********** centile xb1, centile(25 50 75) gen g1=4 replace g1=1 if xb1<=r(c_1) replace g1=2 if xb1>r(c_1) & xb1<=r(c_2) replace g1=3 if xb1>r(c_2) & xb1<=r(c_3) forvalues j=1(1)4 { centile xb0 if g1==`j', centile(25 50 75) gen g0`j'=4 replace g0`j'=1 if xb0<=r(c_1) replace g0`j'=2 if xb0>r(c_1) & xb0<=r(c_2) replace g0`j'=3 if xb0>r(c_2) & xb0<=r(c_3) } gen strata44=. replace strata44=0 if g1==1 & g01==1 replace strata44=1 if g1==1 & g01==2 replace strata44=2 if g1==1 & g01==3 replace strata44=3 if g1==1 & g01==4 replace strata44=4 if g1==2 & g02==1 replace strata44=5 if g1==2 & g02==2 replace strata44=6 if g1==2 & g02==3 replace strata44=7 if g1==2 & g02==4 replace strata44=8 if g1==3 & g03==1 replace strata44=9 if g1==3 & g03==2 replace strata44=10 if g1==3 & g03==3 replace strata44=11 if g1==3 & g03==4 replace strata44=12 if g1==4 & g04==1 replace strata44=13 if g1==4 & g04==2 replace strata44=14 if g1==4 & g04==3 replace strata44=15 if g1==4 & g04==4 forvalues i=0(1)1 { forvalues j=0(1)15 { qui sum emp if treat==`i' & strata==`j' sca pn`i'`j'=r(mean) } } gen nrmpw44=1 forvalues j=0(1)15 { replace nrmpw44= (1-pn0`j')/(1-pn1`j') if treat==1 & strata==`j' & emp==0 replace nrmpw44= pn0`j'/pn1`j' if treat==1 & strata==`j' & emp==1 } ***** 3-category ****** gen rmpw3=1 forvalues i=0(1)2 { replace rmpw3=p0`i'/p1`i' if treat==1 & empcat`i'==1 } ****** Binary with teen-parent moderator ******** gen rmpwt=1 forvalues k=0(1)1 { replace rmpwt=pt0`k'/pt1`k' if treat==1 & emp==1 & teen_parent==`k' replace rmpwt=(1-pt0`k')/(1-pt1`k') if treat==1 & emp==0 & teen_parent==`k' } drop if trunc_dep12sm2==. | treat==. | rmpw==. **** This serves to generate a unique identifier, called "obs", for each observation. Such that duplicates will have the same identifier gen obs=_n ******** Generate duplicate observations, where D is indicator for duplicate ******* expand 2 if treat==1, gen(D) ******* Make sure duplicates get a weight=1 ********* replace rmpw=1 if D==1 replace nrmpw33=1 if D==1 replace nrmpw44=1 if D==1 replace rmpw3=1 if D==1 replace rmpwt=1 if D==1 *** Generate interactions ******* gen treatD=treat*D gen teen_treatD=teen_treat*D gen not_teen= (-1*teen_parent) + 1 gen not_teen_treat=not_teen*treat gen not_teen_treatD=not_teen_treat*D ******* Outcome models ********* *Binary RMPW reg trunc_dep12sm2 treat treatD pqtrunc50 pqtrunc51 pqtrunc52 pqtrunc53 pqtrunc30 hispanic pqtrunc49 nevmar if exclude==0 [pweight=rmpw], vce(cluster obs) *Binary Non-parametric RMPW (NRMPW) reg trunc_dep12sm2 treat treatD pqtrunc50 pqtrunc51 pqtrunc52 pqtrunc53 pqtrunc30 hispanic pqtrunc49 nevmar if exclude==0 [pweight=nrmpw33], vce(cluster obs) reg trunc_dep12sm2 treat treatD pqtrunc50 pqtrunc51 pqtrunc52 pqtrunc53 pqtrunc30 hispanic pqtrunc49 nevmar if exclude==0 [pweight=nrmpw44], vce(cluster obs) * 3-category employment reg trunc_dep12sm2 treat treatD pqtrunc50 pqtrunc51 pqtrunc52 pqtrunc53 pqtrunc30 hispanic pqtrunc49 nevmar if exclude3==0 [pweight=rmpw3], vce(cluster obs) * Binary RMPW with teen-parent as moderator reg trunc_dep12sm2 treat treatD teen_parent teen_treat teen_treatD pqtrunc50 pqtrunc51 pqtrunc52 pqtrunc53 teen_pqtrunc50 teen_pqtrunc51 teen_pqtrunc52 teen_pqtrunc53 pqtrunc30 hispanic pqtrunc49 nevmar if excludet==0 [pweight=rmpwt], vce(cluster obs) reg trunc_dep12sm2 treat treatD not_teen not_teen_treat not_teen_treatD pqtrunc50 pqtrunc51 pqtrunc52 pqtrunc53 teen_pqtrunc50 teen_pqtrunc51 teen_pqtrunc52 teen_pqtrunc53 pqtrunc30 hispanic pqtrunc49 nevmar if excludet==0 [pweight=rmpwt], vce(cluster obs) *Binary RMPW and NRMPW with a binary depresssion measure as the outcome reg depsmrk2 treat treatD pqtrunc50 pqtrunc51 pqtrunc52 pqtrunc53 pqtrunc30 hispanic pqtrunc49 nevmar if exclude==0 [pweight=rmpw], vce(cluster obs) reg depsmrk2 treat treatD pqtrunc50 pqtrunc51 pqtrunc52 pqtrunc53 pqtrunc30 hispanic pqtrunc49 nevmar if exclude==0 [pweight=nrmpw44], vce(cluster obs) * SEM/Path Analysis approach reg emp treat if D==0 sca mediator=_b[treat] sca mediator_se=_se[treat] reg trunc_dep12sm2 treat emp if D==0 sca direct=_b[treat] sca direct_se=_se[treat] sca indirect=_b[emp]*mediator sca indirect_se=sqrt((mediator^2)*(_se[emp]^2) + (mediator_se^2)*(_b[emp]^2)) sca list direct sca list direct_se sca list indirect sca list indirect_se log close