|
|
|
|
|
|
| preserve
|
|
|
| local namestr `" "\it{A. Whole Sample}" "'
|
| di `"`namestr'"'
|
|
|
| global varlist0_selection "in_home_survey has_valid_rdt_H"
|
| global varlist1_selection "has_valid_rdt_H"
|
|
|
| la var in_home_survey "Took Home Survey"
|
| la var has_valid_rdt_H "Took Home-Based RDT"
|
|
|
|
|
| foreach var in $varlist0_selection $varlist1_selection {
|
| local repx ""
|
| if "`var'"!="nobs" & "`var'"!="bobs" local repx "replace `var'=. if dropme==1"
|
| `repx'
|
| }
|
|
|
|
|
| local v0= wordcount("$varlist0_selection")
|
| local v1= wordcount("$varlist1_selection")
|
|
|
|
|
| local totrow= 2*(`v0'+`v0'+`v1')+3
|
| matrix table_randomization=J(`totrow',8,.)
|
| matrix se= J(`totrow',1,.)
|
|
|
| local part1 "\it{A. Whole Sample} &"
|
|
|
| loc f = 2
|
|
|
| foreach var in $varlist0_selection {
|
|
|
| local lbz: variable label `var'
|
| local namestr " `namestr' "`lbz'" "\thinspace" "
|
|
|
| local q= `f'+1
|
| local part`f' "\enspace `lbz' &"
|
| local part`q' "\thinspace &"
|
|
|
|
|
| reg `var' patient_voucher doctor_voucher $date, clu($cluvar)
|
| local coeff_patient_voucher: display %19.3f _b[patient_voucher]
|
| local coeff_doctor_voucher: display %19.3f _b[doctor_voucher]
|
| local se_patient_voucher: display %19.3f _se[patient_voucher]
|
| local se_doctor_voucher: display %19.3f _se[doctor_voucher]
|
|
|
| matrix table_randomization[`f',2] =`coeff_patient_voucher'
|
| matrix table_randomization[`f',3] =`coeff_doctor_voucher'
|
|
|
| matrix table_randomization[`f'+1,2] =`se_patient_voucher'
|
| matrix table_randomization[`f'+1,3] =`se_doctor_voucher'
|
|
|
| matrix se[`f'+1,1]=1
|
|
|
|
|
| test patient_voucher==doctor_voucher
|
| local p_value1: display %7.3f `r(p)'
|
| matrix table_randomization[`f',4] =`p_value1'
|
|
|
|
|
| test patient_voucher==doctor_voucher==0
|
| local p_value2: display %7.3f `r(p)'
|
| matrix table_randomization[`f',5] =`p_value2'
|
|
|
|
|
| matrix table_randomization[`f',6] =e(N)
|
|
|
|
|
| sum `var' if doctor_voucher+patient_voucher==0 & e(sample)
|
| local control_mean: display %19.3f r(mean)
|
| local control_sd: display %19.3f r(sd)
|
|
|
| matrix table_randomization[`f',1] =`control_mean'
|
| matrix table_randomization[`f'+1,1] =`control_sd'
|
|
|
|
|
| loc f = `f' + 2
|
|
|
| }
|
|
|
| local sustring ""
|
| local sutest1 ""
|
| local sutest2 ""
|
|
|
| local part`f' "\it{B. Selected for Home Survey} &"
|
|
|
| local f = `f'+1
|
|
|
| local namestr " `namestr' "\it{B. Selected for Home Survey}" "
|
|
|
| foreach var in $varlist0_selection {
|
|
|
|
|
| local lbz: variable label `var'
|
| local namestr " `namestr' "`lbz'" "\thinspace" "
|
|
|
| local q= `f'+1
|
| local part`f' "\enspace `lbz' &"
|
| local part`q' "\thinspace &"
|
|
|
|
|
| reg `var' patient_voucher doctor_voucher $date if selected_home_survey==1
|
| est store E`var'
|
| local sustring "`sustring' E`var'"
|
| local sutest2 "`sutest2' [E`var'_mean]patient_voucher=[E`var'_mean]doctor_voucher="
|
| local sutest1 "`sutest1' [E`var'_mean]patient_voucher=[E`var'_mean]doctor_voucher="
|
| reg `var' patient_voucher doctor_voucher $date if selected_home_survey==1, clu($cluvar)
|
| local coeff_patient_voucher: display %19.3f _b[patient_voucher]
|
| local coeff_doctor_voucher: display %19.3f _b[doctor_voucher]
|
| local se_patient_voucher: display %19.3f _se[patient_voucher]
|
| local se_doctor_voucher: display %19.3f _se[doctor_voucher]
|
|
|
| matrix table_randomization[`f',2] =`coeff_patient_voucher'
|
| matrix table_randomization[`f',3] =`coeff_doctor_voucher'
|
|
|
| matrix table_randomization[`f'+1,2] =`se_patient_voucher'
|
| matrix table_randomization[`f'+1,3] =`se_doctor_voucher'
|
|
|
| matrix se[`f'+1,1]=1
|
|
|
|
|
| test patient_voucher==doctor_voucher
|
| local p_value1: display %7.3f `r(p)'
|
| matrix table_randomization[`f',4] =`p_value1'
|
|
|
|
|
| test patient_voucher==doctor_voucher==0
|
| local p_value2: display %7.3f `r(p)'
|
| matrix table_randomization[`f',5] =`p_value2'
|
|
|
|
|
| matrix table_randomization[`f',6] =e(N)
|
|
|
|
|
| sum `var' if doctor_voucher+patient_voucher==0 & e(sample)
|
| local control_mean: display %19.3f r(mean)
|
| local control_sd: display %19.3f r(sd)
|
|
|
| matrix table_randomization[`f',1] =`control_mean'
|
| matrix table_randomization[`f'+1,1] =`control_sd'
|
|
|
|
|
| loc f = `f' + 2
|
|
|
| }
|
|
|
| mat li table_randomization
|
|
|
|
|
|
|
|
|
|
|
| local part`f' "\it{C. Took Home Survey} &"
|
|
|
| local f = `f'+1
|
|
|
| local namestr " `namestr' "\it{C. Took Home Survey}" "
|
|
|
| foreach var in $varlist1_selection {
|
|
|
|
|
| local lbz: variable label `var'
|
| local namestr " `namestr' "`lbz'" "\thinspace" "
|
|
|
| local q= `f'+1
|
| local part`f' "\enspace `lbz' &"
|
| local part`q' "\thinspace &"
|
|
|
|
|
| reg `var' patient_voucher doctor_voucher $date if in_home_survey==1
|
| est store E`var'
|
| local sustring "`sustring' E`var'"
|
| local sutest2 "`sutest2' [E`var'_mean]patient_voucher=[E`var'_mean]doctor_voucher="
|
| local sutest1 "`sutest1' [E`var'_mean]patient_voucher=[E`var'_mean]doctor_voucher="
|
| reg `var' patient_voucher doctor_voucher $date if in_home_survey==1, clu($cluvar)
|
| local coeff_patient_voucher: display %19.3f _b[patient_voucher]
|
| local coeff_doctor_voucher: display %19.3f _b[doctor_voucher]
|
| local se_patient_voucher: display %19.3f _se[patient_voucher]
|
| local se_doctor_voucher: display %19.3f _se[doctor_voucher]
|
|
|
| matrix table_randomization[`f',2] =`coeff_patient_voucher'
|
| matrix table_randomization[`f',3] =`coeff_doctor_voucher'
|
|
|
| matrix table_randomization[`f'+1,2] =`se_patient_voucher'
|
| matrix table_randomization[`f'+1,3] =`se_doctor_voucher'
|
|
|
| matrix se[`f'+1,1]=1
|
|
|
|
|
| test patient_voucher==doctor_voucher
|
| local p_value1: display %7.3f `r(p)'
|
| matrix table_randomization[`f',4] =`p_value1'
|
|
|
|
|
| test patient_voucher==doctor_voucher==0
|
| local p_value2: display %7.3f `r(p)'
|
| matrix table_randomization[`f',5] =`p_value2'
|
|
|
|
|
| matrix table_randomization[`f',6] =e(N)
|
|
|
|
|
| sum `var' if doctor_voucher+patient_voucher==0 & e(sample)
|
| local control_mean: display %19.3f r(mean)
|
| local control_sd: display %19.3f r(sd)
|
|
|
| matrix table_randomization[`f',1] =`control_mean'
|
| matrix table_randomization[`f'+1,1] =`control_sd'
|
|
|
|
|
| loc f = `f' + 2
|
|
|
| }
|
|
|
| local sutest1 "`sutest1' [Egender_mean]patient_voucher"
|
| local sutest2 "`sutest2' 0"
|
|
|
| local df= e(df_r)
|
|
|
| mat li table_randomization
|
| matrix rownames table_randomization= `namestr'
|
|
|
| local bc = rowsof(table_randomization)
|
|
|
| matrix stars = J(`bc',6,0)
|
|
|
| local end0= `v0'*2
|
| local start1= `end0'+3
|
| local end1= `start1' + `v1'*2
|
| local start2= `end1'+3
|
| local end2= `totrow'-1
|
|
|
| forvalues i=4(1)5{
|
|
|
| forvalues k = 2(2)`end0' {
|
|
|
| if table_randomization[`k',`i']<=.01{
|
| local star "1"
|
| }
|
| if table_randomization[`k',`i']>.01 & table_randomization[`k',`i']<=.05{
|
| local star "2"
|
| }
|
| if table_randomization[`k',`i']>.05 & table_randomization[`k',`i']<=.10{
|
| local star "3"
|
| }
|
| if table_randomization[`k',`i']>.10{
|
| local star "0"
|
| }
|
| di
|
| matrix stars[`k',`i'] = `star'
|
| }
|
|
|
| forvalues k = `start1'(2)`end1' {
|
|
|
| if table_randomization[`k',`i']<=.01{
|
| local star "1"
|
| }
|
| if table_randomization[`k',`i']>.01 & table_randomization[`k',`i']<=.05{
|
| local star "2"
|
| }
|
| if table_randomization[`k',`i']>.05 & table_randomization[`k',`i']<=.10{
|
| local star "3"
|
| }
|
| if table_randomization[`k',`i']>.10 {
|
| local star "0"
|
| }
|
| di
|
| matrix stars[`k',`i'] = `star'
|
| }
|
|
|
| forvalues k = `start2'(2)`end2' {
|
|
|
| if table_randomization[`k',`i']<=.01{
|
| local star "1"
|
| }
|
| if table_randomization[`k',`i']>.01 & table_randomization[`k',`i']<=.05{
|
| local star "2"
|
| }
|
| if table_randomization[`k',`i']>.05 & table_randomization[`k',`i']<=.10{
|
| local star "3"
|
| }
|
| if table_randomization[`k',`i']>.10 {
|
| local star "0"
|
| }
|
| di
|
| matrix stars[`k',`i'] = `star'
|
| }
|
| }
|
|
|
|
|
| local cv10= abs(invt(`df',.05))
|
| local cv5= abs(invt(`df',.025))
|
| local cv1= abs(invt(`df',.005))
|
|
|
| forvalues i=2(1)3{
|
|
|
| forvalues k = 2(2)`end0' {
|
|
|
| local ttest=abs(table_randomization[`k',`i']/table_randomization[`k'+1,`i'])
|
| if `ttest'<`cv10' {
|
| local star "0"
|
| }
|
| if `ttest'>=`cv10' & `ttest'<`cv5' {
|
| local star "3"
|
| }
|
| if `ttest'>=`cv5' & `ttest'<`cv1' {
|
| local star "2"
|
| }
|
| if `ttest'>=`cv1' & `ttest'!=. {
|
| local star "1"
|
| }
|
| di
|
| matrix stars[`k',`i'] = `star'
|
| }
|
|
|
| forvalues k = `start1'(2)`end1' {
|
|
|
| local ttest=abs(table_randomization[`k',`i']/table_randomization[`k'+1,`i'])
|
| if `ttest'<`cv10' {
|
| local star "0"
|
| }
|
| if `ttest'>=`cv10' & `ttest'<`cv5' {
|
| local star "3"
|
| }
|
| if `ttest'>=`cv5' & `ttest'<`cv1' {
|
| local star "2"
|
| }
|
| if `ttest'>=`cv1' & `ttest'!=. {
|
| local star "1"
|
| }
|
| di
|
| matrix stars[`k',`i'] = `star'
|
|
|
| }
|
| forvalues k = `start2'(2)`end2' {
|
|
|
| local ttest=abs(table_randomization[`k',`i']/table_randomization[`k'+1,`i'])
|
| if `ttest'<`cv10' {
|
| local star "0"
|
| }
|
| if `ttest'>=`cv10' & `ttest'<`cv5' {
|
| local star "3"
|
| }
|
| if `ttest'>=`cv5' & `ttest'<`cv1' {
|
| local star "2"
|
| }
|
| if `ttest'>=`cv1' {
|
| local star "1"
|
| }
|
| di
|
| matrix stars[`k',`i'] = `star'
|
|
|
| }
|
|
|
| }
|
|
|
| drop _all
|
| svmat table_randomization
|
| svmat stars
|
| svmat se
|
| g t0=""
|
| forval i=1/`totrow' {
|
| di "`part`i''"
|
| replace t0= "`part`i''" if _n==`i'
|
| }
|
|
|
| forval var=1/5 {
|
| tostring table_randomization`var', format("%9.3f") replace force
|
| replace table_randomization`var'="" if table_randomization`var'=="."
|
| replace table_randomization`var'="0"+table_randomization`var' if substr(table_randomization`var',1,1)=="."
|
| replace table_randomization`var'= table_randomization`var'+"\sym{*}" if stars`var'==3
|
| replace table_randomization`var'= table_randomization`var'+"\sym{**}" if stars`var'==2
|
| replace table_randomization`var'= table_randomization`var'+"\sym{***}" if stars`var'==1
|
|
|
| }
|
| replace table_randomization1= "["+table_randomization1+"]" if se1==1
|
|
|
| forval i=2/3 {
|
| replace table_randomization`i'="("+table_randomization`i'+")" if se1==1
|
| }
|
|
|
| forval i=1/5 {
|
| replace table_randomization`i'= table_randomization`i'+"&"
|
| }
|
| tostring table_randomization6, format("%9.0f") replace force
|
| replace table_randomization6="" if table_randomization6=="."
|
| replace table_randomization6="0"+table_randomization6 if substr(table_randomization6,1,1)=="."
|
|
|
|
|
| replace table_randomization6= table_randomization6+"\\" if table_randomization6!=""
|
| replace table_randomization6= table_randomization6+"& \\" if table_randomization6==""
|
|
|
| set obs `=_N+2'
|
| g index= _n
|
| replace index=0 if _n==_N-1
|
| sort index
|
| order t0 table_randomization1-table_randomization8
|
| keep t0-table_randomization8
|
| list, clean
|
|
|
| #delimit ;
|
| local fn "$footnote0_alt $footnote1";
|
| local text0 "\begin{table}[h!] \begin{adjustbox}{max width=1\textwidth} \begin{threeparttable} \caption{Selection into Analysis Samples by Treatment} \label{selection} {
|
| \begin{tabular}{l*{7}{c}} \hline\hline & \multicolumn{1}{c}{(1)} & \multicolumn{1}{c}{(2)} & \multicolumn{1}{c}{(3)} & \multicolumn{1}{c}{(4)} & \multicolumn{1}{c}{(5)} & \multicolumn{1}{c}{(6)} \\
|
| & & \multicolumn{2}{c}{Regression Coefficients} & \multicolumn{2}{c}{P-Values} & \\
|
| \cmidrule(lr){3-4} \cmidrule(lr){5-6} &
|
| \multicolumn{1}{c}{\shortstack{Control\\Mean}} & \multicolumn{1}{c}{\shortstack{Patient\\Voucher}} & \multicolumn{1}{c}{\shortstack{Doctor\\ Voucher}} &
|
| \multicolumn{1}{c}{\shortstack{Joint Test\\ PV=DV}} & \multicolumn{1}{c}{\shortstack{Joint Test \\ PV=DV=0}} & \multicolumn{1}{c}{N} \\ \hline";
|
| local textlast "\hline \end{tabular} } \begin{tablenotes}[flushleft] \small
|
| \item `fn'
|
| \end{tablenotes} \end{threeparttable} \end{adjustbox} \end{table}";
|
| #delimit cr
|
| replace t0="`text0'" if _n==1
|
| replace t0="`textlast'" if _n==_N
|
|
|
|
|
| outfile t0-table_randomization6 using "$tables/B5_selection.tex", noquote replace wide
|
|
|
| restore
|
|
|