|
|
| local reps= 1000 |
|
|
| keep if dropme==0 |
|
|
| |
| _pctile pred_mal_pos, p(2.5 97.5) |
| local bottom=r(r1) |
| local top=r(r2) |
| _pctile pred_mal_pos, p(25 50 75) |
| local p25= r(r1) |
| local p50= r(r2) |
| local p75= r(r3) |
| |
| la var used_vouchers_admin "A. Used Voucher" |
| la var treat_sev_simple_mal "B. Purchase Any Malaria Treatment" |
| la var treat_severe_mal "C. Purchase Severe Malaria Treatment" |
|
|
| mat xgrid= J(50,1,.) |
|
|
| local interval= (`top' - `bottom')/50 |
| local qq=1 |
| forval i=`bottom'(`interval')`top' { |
| mat xgrid[`qq',1]= `i' |
| local ++qq |
| } |
| |
| svmat xgrid |
|
|
| |
| local varlist "used_vouchers_admin treat_sev_simple_mal treat_severe_mal" |
| foreach out of local varlist { |
|
|
| lpoly `out' pred_mal_pos if patient_voucher==1, deg(1) gen(Py_`out') at(xgrid) nodraw |
| mkmat Py_`out' if xgrid!=., mat(q) |
| mat RP`out'= q |
|
|
| lpoly `out' pred_mal_pos if doctor_voucher==1, deg(1) gen(Dy_`out') at(xgrid) nodraw |
| mkmat Dy_`out' if xgrid!=., mat(q) |
| mat RD`out'= q |
| } |
| |
| |
| local k=1 |
| while `k'<=`reps' { |
| |
| drop _all |
| use "$data_final/_bootstrap/bs_cluCSCOM_`k'" |
|
|
| keep if dropme==0 |
| |
| svmat xgrid |
|
|
| |
| local varlist "used_vouchers_admin treat_sev_simple_mal treat_severe_mal" |
| foreach out of local varlist { |
| lpoly `out' pred_mal_pos if patient_voucher==1, deg(1) gen(Py_`out') at(xgrid) nodraw |
| mkmat Py_`out' if xgrid!=., mat(q) |
| mat RP`out'= RP`out',q |
| lpoly `out' pred_mal_pos if doctor_voucher==1, deg(1) gen(Dy_`out') at(xgrid) nodraw |
| mkmat Dy_`out' if xgrid!=., mat(q) |
| mat RD`out'= RD`out',q |
| } |
| di `k' |
| local ++k |
| } |
|
|
| |
| local varlist "used_vouchers_admin treat_sev_simple_mal treat_severe_mal" |
| foreach out of local varlist { |
| foreach let in P D { |
| mat ul= R`let'`out'[.,2...]' |
| mat ll= ul |
| mat pe= ul |
| drop _all |
| svmat ul |
| svmat ll |
| svmat pe |
| collapse (p5) ll* (p95) ul* (sd) pe* |
| mkmat ll1-ll50, mat(ll2) |
| mkmat ul1-ul50, mat(ul2) |
| mkmat pe1-pe50, mat(pe) |
| mat ul2= ul2' |
| mat ll2= ll2' |
| mat pe= pe' |
| mat useme= R`let'`out'[1..50,1] |
| mat F`let'`out'= xgrid,useme,ul2,ll2,pe |
| } |
| |
| |
| drop _all |
| if "`out'"=="used_vouchers_admin" local tit_`out' "Used Voucher" |
| if "`out'"=="treat_sev_simple_mal" local tit_`out' "Purchased Any Malaria Treatment" |
| if "`out'"=="treat_severe_mal" local tit_`out' "Purchased Severe Malaria Treatment" |
| foreach let in D P { |
| svmat F`let'`out' |
| g ul`let'= F`let'`out'2 + 1.645*F`let'`out'5 |
| g ll`let'= F`let'`out'2 - 1.645*F`let'`out'5 |
| } |
|
|
| |
| twoway line ulD llD FD`out'2 ulP llP FP`out'2 FD`out'1, lcol(black black black gs12 gs12 gs12) lpat(dot dot solid dot dot solid) |
| graphregion(color(white)) legend(order(3 6) label(3 "Doctor Voucher") label(6 "Patient Voucher") size(medium) row(1)) |
| ytit("Share Patients", size(medlarge)) ylab(0(.2).9) xtit("Predicted Malaria Risk", size(medlarge)) |
| tit("`tit_`out''", size(large)) name(`out', replace) |
| xline(`p25', lcol(gs12) lpat(dash)) xline(`p50', lcol(gs12) lpat(dash)) xline(`p75', lcol(gs12) lpat(dash)) |
| |
| } |
| |
|
|
| |
| grc1leg used_vouchers_admin treat_sev_simple_mal treat_severe_mal, row(1) graphregion(color(white)) name(final, replace) |
| gr dis final, xsize(10) ysize(4) |
|
|
| graph export "$graphs/4_tmtXpredpos.pdf", replace |
|
|
|
|
| |
|
|