/*********************************************************************************************************************************
*************************************************** The World Bank ***************************************************************
*************************** Analysis of the impact evaluation of informal firms training in Togo *********************************
*************************************** Private Sector Development Support Project ***********************************************
************************************************* Data Analysis Do-file **********************************************************
*********************************************************************************************************************************/
set more off
**********************************************************************************************************************************
******************************************************* Manuscript ***************************************************************
**********************************************************************************************************************************
clear
clear matrix
clear mata
set maxvar 10000
cap ssc install qreg2
cap ssc install estadd
use "$Master_final"

************************
** Reshaping the data **
************************

** Rename sales variables **
forval i = 1/4 {
	ren win_fu`i'_sales_lm fu`i'_mo_sales_win
	ren win_fu`i'_profits_lm fu`i'_mo_profits_win
	ren ihs_fu`i'_profits_lm fu`i'_mo_profits_ihs
	ren win_fu`i'_profits_lw fu`i'_week_profits_win
	}
ren win_bl_sales_lm mo_sales_bl_win
ren win_bl_sales_lm_miss mo_sales_bl_win_miss
ren win_bl_profits_lm mo_profits_bl_win
ren bl_profits_lm_miss mo_profits_bl_miss
ren win_bl_profits_lm_miss mo_profits_bl_win_miss
ren ihs_bl_profits_lm mo_profits_bl_ihs
ren win_bl_profits_lw week_profits_bl_win
ren win_bl_profits_lw_miss week_profits_bl_win_miss

** Overall **
ren fu4_* *_fu4
ren fu3_* *_fu3
ren fu2_* *_fu2
ren fu1_* *_fu1
ren bl_* *_bl

ren win_fu4_* *_win_fu4
ren win_fu3_* *_win_fu3
ren win_fu2_* *_win_fu2
ren win_fu1_* *_win_fu1

** Reshape **
keep id_ent assign_man assign_ent assign_group avg_z_hyp_a1* mo_* week_* strata avg_z_hyp_b1* business_practice* ///
	interviewed_* avg_z_hyp_cs4a* sec_sector_change* PI_* has_business* avg_z_hyp_cs4c*
reshape long mo_profits_ihs_fu has_business_fu mo_sales_win_fu mo_profits_win_fu week_profits_win_fu avg_z_hyp_a1_fu ///
	business_practice_fu PI_fu avg_z_hyp_b1_fu avg_z_hyp_cs4a_fu sec_sector_change_fu avg_z_hyp_cs4c_fu, i(id_ent) j(fu)

************************************************
** Figure 1: Quantile Treatment Effects - IHS **
************************************************

clear matrix
preserve
	
forval i=.05(.05) 1 {
	di `i'
		
	*Quantile regression:
	quietly xi: qreg2 mo_profits_ihs_fu assign_man assign_ent mo_profits_bl_ihs mo_profits_bl_miss i.fu,  cluster(id_ent) q(`i')
		scalar beta = _b[assign_ent]
		scalar sigma = _se[assign_ent]
		scalar beta_man=_b[assign_man]
		scalar sigma_man=_se[assign_man]
		scalar cil = beta - (1.64*sigma)
		scalar ciu = beta + (1.64*sigma)
		scalar cil_man=beta_man - (1.64*sigma_man)
		scalar ciu_man=beta_man + (1.64*sigma_man)
		test assign_man=assign_ent
		scalar pval1=r(p)
		matrix pool_qreg = [nullmat(pool_qreg) \ `i', beta, beta_man, cil, ciu, cil_man, ciu_man, pval1]
	}

clear
svmat pool_qreg
	ren pool_qreg1 qtile
	ren pool_qreg2 pi_treatment
	ren pool_qreg3 man_treatment
	ren pool_qreg4 treatment_cilo
	ren pool_qreg5 treatment_cihi
	ren pool_qreg6 confman_lo
	ren pool_qreg7 confman_hi
	ren pool_qreg8 pvalue
	
gen y0=0
gen Percentile=qtile*100
sort Percentile
replace y0=. if Percentile<5 | Percentile>95
format pi_treatment man_treatment treatment_cihi treatment_cilo %6.0f 

replace man_treatment=man_treatment*100
replace pi_treatment=pi_treatment*100

twoway (line man_treatment Percentile if Percentile>=10 & Percentile<=90, lwidth(thick) lcolor(gray) lpattern(longdash)) ///
	   (line pi_treatment Percentile if Percentile>=10 & Percentile<=90, lwidth(thick) lcolor(black) lpattern(line))   ///
	   (line y0 Percentile if Percentile>=10 & Percentile<=90, lcolor(black)), ///
	    xlabel(10 20 30 40 50 60 70 80 90) ylabel(-20 0 20 40) ///
		title(Quantile Regression) ytitle("Percentage Impact on Monthly Profits") ///
		scheme(s1manual) legend(order(1 2 4)) legend(rows(1))	
graph save "$results/FigureQ1log.gph", replace
restore

*******************************************************************************
** Table 1: Impact of Training Programs on Survival, Profitability and Sales **
*******************************************************************************
estimates clear

** Business Survival **
xi: areg has_business_fu assign_man assign_ent i.fu, a(strata) cluster(id_ent) robust
	estimates store Firms_survival
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum has_business_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)

** Monthly sales, winsorized **
xi: areg mo_sales_win_fu assign_man assign_ent mo_sales_bl_win mo_sales_bl_win_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store Monthly_sales_winsorized
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum mo_sales_win_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
** Monthly profits, winsorized **
xi: areg mo_profits_win_fu assign_man assign_ent mo_profits_bl_win mo_profits_bl_win_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store Monthly_profits_winsorized
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum mo_profits_win_fu if assign_group==3
	estadd scalar control_mean = r(mean)	

** Weekly profits **
xi: areg week_profits_win_fu assign_man assign_ent week_profits_bl_win week_profits_bl_win_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store Weekly_profits_winsorized
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum week_profits_win_fu if assign_group==3
	estadd scalar control_mean = r(mean)	

** Standardized z-score **
xi: areg avg_z_hyp_a1_fu assign_man assign_ent avg_z_hyp_a1_bl avg_z_hyp_a1_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store A1_zscore
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum avg_z_hyp_a1_fu if assign_group==3
	estadd scalar control_mean = r(mean)

** Export results **
estout Firms_survival Monthly_sales_winsorized Monthly_profits_winsorized Weekly_profits_winsorized A1_zscore using ///
	"$results\Table_1_`sysdate'.txt", replace cells(b(fmt(%12.3fc)star) se(par fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) ///
	drop(_cons) legend varlabels(assign_man Managerial assign_ent PI) stats(N p_joint_significance p_man_ent control_mean, fmt(0 %12.4fc %12.4fc %12.4fc %12.2fc %12.2fc)) ///
	title("Table 1: Impact on Primary Outcomes")

*********************************************************
** Table 2: Mechanisms through which training operates **
*********************************************************
estimates clear

** Business Practices **
xi: areg business_practice_fu assign_man assign_ent business_practice_bl business_practice_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Business_practice_index
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum business_practice_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)

** Personal Initiative **
xi: areg PI_fu assign_man assign_ent PI_bl PI_bl_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store PI_index
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum PI_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)

** Capital and Labor inputs **
xi: areg avg_z_hyp_b1_fu assign_man assign_ent avg_z_hyp_b1_bl avg_z_hyp_b1_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store B1_zscore
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum avg_z_hyp_b1_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)

** Innovation Index **
xi:	areg avg_z_hyp_cs4a_fu assign_man assign_ent avg_z_hyp_cs4a_bl avg_z_hyp_cs4a_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Innovation
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum avg_z_hyp_cs4a_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)

** Diversified Product Line **
xi: areg sec_sector_change_fu assign_man assign_ent i.fu, a(strata) cluster(id_ent) robust
	estimates store sec_sector
	test assign_man=assign_ent	
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum sec_sector_change_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)

** Access to Finance Index **
xi:	areg avg_z_hyp_cs4c_fu assign_man assign_ent avg_z_hyp_cs4c_bl avg_z_hyp_cs4c_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store z_cs4c
	test assign_man=assign_ent	
	estadd scalar p_man_ent = r(p)
	sum avg_z_hyp_cs4c_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)
	estadd scalar control_med = r(p50)


estout Business_practice_index PI_index B1_zscore Innovation sec_sector z_cs4c using "$results\Table_2_`sysdate'.txt", replace ///
	cells(b(fmt(%12.3fc)star) se(par fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man ///
	Managerial assign_ent Entrepreneurial) stats(N p_joint_significance p_man_ent control_mean, fmt(0 %12.4fc %12.4fc %12.4fc %12.2fc %12.2fc))  ///
	title("Table 2: Impact on Mechanisms through which training operates")

**********************************************************************************************************************************
*********************************************** Supplemental Online Material *****************************************************
**********************************************************************************************************************************

*************************************************************
** Figure S1: Round by round trajectory of Monthly Profits **
*************************************************************

preserve
clear
use "$Master_final"

** Average profits **
rename win_bl_profits_lm win_fu0_profits_lm
forval i=0/4 {
bysort assign_group: egen profits_fu`i' = mean(win_fu`i'_profits_lm)
}

** Time variable **
gen year_fu0 = 1 
gen year_fu1 = 2 if interviewed_fu1==1
gen year_fu2 = 3 if interviewed_fu2==1
gen year_fu3 = 4 if interviewed_fu3==1
gen year_fu4 = 5 if interviewed_fu4==1

keep profits_* year_* id_ent assign_group

reshape long profits_fu year_fu, i(id_ent) j(fu)
gen profits_1 = profits_fu if assign_group==1
gen profits_2 = profits_fu if assign_group==2
gen profits_3 = profits_fu if assign_group==3
label var profits_1 "Managerial"
label var profits_2 "Personal Initiative"
label var profits_3 "Control group"

rename year_fu year
sort year

** Original **
twoway line profits_1 year || line profits_2 year || line profits_3 year, sort ylabel(0(50000)200000) ///
	ytitle("Winsorized Monthly Profits") xlabel(1 "Baseline" 2 "FU1" 3 "FU2" 4 "FU3" 5 "FU4") /// 
	xtitle(" ") title("Profits by treatment group over time")
graph save "$results/FigureS1.gph", replace

restore

********************************************************************************************
** Figure S2: P-values for testing Equality of Training Treatments at Different Quantiles **
********************************************************************************************

clear matrix
 	preserve
	
	forval i=.05(.05) 1 {
		di `i'
		
		*Quantile regression:
quietly xi: qreg2 mo_profits_ihs_fu assign_man assign_ent mo_profits_bl_ihs mo_profits_bl_miss i.fu,  cluster(id_ent) q(`i')
		scalar beta = _b[assign_ent]
		scalar sigma = _se[assign_ent]
		scalar beta_man=_b[assign_man]
		scalar sigma_man=_se[assign_man]
		scalar cil = beta - (1.64*sigma)
		scalar ciu = beta + (1.64*sigma)
		scalar cil_man=beta_man - (1.64*sigma_man)
		scalar ciu_man=beta_man + (1.64*sigma_man)
		test assign_man=assign_ent
		scalar pval1=r(p)
		matrix pool_qreg = [nullmat(pool_qreg) \ `i', beta, beta_man, cil, ciu, cil_man, ciu_man, pval1]
		}

	clear
	svmat pool_qreg
	ren pool_qreg1 qtile
	ren pool_qreg2 pi_treatment
	ren pool_qreg3 man_treatment
	ren pool_qreg4 treatment_cilo
	ren pool_qreg5 treatment_cihi
	ren pool_qreg6 confman_lo
	ren pool_qreg7 confman_hi
	ren pool_qreg8 pvalue
	
gen y0=0
gen Percentile=qtile*100
sort Percentile
replace y0=. if Percentile<5 | Percentile>95
format pi_treatment man_treatment treatment_cihi treatment_cilo %6.0f 

twoway line pvalue Percentile, xlabel(5 10 20 30 40 50 60 70 80 90 95) yline(0.10) scheme(s1manual)
graph save "$results/Figure_S2.gph", replace
restore

***********************************************************
** Table S1: Impact of Training on Survey Response Rates **
***********************************************************

clear
clear matrix
use "$Master_final"

estimates clear
forval i=1/4 {
	qui areg interviewed_fu`i' assign_man assign_ent, a(strata) robust
	estimates store fu`i'
	esttab, se scalars(N p F)
	test assign_man = assign_ent
	estadd scalar p_man_ent = r(p)
	sum interviewed_fu`i' if assign_group==3
	estadd scalar control_mean = r(mean)
	}
estout fu1 fu2 fu3 fu4 using "$results\Table_S1_`sysdate'.txt", replace cells(b(fmt(%6.3fc)star) se(par fmt(%6.3fc))) ///
	starlevels(* .1 ** .05 *** .01) legend varlabels(assign_man Managerial assign_ent Entrepreneurial) stats (N p_man_ent ///
	control_mean, fmt(0 %12.4fc))

************************
** Test over time **
************************
estimates clear

clear
clear matrix
use "$Master_final"


*************** Renaming******
ren fu4_* *_fu4
ren fu3_* *_fu3
ren fu2_* *_fu2
ren fu1_* *_fu1
ren bl_* *_bl

ren win_fu4_* *_win_fu4
ren win_fu3_* *_win_fu3
ren win_fu2_* *_win_fu2
ren win_fu1_* *_win_fu1


preserve
** Reshape **
keep id_ent assign_man assign_ent assign_group strata interviewed_* PI_* has_business* 
reshape long has_business_fu interviewed_fu PI_fu, i(id_ent) j(fu)

foreach var in assign_man assign_ent {
	forval i=1/4 {
		gen `var'_fu`i' = (`var'==1 & fu==`i')
		}
	}


global controls assign_man_fu1 assign_man_fu2 assign_man_fu3 assign_man_fu4 assign_ent_fu1 assign_ent_fu2 assign_ent_fu3 assign_ent_fu4

xi: areg interviewed_fu $controls i.fu, a(strata) cluster(id_ent) robust
	estimates store Interviewed_FU
	test assign_man_fu1=assign_man_fu2=assign_man_fu3=assign_man_fu4
	estadd scalar p_man = r(p)
	test assign_ent_fu1=assign_ent_fu2=assign_ent_fu3=assign_ent_fu4
	estadd scalar p_ent = r(p)

estout Interviewed_FU using "$results\Table_S1b_`sysdate'.txt", replace cells(b(fmt(%6.3fc)star) se(par fmt(%6.3fc))) ///
	starlevels(* .1 ** .05 *** .01) legend varlabels(assign_man_fu1 Managerial_FU1 assign_man_fu2 Managerial_FU2 assign_man_fu3 Managerial_FU3 assign_man_fu4 Managerial_FU4 ///
	assign_ent_fu1 Entrepreneurial_FU1 assign_ent_fu2 Entrepreneurial_FU2 assign_ent_fu3 Entrepreneurial_FU3 assign_ent_fu4 Entrepreneurial_FU4) stats (N p_man p_ent ///
	, fmt(0 %12.4fc %12.4fc))
	
	
restore	
	
**************************************************************
** Table S2: Characteristics of Sample and Baseline Balance **
**************************************************************

estimates clear

clear
clear matrix
use "$Master_final"

*change BL variables that had been recoded to 0 if they were missing for the regressions back to missing for the descriptive statistics
gen win_bl_sales_lw_miss=bl_sales_lw_miss
gen win_bl_k_stock_miss=bl_k_stock_miss
foreach var in win_bl_profits_lm win_bl_sales_lm ///
	win_bl_sales_lw  win_bl_profits_lw  bl_no_workers win_bl_k_stock  PI_bl bl_business_practice {
	replace `var'=. if `var'_miss==1
	}

mat y = J(15,13,.)	
local j=1
foreach var in win_bl_profits_lm bl_commerce bl_production female bl_age bl_years_schooling bl_firm_age win_bl_sales_lm ///
	win_bl_sales_lw  win_bl_profits_lw  bl_no_workers win_bl_k_stock  PI_bl bl_business_practice {
	
	** Control group Means **
	sum `var' if assign_group==3, d
	mat y[`j',1]=r(mean)
	mat y[`j',2]== r(sd)
    mat y[`j',3] = r(p50)
	
	** Traditional Business **
	qui areg `var' assign_man if (assign_group==3|assign_group==1), a(strata) r
	test assign_man=0
	mat y[`j',10] = r(p)
	sum `var' if assign_group==1, d
	mat y[`j',4]=r(mean)
	mat y[`j',5]== r(sd)
    mat y[`j',6] = r(p50)
	
	** Personal Initiative **
	qui areg `var' assign_ent if (assign_group==3|assign_group==2), a(strata) r
	test assign_ent = 0 
	mat y[`j',11] = r(p)	
	sum `var' if assign_group==2, d
    mat y[`j',7]=r(mean)
	mat y[`j',8]== r(sd)
    mat y[`j',9] = r(p50)

	** Test equality of means across all three treatments **
	qui areg `var' assign_man assign_ent, a(strata) r
	test assign_man=assign_ent=0
	mat y[`j',12] = r(p)
	
	** Whole Sample Mean for Description in Text**
	sum `var'
	mat y[`j',13]  = r(mean)
	local j=`j'+1
}
count if assign_group==3
mat y[15,1] = r(N)
count if assign_group==1
mat y[15,2]= r(N)
count if assign_group==2
mat y[15,3]=r(N)
mat rownames y = "Profits" "Commerce" "Production" "Female" "Age" "Schooling" "Firm Age" "Sales" "Weekly Sales" "Weekly Profits" "Workers" "Capital Stock" "PI Scale" "Business Practices" "Sample Size"
mat colnames y = "Mean" "SD" "Median" "Mean" "SD" "Median" "Mean" "SD" "Median"  "p-value" "p-value" "p-value" "Mean"
mat2txt, matrix(y) saving("$results\S2.xls") replace

** Joint Orthogonality Tests **

* Traditional Training Vs Control *
#delimit ;
reg assign_man win_bl_profits_lm bl_commerce bl_production female bl_age bl_years_schooling bl_firm_age win_bl_sales_lm 
win_bl_sales_lw win_bl_profits_lw bl_no_workers win_bl_k_stock PI_bl bl_business_practice if (assign_group==3|assign_group==1), r;

* Personal Initiative Training Vs Control *
#delimit ;
reg assign_ent win_bl_profits_lm bl_commerce bl_production female bl_age bl_years_schooling bl_firm_age win_bl_sales_lm 
win_bl_sales_lw win_bl_profits_lw bl_no_workers win_bl_k_stock PI_bl bl_business_practice if (assign_group==3|assign_group==2), r;

* Comparing two training treatment groups to one another *
#delimit ;
reg assign_ent win_bl_profits_lm bl_commerce bl_production female bl_age bl_years_schooling bl_firm_age win_bl_sales_lm 
win_bl_sales_lw win_bl_profits_lw bl_no_workers win_bl_k_stock PI_bl bl_business_practice if (assign_group==1|assign_group==2), r;	

#delimit cr
	
***************************************************************************
** Table S4: Baseline Balance for Sample Interviewed at Last Follow-up **
***************************************************************************
estimates clear

clear
clear matrix
clear mata
use "$Master_final"

*change BL variables that had been recoded to 0 if they were missing for the regressions back to missing for the descriptive statistics
gen win_bl_sales_lw_miss=bl_sales_lw_miss
gen win_bl_k_stock_miss=bl_k_stock_miss
foreach var in win_bl_profits_lm win_bl_sales_lm ///
	win_bl_sales_lw  win_bl_profits_lw  bl_no_workers win_bl_k_stock  PI_bl bl_business_practice {
	replace `var'=. if `var'_miss==1
	}

keep if interviewed_fu4==1
mat y = J(15,13,.)	
local j=1
foreach var in win_bl_profits_lm bl_commerce bl_production female bl_age bl_years_schooling bl_firm_age win_bl_sales_lm ///
	win_bl_sales_lw  win_bl_profits_lw  bl_no_workers win_bl_k_stock  PI_bl bl_business_practice {
	
	** Control group Means **
	sum `var' if assign_group==3, d
	mat y[`j',1]=r(mean)
	mat y[`j',2]== r(sd)
    mat y[`j',3] = r(p50)
	
	** Traditional Business **
	qui areg `var' assign_man if (assign_group==3|assign_group==1), a(strata) r
	test assign_man=0
	mat y[`j',10] = r(p)
	sum `var' if assign_group==1, d
	mat y[`j',4]=r(mean)
	mat y[`j',5]== r(sd)
    mat y[`j',6] = r(p50)
	
	** Personal Initiative **
	qui areg `var' assign_ent if (assign_group==3|assign_group==2), a(strata) r
	test assign_ent = 0 
	mat y[`j',11] = r(p)	
	sum `var' if assign_group==2, d
    mat y[`j',7]=r(mean)
	mat y[`j',8]== r(sd)
    mat y[`j',9] = r(p50)

	** Test equality of means across all three treatments **
	qui areg `var' assign_man assign_ent, a(strata) r
	test assign_man=assign_ent=0
	mat y[`j',12] = r(p)
	
	** Whole Sample Mean for Description in Text**
	sum `var'
	mat y[`j',13]  = r(mean)
	local j=`j'+1
}
count if assign_group==3
mat y[15,1] = r(N)
count if assign_group==1
mat y[15,2]= r(N)
count if assign_group==2
mat y[15,3]=r(N)
mat rownames y = "Profits" "Commerce" "Production" "Female" "Age" "Schooling" "Firm Age" "Sales" "Weekly Sales" "Weekly Profits" "Workers" "Capital Stock" "PI Scale" "Business Practices" "Sample Size"
mat colnames y = "Mean" "SD" "Median" "Mean" "SD" "Median" "Mean" "SD" "Median"  "p-value" "p-value" "p-value" "Mean"
mat2txt, matrix(y) saving("$results\S4.xls") replace
	
** Joint Orthogonality Tests **

	* Traditional Training Vs Control *
	#delimit ;
	reg assign_man  win_bl_profits_lm bl_commerce bl_production female bl_age bl_years_schooling bl_firm_age win_bl_sales_lm 
	win_bl_sales_lw  win_bl_profits_lw  bl_no_workers win_bl_k_stock  PI_bl bl_business_practice if (assign_group==3|assign_group==1), r;

	* Personal Initiative Training Vs Control *
	#delimit ;
	reg assign_ent  win_bl_profits_lm bl_commerce bl_production female bl_age bl_years_schooling bl_firm_age win_bl_sales_lm 
	win_bl_sales_lw  win_bl_profits_lw  bl_no_workers win_bl_k_stock  PI_bl bl_business_practice if (assign_group==3|assign_group==2), r;

	* Comparing two training treatment groups to one another *
	#delimit ;
	reg assign_ent  win_bl_profits_lm bl_commerce bl_production female bl_age bl_years_schooling bl_firm_age win_bl_sales_lm 
	win_bl_sales_lw  win_bl_profits_lw  bl_no_workers win_bl_k_stock  PI_bl bl_business_practice if (assign_group==1|assign_group==2) & interviewed_fu4==1, r;	

	#delimit cr

*change bl missing back to 0 for analysis
foreach var in win_bl_profits_lm win_bl_sales_lm ///
	win_bl_sales_lw  win_bl_profits_lw  bl_no_workers win_bl_k_stock  PI_bl bl_business_practice {
	replace `var'=0 if `var'_miss==1
	}

**********************************************************
** Table S5: Round-by-Round Impacts on Primary Outcomes **
**********************************************************
clear
clear matrix
clear mata
use "$Master_final"
** Panel A: Firm Survival **
forval i=1/4 {
	areg fu`i'_has_business assign_man assign_ent, a(strata) robust
	estimates store fu`i'_survival
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum fu`i'_has_business if assign_group==3, d
	estadd scalar control_mean = r(mean)
	estadd scalar control_med = r(p50)
}

** Panel B: Monthly Sales, winsorized at the 99th percentile **
forval i=1/4 {
	areg win_fu`i'_sales_lm assign_man assign_ent win_bl_sales_lm bl_sales_lm_miss, a(strata) robust
	estimates store fu`i'_mo_sales
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum win_fu`i'_sales_lm if assign_group==3, d
	estadd scalar control_mean = r(mean)
	estadd scalar control_med = r(p50)
}

** Panel C: Monthly Profits, winsorized at the 99th percentile **
forval i=1/4 {
	areg win_fu`i'_profits_lm assign_man assign_ent win_bl_profits_lm bl_profits_lm_miss, a(strata) robust
	estimates store fu`i'_mo_profits
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum win_fu`i'_profits_lm if assign_group==3, d
	estadd scalar control_mean = r(mean)
	estadd scalar control_med = r(p50)
	
}

** Panel D: Weekly Profits, winsorized at the 99th percentile **
forval i=1/4 {
	areg win_fu`i'_profits_lw assign_man assign_ent win_bl_profits_lw bl_profits_lw_miss, a(strata) robust
	estimates store fu`i'_week_profits
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum win_fu`i'_profits_lw if assign_group==3, d
	estadd scalar control_mean = r(mean)
	estadd scalar control_med = r(p50)
	}
	
** Panel E: Profits and Sales Index **
forval i=1/4 {
	areg fu`i'_avg_z_hyp_a1 assign_man assign_ent bl_avg_z_hyp_a1 bl_avg_z_hyp_a1_miss, a(strata) robust
	estimates store fu`i'_zscore
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum fu`i'_avg_z_hyp_a1 if assign_group==3, d
	estadd scalar control_mean = r(mean)
	estadd scalar control_med = r(p50)
}	

estout fu1_survival fu2_survival fu3_survival fu4_survival fu1_mo_sales fu2_mo_sales fu3_mo_sales fu4_mo_sales ///
	fu1_mo_profits fu2_mo_profits fu3_mo_profits fu4_mo_profits fu1_week_profits fu2_week_profits fu3_week_profits ///
	fu4_week_profits fu1_zscore fu2_zscore fu3_zscore fu4_zscore using "$results\Table_S5_`sysdate'.txt", replace ///
	cells(b(fmt(%12.9fc)star) se(par fmt(%12.3fc))) drop(_cons) starlevels(* .1 ** .05 *** .01) legend varlabels(assign_man ///
	Managerial assign_ent Entrepreneurial) stats(N p_joint_significance p_man_ent control_mean, fmt(0 %12.4fc %12.4fc %12.4fc %12.2fc %12.2fc)) ///
	title("Round by Round Impact on Primary outcomes")


************************
** Test over time **
************************
estimates clear

clear
clear matrix
use "$Master_final"


*************** Renaming******
forval i = 1/4 {
	ren win_fu`i'_sales_lm fu`i'_mo_sales_win
	ren win_fu`i'_profits_lm fu`i'_mo_profits_win
	ren ihs_fu`i'_profits_lm fu`i'_mo_profits_ihs
	ren win_fu`i'_profits_lw fu`i'_week_profits_win
	}
ren win_bl_sales_lm mo_sales_bl_win
ren win_bl_sales_lm_miss mo_sales_bl_win_miss
ren win_bl_profits_lm mo_profits_bl_win
ren bl_profits_lm_miss mo_profits_bl_miss
ren win_bl_profits_lm_miss mo_profits_bl_win_miss
ren ihs_bl_profits_lm mo_profits_bl_ihs
ren win_bl_profits_lw week_profits_bl_win
ren win_bl_profits_lw_miss week_profits_bl_win_miss

ren fu4_* *_fu4
ren fu3_* *_fu3
ren fu2_* *_fu2
ren fu1_* *_fu1
ren bl_* *_bl

ren win_fu4_* *_win_fu4
ren win_fu3_* *_win_fu3
ren win_fu2_* *_win_fu2
ren win_fu1_* *_win_fu1


preserve
** Reshape **
keep id_ent assign_man assign_ent assign_group avg_z_hyp_a1* mo_* week_* strata avg_z_hyp_b1* business_practice* ///
	interviewed_* avg_z_hyp_cs4a* sec_sector_change* PI_* has_business* 
reshape long mo_profits_ihs_fu has_business_fu mo_sales_win_fu mo_profits_win_fu week_profits_win_fu avg_z_hyp_a1_fu ///
	business_practice_fu interviewed_fu PI_fu avg_z_hyp_b1_fu avg_z_hyp_cs4a_fu sec_sector_change_fu, i(id_ent) j(fu)

foreach var in assign_man assign_ent {
	forval i=1/4 {
		gen `var'_fu`i' = (`var'==1 & fu==`i')
		}
	}


global controls assign_man_fu1 assign_man_fu2 assign_man_fu3 assign_man_fu4 assign_ent_fu1 assign_ent_fu2 assign_ent_fu3 assign_ent_fu4

** Panel A: Firm Survival **
xi: areg has_business $controls i.fu, a(strata) cluster(id_ent) robust
	estimates store Has_business_FU
	test assign_man_fu1=assign_man_fu2=assign_man_fu3=assign_man_fu4
	estadd scalar p_man = r(p)
	test assign_ent_fu1=assign_ent_fu2=assign_ent_fu3=assign_ent_fu4
	estadd scalar p_ent = r(p)

** Panel B: Monthly Sales, winsorized at the 99th percentile **
xi: areg mo_sales_win_fu $controls mo_sales_bl_win mo_sales_bl_win_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store Monthly_Sales_FU
	test assign_man_fu1=assign_man_fu2=assign_man_fu3=assign_man_fu4
	estadd scalar p_man = r(p)
	test assign_ent_fu1=assign_ent_fu2=assign_ent_fu3=assign_ent_fu4
	estadd scalar p_ent = r(p)

** Panel C: Monthly Profits, winsorized at the 99th percentile **
xi: areg mo_profits_win_fu $controls mo_profits_bl_win mo_profits_bl_win_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store Monthly_Profits_FU
	test assign_man_fu1=assign_man_fu2=assign_man_fu3=assign_man_fu4
	estadd scalar p_man = r(p)
	test assign_ent_fu1=assign_ent_fu2=assign_ent_fu3=assign_ent_fu4
	estadd scalar p_ent = r(p)

** Panel D: Weekly Profits, winsorized at the 99th percentile **
xi: areg week_profits_win_fu $controls week_profits_bl_win week_profits_bl_win_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store Weekly_Profits_FU
	test assign_man_fu1=assign_man_fu2=assign_man_fu3=assign_man_fu4
	estadd scalar p_man = r(p)
	test assign_ent_fu1=assign_ent_fu2=assign_ent_fu3=assign_ent_fu4
	estadd scalar p_ent = r(p)

** Panel E: Standardized z-score - Sales and Profits **
xi: areg avg_z_hyp_a1_fu $controls avg_z_hyp_a1_bl avg_z_hyp_a1_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Zscore_FU
	test assign_man_fu1=assign_man_fu2=assign_man_fu3=assign_man_fu4
	estadd scalar p_man = r(p)
	test assign_ent_fu1=assign_ent_fu2=assign_ent_fu3=assign_ent_fu4
	estadd scalar p_ent = r(p)

estout Has_business_FU Monthly_Sales_FU Monthly_Profits_FU Weekly_Profits_FU Zscore_FU using "$results\Table_S5b_`sysdate'.txt", replace cells(b(fmt(%6.3fc)star) se(par fmt(%12.3fc))) ///
	starlevels(* .1 ** .05 *** .01) legend varlabels(assign_man_fu1 Managerial_FU1 assign_man_fu2 Managerial_FU2 assign_man_fu3 Managerial_FU3 assign_man_fu4 Managerial_FU4 ///
	assign_ent_fu1 Entrepreneurial_FU1 assign_ent_fu2 Entrepreneurial_FU2 assign_ent_fu3 Entrepreneurial_FU3 assign_ent_fu4 Entrepreneurial_FU4) stats (N p_man p_ent ///
	, fmt(0 %12.4fc %12.4fc))
	
	
restore

	
	
************************************************************************
** Table S6: Robustness of Primary Impact to Differential Attrition **
************************************************************************

clear
clear matrix
clear mata
set maxvar 10000
use "$Master_final"

************************
** Reshaping the data **
************************

** Rename sales variables **
forval i = 1/4 {
	ren win_fu`i'_profits_lm fu`i'_mo_profits_win
	}
ren win_bl_profits_lm mo_profits_bl_win
ren bl_profits_lm_miss mo_profits_bl_miss

** Overall **
ren fu4_* *_fu4
ren fu3_* *_fu3
ren fu2_* *_fu2
ren fu1_* *_fu1
ren bl_* *_bl

ren win_fu4_* *_win_fu4
ren win_fu3_* *_win_fu3
ren win_fu2_* *_win_fu2
ren win_fu1_* *_win_fu1

** Reshape **
keep id_ent assign_man assign_ent assign_group avg_z_hyp_a1* mo_* strata 
reshape long mo_profits_win_fu avg_z_hyp_a1_fu, i(id_ent) j(fu)

** Panel A: Standardized Index of Profits and Sales **
eststo clear

** Standardized z-score **
xi: areg avg_z_hyp_a1_fu assign_man assign_ent avg_z_hyp_a1_bl avg_z_hyp_a1_miss_bl i.fu, a(strata) cluster(id_ent) robust
eststo robust_1

*** Robustness to Attrition
set seed 124
gen z_a1_top=avg_z_hyp_a1_fu
egen rank1a1 = rank(z_a1_top), by(assign_group fu) unique
egen rank1b1 = rank(-z_a1_top), by(assign_group fu) unique

* Assume all extra attritors were from top of distribution
replace z_a1_top=. if assign_man==1 & ((fu==1 & rank1b1<=8)|(fu==2 & rank1b1<=21)|(fu==3 & rank1b1<=16)|(fu==4 & rank1b1<=4))
replace z_a1_top=. if assign_ent==1 & ((fu==1 & rank1b1<=11)|(fu==2 & rank1b1<=15)|(fu==3 & rank1b1<=16)|(fu==4 & rank1b1<=14))

xi: areg z_a1_top assign_man assign_ent avg_z_hyp_a1_bl avg_z_hyp_a1_miss_bl i.fu, a(strata) cluster(id_ent) robust
eststo robust_2

*** Second alternative, assume additional attritors in control were at different parts of PI treated distribution
sum avg_z_hyp_a1_fu if assign_ent==1 & fu==1, de
gen high95=r(p95)
gen high90=r(p90)
gen high75=r(p75)
gen high50=r(p50)
sum avg_z_hyp_a1_fu if assign_ent==1 & fu==2, de
replace high95=r(p95) if fu==2 
replace high90=r(p90) if fu==2
replace high75=r(p75) if fu==2
replace high50=r(p50) if fu==2
sum avg_z_hyp_a1_fu if assign_ent==1 & fu==3, de
replace high95=r(p95) if fu==3 
replace high90=r(p90) if fu==3
replace high75=r(p75) if fu==3
replace high50=r(p50) if fu==3
sum avg_z_hyp_a1_fu if assign_ent==1 & fu==4, de
replace high95=r(p95) if fu==4 
replace high90=r(p90) if fu==4
replace high75=r(p75) if fu==4
replace high50=r(p50) if fu==4

set seed 124
gen z_a1_95=avg_z_hyp_a1_fu
gen random1=uniform()
egen rank2=rank(random1) if assign_ent==0 & assign_man==0 & avg_z_hyp_a1_fu==., by(assign_group fu) unique
replace z_a1_95=high95 if (assign_ent==0 & assign_man==0) & ((fu==1 & rank2<=11)|(fu==2 & rank2<=15)|(fu==3 & rank2<=16)|(fu==4 & rank2<=14))

xi: areg z_a1_95 assign_man assign_ent avg_z_hyp_a1_bl avg_z_hyp_a1_miss_bl i.fu, a(strata) cluster(id_ent) robust
eststo robust_3

gen z_a1_90=avg_z_hyp_a1_fu
replace z_a1_90=high90 if (assign_ent==0 & assign_man==0) & ((fu==1 & rank2<=11)|(fu==2 & rank2<=15)|(fu==3 & rank2<=16)|(fu==4 & rank2<=14))
xi: areg z_a1_90 assign_man assign_ent avg_z_hyp_a1_bl avg_z_hyp_a1_miss_bl i.fu, a(strata) cluster(id_ent) robust
eststo robust_4

gen z_a1_75=avg_z_hyp_a1_fu
replace z_a1_75=high75 if (assign_ent==0 & assign_man==0) & ((fu==1 & rank2<=11)|(fu==2 & rank2<=15)|(fu==3 & rank2<=16)|(fu==4 & rank2<=14))
xi: areg z_a1_75 assign_man assign_ent avg_z_hyp_a1_bl avg_z_hyp_a1_miss_bl i.fu, a(strata) cluster(id_ent) robust
eststo robust_5


esttab robust_* using "$results\tablerobust.csv", replace depvar legend label nonumbers ///
	drop(_cons avg_z_hyp_a1_bl avg_z_hyp_a1_miss_bl _Ifu*) ///
	b(%9.3f) se star(* 0.10 ** 0.05 *** 0.01) nogaps ///
	stats(N, fmt(%9.0f) labels("Sample Size")) ///
	title("Table S6: Robustness of Primary Outcomes to Differential Attrition") addnotes("""") 

* Panel B: Monthly Profits
replace mo_profits_bl_win=0 if mo_profits_bl_win==. & mo_profits_bl_miss==1
eststo clear
xi: areg mo_profits_win_fu assign_man assign_ent mo_profits_bl_win mo_profits_bl_miss i.fu, a(strata) cluster(id_ent) robust
eststo robust_1

set seed 124
gen profits_top=mo_profits_win_fu
egen rank1b1p = rank(-profits_top), by(assign_group fu) unique

* Assume all extra attritors were from top of distribution
replace profits_top=. if assign_man==1 & ((fu==1 & rank1b1p<=8)|(fu==2 & rank1b1p<=21)|(fu==3 & rank1b1p<=16)|(fu==4 & rank1b1p<=4))
replace profits_top=. if assign_ent==1 & ((fu==1 & rank1b1p<=11)|(fu==2 & rank1b1p<=15)|(fu==3 & rank1b1p<=16)|(fu==4 & rank1b1p<=14))

xi: areg profits_top assign_man assign_ent mo_profits_bl_win mo_profits_bl_miss i.fu, a(strata) cluster(id_ent) robust
eststo robust_2

cap drop high95 high90 high75 high50
sum mo_profits_win_fu if assign_ent==1 & fu==1, de
gen high95=r(p95)
gen high90=r(p90)
gen high75=r(p75)
gen high50=r(p50)
sum mo_profits_win_fu if assign_ent==1 & fu==2, de
replace high95=r(p95) if fu==2 
replace high90=r(p90) if fu==2
replace high75=r(p75) if fu==2
replace high50=r(p50) if fu==2
sum mo_profits_win_fu if assign_ent==1 & fu==3, de
replace high95=r(p95) if fu==3 
replace high90=r(p90) if fu==3
replace high75=r(p75) if fu==3
replace high50=r(p50) if fu==3
sum mo_profits_win_fu if assign_ent==1 & fu==4, de
replace high95=r(p95) if fu==4 
replace high90=r(p90) if fu==4
replace high75=r(p75) if fu==4
replace high50=r(p50) if fu==4

set seed 124
gen profits_95=mo_profits_win_fu
replace profits_95=high95 if (assign_ent==0 & assign_man==0) & ((fu==1 & rank2<=11)|(fu==2 & rank2<=15)|(fu==3 & rank2<=16)|(fu==4 & rank2<=14))

xi: areg profits_95 assign_man assign_ent mo_profits_bl_win mo_profits_bl_miss i.fu, a(strata) cluster(id_ent) robust
eststo robust_3

gen profits_90=mo_profits_win_fu
replace profits_90=high90 if (assign_ent==0 & assign_man==0) & ((fu==1 & rank2<=11)|(fu==2 & rank2<=15)|(fu==3 & rank2<=16)|(fu==4 & rank2<=14))
xi: areg profits_90 assign_man assign_ent mo_profits_bl_win mo_profits_bl_miss i.fu, a(strata) cluster(id_ent) robust
eststo robust_4

gen profits_75=mo_profits_win_fu
replace profits_75=high75 if (assign_ent==0 & assign_man==0) & ((fu==1 & rank2<=11)|(fu==2 & rank2<=15)|(fu==3 & rank2<=16)|(fu==4 & rank2<=14))
xi: areg profits_75 assign_man assign_ent mo_profits_bl_win mo_profits_bl_miss i.fu, a(strata) cluster(id_ent) robust
eststo robust_5

esttab robust_* using "$results\tablerobustB.csv", replace depvar legend label nonumbers ///
	drop(_cons mo_profits_bl_win mo_profits_bl_miss _Ifu*) ///
	b(%9.0f) se star(* 0.10 ** 0.05 *** 0.01) nogaps ///
	stats(N, fmt(%9.0f) labels("Sample Size")) ///
	title("Table S6: Robustness of Primary Outcomes to Differential Attrition") addnotes("""") 

************************************************************************
** Table S7: Robustness of Primary Outcomes to Other Specifications **
************************************************************************

clear
clear matrix
clear mata
set maxvar 10000
use "$Master_final", clear

** Rename sales variables **
forval i=1/4 {
	ren fu`i'_sales_lm fu`i'_mo_sales
	ren ihs_fu`i'_sales_lm fu`i'_mo_sales_ihs
	ren win_fu`i'_sales_lm fu`i'_mo_sales_win
	ren win_fu`i'_sales_lw fu`i'_week_sales_win	
	ren fu`i'_profits_lm fu`i'_mo_profits
	ren win_fu`i'_profits_lm fu`i'_mo_profits_win
	ren win_fu`i'_profits_lw fu`i'_week_profits_win
	ren ihs_fu`i'_profits_lm fu`i'_mo_profits_ihs
	ren win_fu`i'_total_profits total_profits_win_fu`i'
	}
ren win_bl_sales_lm bl_mo_sales_win
ren win_bl_profits_lm bl_mo_profits_win
ren bl_profits_lm_miss bl_mo_profits_miss
ren win_bl_profits_lw bl_week_profits_win
ren bl_profits_lw_miss bl_week_profits_miss
ren bl_sales_lm bl_mo_sales
ren bl_sales_lm_miss bl_mo_sales_miss
ren ihs_bl_sales_lm bl_mo_sales_ihs
ren win_bl_sales_lw bl_week_sales_win
ren bl_sales_lw_miss bl_week_sales_miss
ren bl_profits_lm bl_mo_profits
ren ihs_bl_profits_lm bl_mo_profits_ihs
ren win_bl_total_profits total_profits_win_bl

** Overall **
ren fu4_* *_fu4
ren fu3_* *_fu3
ren fu2_* *_fu2
ren fu1_* *_fu1
ren bl_* *_bl

ren win_fu4_* *_win_fu4
ren win_fu3_* *_win_fu3
ren win_fu2_* *_win_fu2
ren win_fu1_* *_win_fu1

** Reshape **
keep id_ent assign_man assign_ent assign_group avg_z_hyp_a1* mo_* week_* total_profits_* female strata has_business_* ///
	PI_* z_fu* z_PI*
	
reshape long mo_sales_fu mo_sales_ihs_fu week_sales_win_fu mo_profits_fu mo_profits_ihs_fu total_profits_win_fu ///
	has_business_fu mo_sales_win_fu mo_profits_win_fu week_profits_win_fu avg_z_hyp_a1_fu PI_fu, i(id_ent) j(fu)

** Monthly sales **
xi: areg mo_sales_fu assign_man assign_ent mo_sales_bl mo_sales_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Monthly_sales
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum mo_sales_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)
	estadd scalar control_med = r(p50)

** Monthly sales, ihs **
replace mo_sales_ihs_bl=0 if mo_sales_ihs_bl==. & mo_sales_miss_bl==1
xi: areg mo_sales_ihs_fu assign_man assign_ent mo_sales_ihs_bl mo_sales_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Monthly_sales_IHS
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum mo_sales_ihs_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)	
	estadd scalar control_med = r(p50)

*** Log sales + 1
cap drop logsalesplusone_fu bl_logsalesplusone
gen logsalesplusone_fu=ln(mo_sales_fu+1)
gen bl_logsalesplusone=ln(mo_sales_bl+1)

xi: areg logsalesplusone_fu assign_man assign_ent bl_logsalesplusone mo_sales_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Monthly_sales_logplusone
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum logsalesplusone_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)
	estadd scalar control_med = r(p50)

** Weekly sales, winsorized **
replace week_sales_win_bl=0 if week_sales_win_bl==. & week_sales_miss_bl==1
xi: areg week_sales_win_fu assign_man assign_ent week_sales_win_bl week_sales_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Weekly_sales_winsorized
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum week_sales_win_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)	
	estadd scalar control_med = r(p50)

** Monthly profits **
xi: areg mo_profits_fu assign_man assign_ent mo_profits_bl mo_profits_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Monthly_profits
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum mo_profits_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)
	estadd scalar control_med = r(p50)

** Monthly profits, IHS **
xi: areg mo_profits_ihs_fu assign_man assign_ent mo_profits_ihs_bl mo_profits_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Monthly_profits_IHS
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum mo_profits_ihs_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)	
	estadd scalar control_med = r(p50)

*** Log profits + 1
cap drop logprofitsplusone_fu bl_logprofitsplusone
gen logprofitsplusone_fu=ln(mo_profits_fu+1)
gen bl_logprofitsplusone=ln(mo_profits_bl+1)

xi: areg logprofitsplusone_fu assign_man assign_ent bl_logprofitsplusone mo_profits_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Monthly_profits_logplusone
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum logprofitsplusone_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)
	estadd scalar control_med = r(p50)

** Total profits **
xi: areg total_profits_win_fu assign_man assign_ent total_profits_win_bl total_profits_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Total_profits_winsorized
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum total_profits_win_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)	
	estadd scalar control_med = r(p50)
	
** Export results **
estout Monthly_sales Monthly_sales_IHS Monthly_sales_logplusone Weekly_sales_winsorized Monthly_profits Monthly_profits_IHS ///
	Monthly_profits_logplusone Total_profits_winsorized using "$results\Table_S7_`sysdate'.txt", replace cells(b(fmt(%12.4fc)star) ///
	se(par fmt(%12.4fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent ///
	Entrepreneurial) stats(N p_joint_significance p_man_ent control_med control_mean, fmt(0 %12.4fc %12.4fc )) ///
	title("Table S6: Robustness of Primary Outcomes on other specifications")

******************************************************
** Table S8: Impact on Primary Outcomes by Gender **
******************************************************
estimates clear

** Create variables for gender heterogeneity **
foreach var in assign_man assign_ent {
	gen fem_`var' = female * `var'
	}
foreach var in mo_sales_win_bl mo_profits_win_bl week_profits_win_bl avg_z_hyp_a1_bl {
	gen fem_`var' = female * `var'
	}

** Survival **
xi: areg has_business_fu assign_man fem_assign_man assign_ent fem_assign_ent female i.fu, a(strata) cluster(id_ent) robust
	estimates store Survival
	test assign_man=assign_ent
	estadd scalar p_male = r(p)
	test (assign_man+fem_assign_man)=(assign_ent+fem_assign_ent)
	estadd scalar p_fem = r(p)
	sum has_business_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	sum has_business_fu if assign_group==3 & female==1
	estadd scalar control_fem = r(mean) 
	sum has_business_fu if assign_group==3 & female==0
	estadd scalar control_male = r(mean)

	
** Monthly sales, winsorized **
xi: areg mo_sales_win_fu assign_man fem_assign_man assign_ent fem_assign_ent female mo_sales_win_bl fem_mo_sales_win_bl mo_sales_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Monthly_sales_winsorized
	test assign_man=assign_ent
	estadd scalar p_male = r(p)
	test (assign_man+fem_assign_man)=(assign_ent+fem_assign_ent)
	estadd scalar p_fem = r(p)
	sum mo_sales_win_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	sum mo_sales_win_fu if assign_group==3 & female==1
	estadd scalar control_fem = r(mean) 
	sum mo_sales_win_fu if assign_group==3 & female==0
	estadd scalar control_male = r(mean)

** Monthly profits, winsorized **
xi: areg mo_profits_win_fu assign_man fem_assign_man assign_ent fem_assign_ent female mo_profits_win_bl fem_mo_profits_win_bl mo_profits_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Monthly_profits_winsorized
	test assign_man=assign_ent
	estadd scalar p_male = r(p)
	test (assign_man+fem_assign_man)=(assign_ent+fem_assign_ent)
	estadd scalar p_fem = r(p)
	sum mo_profits_win_fu if assign_group==3
	estadd scalar control_mean = r(mean)	
	sum mo_profits_win_fu if assign_group==3 & female==1
	estadd scalar control_fem = r(mean) 
	sum mo_profits_win_fu if assign_group==3 & female==0
	estadd scalar control_male = r(mean)

** Weekly profits **
xi: areg week_profits_win_fu assign_man fem_assign_man assign_ent fem_assign_ent female week_profits_win_bl fem_week_profits_win_bl week_profits_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Weekly_profits_winsorized
	test assign_man=assign_ent
	estadd scalar p_male = r(p)
	test (assign_man+fem_assign_man)=(assign_ent+fem_assign_ent)
	estadd scalar p_fem = r(p)
	sum week_profits_win_fu if assign_group==3
	estadd scalar control_mean = r(mean)	
	sum week_profits_win_fu if assign_group==3 & female==1
	estadd scalar control_fem = r(mean) 
	sum week_profits_win_fu if assign_group==3 & female==0
	estadd scalar control_male = r(mean)

** Standardized z-score **
replace avg_z_hyp_a1_bl=0 if avg_z_hyp_a1_bl==. & avg_z_hyp_a1_miss_bl==1
xi: areg avg_z_hyp_a1_fu assign_man fem_assign_man assign_ent fem_assign_ent female avg_z_hyp_a1_bl fem_avg_z_hyp_a1_bl avg_z_hyp_a1_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store A1_zscore
	test assign_man=assign_ent
	estadd scalar p_male = r(p)
	test (assign_man+fem_assign_man)=(assign_ent+fem_assign_ent)
	estadd scalar p_fem = r(p)
	sum avg_z_hyp_a1_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	sum avg_z_hyp_a1_fu if assign_group==3 & female==1
	estadd scalar control_fem = r(mean) 
	sum avg_z_hyp_a1_fu if assign_group==3 & female==0
	estadd scalar control_male = r(mean)

** Export results **
estout Survival Monthly_sales_winsorized Monthly_profits_winsorized Weekly_profits_winsorized A1_zscore using ///
	"$results\Table_S8_`sysdate'.txt", replace cells(b(fmt(%12.3fc)star) se(par fmt(%12.3fc))) ///
	starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial fem_assign_man Managerial_X_fem ///
	assign_ent Entrepreneurial fem_assign_ent Entrepreneurial_X_fem) stats(N p_fem p_male control_mean ///
	control_fem control_male, fmt(0 %12.4fc %12.4fc %12.4fc %12.2fc %12.2fc %12.2fc)) ///
	title("Table S8")

*******************************************************************
** Table S9: Robustness to Other Measures of Personal Initiative **
*******************************************************************
clear
clear matrix
clear mata
set maxvar 10000
use "$Master_final", clear

*** Rename variables ***
* Personal initiative behavior -quantitative *
ren fu1_pi_quant_p4q10 PI_quant_fu1
ren fu2_pi_quant_p4q14 PI_quant_fu2
ren fu3_pi_quant_p4q15 PI_quant_fu3

* Personal initiative behavior - qualitative
ren fu1_pi_qual_p4q10 PI_qual_fu1
ren fu2_pi_qual_p4q14 PI_qual_fu2
ren fu3_pi_qual_p4q15 PI_qual_fu3

reshape long PI_fu PI_quant_fu PI_qual_fu z_PI_beh_wb_fu , i(id_ent) j(fu)

*** PI scale ***
	xi: areg PI_fu assign_man assign_ent PI_bl PI_bl_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store PI_all
	test
	estadd scalar p_joint_significance = r(p)
	sum PI_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)
	
*** Personal initiative - behavior ***

*** quantitative
xi: areg PI_quant_fu assign_man assign_ent PI_bl PI_bl_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store PI_beh_quant_all
	test
	estadd scalar p_joint_significance = r(p)
	sum PI_quant_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)
	
*** qualitative
xi: areg PI_qual_fu assign_man assign_ent PI_bl PI_bl_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store PI_beh_qual_all
	test
	estadd scalar p_joint_significance = r(p)
	sum PI_qual_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)

	
*** combined z-score
xi: areg z_PI_beh_wb_fu assign_man assign_ent PI_bl PI_bl_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store z_PI_beh_wb_all
	test
	estadd scalar p_joint_significance = r(p)
	sum z_PI_beh_wb_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)
	
** Export results **
estout PI_beh_quant_all PI_beh_qual_all z_PI_beh_wb_all using "$results\Table_S9_`sysdate'.txt", replace ///
	cells(b(fmt(%12.3fc)star) se(par fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man ///
	Managerial assign_ent Entrepreneurial) stats(N p_joint_significance p_man_ent control_mean, fmt(0 %12.4fc %12.4fc %12.4fc %12.2fc %12.2fc)) ///
	title("Table S9")

******************************************************************************
** Table S10: Personal Initiative Training endurance on Personal Initiative **
******************************************************************************
clear
clear matrix
clear mata
set maxvar 10000
use "$Master_final"

*** Personal initiative - scale ***
*fu1
areg PI_fu1 assign_man assign_ent PI_bl PI_bl_miss, a (strata) robust
estimates store PI_fu1
test
estadd scalar p_joint_significance = r(p)
sum PI_fu1 if assign_group==3
estadd scalar control_mean = r(mean)

test assign_man=assign_ent
estadd scalar F_value=r(F)
estadd scalar p_man_ent=r(p)

*fu2
areg PI_fu2 assign_man assign_ent PI_bl PI_bl_miss, a (strata) robust
estimates store PI_fu2
test
estadd scalar p_joint_significance = r(p)
sum PI_fu2 if assign_group==3
estadd scalar control_mean = r(mean)

test assign_man=assign_ent
estadd scalar F_value=r(F)
estadd scalar p_man_ent=r(p)

*fu3
areg PI_fu3 assign_man assign_ent PI_bl PI_bl_miss, a (strata) robust
estimates store PI_fu3
test
estadd scalar p_joint_significance = r(p)
sum PI_fu3 if assign_group==3
estadd scalar control_mean = r(mean)

test assign_man=assign_ent
estadd scalar F_value=r(F)
estadd scalar p_man_ent=r(p)

*fu4
replace PI_bl=0 if PI_bl==. & PI_bl_miss==1 /***zero changes***/
areg PI_fu4 assign_man assign_ent PI_bl PI_bl_miss, a (strata) robust
estimates store PI_fu4
test
estadd scalar p_joint_significance = r(p)
sum PI_fu4 if assign_group==3
estadd scalar control_mean = r(mean)

test assign_man=assign_ent
estadd scalar F_value=r(F)
estadd scalar p_man_ent=r(p)

estout PI_fu1 PI_fu2 PI_fu3 PI_fu4 using "$results\Regressions Results PI scale table S10.txt", replace ///
cells(b(fmt(%6.3fc)star) se(par(`"="("'`")""') fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneurial) ///
stats(N p_man_ent p_joint_significance control_mean, fmt(0 %12.3fc %12.3fc %12.3fc)) title("PERSONAL INITIATIVE SCALE")

******************************************************************************************************
** Table S11: Impact on the Big Five Personality Traits, Risk Attitude, and Entrepreneurial Passion **
******************************************************************************************************
clear
clear matrix
clear mata
set maxvar 10000
use "$Master_final"



********* Big Five Regressions *********

*Extraversion fu3
areg EXT_fu3 assign_man assign_ent, a (strata) robust
estimates store EXT_fu3
test
estadd scalar p_joint_significance = r(p)
sum EXT_fu3 if assign_group==3
estadd scalar control_mean = r(mean)

test assign_man=assign_ent
estadd scalar F_value=r(F)
estadd scalar p_man_ent=r(p)

*Agreeableness fu3
areg AGR_fu3 assign_man assign_ent, a (strata) robust
estimates store AGR_fu3
test
estadd scalar p_joint_significance = r(p)
sum AGR_fu3 if assign_group==3
estadd scalar control_mean = r(mean)

test assign_man=assign_ent
estadd scalar F_value=r(F)
estadd scalar p_man_ent=r(p)

*Neuroticism fu3
areg NEU_fu3 assign_man assign_ent, a (strata) robust
estimates store NEU_fu3
test
estadd scalar p_joint_significance = r(p)
sum NEU_fu3 if assign_group==3
estadd scalar control_mean = r(mean)

test assign_man=assign_ent
estadd scalar F_value=r(F)
estadd scalar p_man_ent=r(p)

*Conscientiousness fu3
areg CON_fu3 assign_man assign_ent, a (strata) robust
estimates store CON_fu3
test
estadd scalar p_joint_significance = r(p)
sum CON_fu3 if assign_group==3
estadd scalar control_mean = r(mean)

test assign_man=assign_ent
estadd scalar F_value=r(F)
estadd scalar p_man_ent=r(p)

*Openness fu3
areg OPEN_fu3 assign_man assign_ent, a (strata) robust
estimates store OPEN_fu3
test
estadd scalar p_joint_significance = r(p)
sum OPEN_fu3 if assign_group==3
estadd scalar control_mean = r(mean)

test assign_man=assign_ent
estadd scalar F_value=r(F)
estadd scalar p_man_ent=r(p)

reshape long PFE_fu RT_fu, i(id_ent) j(fu)

*** Passion for entrepreneurship ***
xi: areg PFE_fu assign_man assign_ent PFE_bl PFE_bl_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store PFE_all
	test
	estadd scalar p_joint_significance = r(p)
	sum PFE_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)
	
	
*** Risk taking ***
xi: areg RT_fu assign_man assign_ent RT_bl RT_bl_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store RT_all
	test
	estadd scalar p_joint_significance = r(p)
	sum RT_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)


#delimit;
estout EXT_fu3 AGR_fu3 NEU_fu3 CON_fu3 OPEN_fu3 RT_all PFE_all using "$results\Table S11_`sysdate'.txt", replace
cells(b(fmt(%6.3fc)star) se(par(`"="("'`")""') fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneurial)
stats(N p_man_ent p_joint_significance control_mean, fmt(0 %12.3fc %12.3fc)) title("Table S11: Impact on the Big Five Personality Traits, Risk Attitude, and Entrepreneurial Passion");

#delimit cr


*************************************************************************
** Table S12: Impacts on Subcomponents of the Business Practices Index **
*************************************************************************

clear
clear mata
clear matrix
set maxvar 10000
use "$Master_final", clear

** Rename Hypothesis B1 **
ren win_fu4_own_labor owner_worked_win_fu4
ren win_fu3_own_labor owner_worked_win_fu3
ren win_fu2_own_labor owner_worked_win_fu2
ren win_fu1_own_labor owner_worked_win_fu1
ren fu4_no_workers fu4_n_workers
ren fu3_no_workers fu3_n_workers
ren fu2_no_workers fu2_n_workers
ren fu1_no_workers fu1_n_workers
ren bl_no_workers bl_n_workers
ren bl_no_workers_miss bl_n_workers_miss

ren win_fu4_k_stock k_stock_win_fu4
ren win_fu3_k_stock k_stock_win_fu3
ren win_fu2_k_stock k_stock_win_fu2
ren win_bl_k_stock k_stock_win_bl
ren bl_k_stock_miss k_stock_miss_bl
ren win_fu4_k_invest k_invest_win_fu4
ren win_fu3_k_invest k_invest_win_fu3
ren win_fu2_k_invest k_invest_win_fu2
ren win_bl_k_invest k_invest_win_bl
ren bl_k_invest_miss k_invest_miss_bl
ren win_fu4_stock_value fu4_inventory_win
ren win_fu3_stock_value fu3_inventory_win
ren win_fu2_stock_value fu2_inventory_win
ren win_fu1_stock_value fu1_inventory_win
ren win_bl_stock_value bl_inventory_win 
ren bl_stock_value_miss bl_inventory_miss
ren fu4_avg_z_hyp_b1 avg_z_hyp_b1_fu4
ren fu3_avg_z_hyp_b1 avg_z_hyp_b1_fu3 
ren fu2_avg_z_hyp_b1 avg_z_hyp_b1_fu2
ren fu1_avg_z_hyp_b1 avg_z_hyp_b1_fu1 
ren bl_avg_z_hyp_b1 avg_z_hyp_b1_bl 
ren bl_avg_z_hyp_b1_miss avg_z_hyp_b1_miss_bl

** C hypothesis variables **
ren bl_avg_z_hyp_cs4a avg_z_hyp_cs4a_bl
ren bl_process_innovation process_innovation_bl
ren bl_new_products new_products_bl 
ren bl_new_products_miss new_products_miss_bl
ren bl_new_line new_line_bl
ren bl_own_inspired own_inspired_bl
ren bl_avg_z_hyp_cs4c avg_z_hyp_cs4c_bl
ren bl_amount_borrow amount_borrow_bl
ren bl_amount_borrow_miss amount_borrow_miss_bl
ren bl_loan_bank loan_bank_bl
ren bl_tot_recent_loans tot_recent_loans_bl
ren bl_tot_recent_loans_miss tot_recent_loans_miss_bl
ren bl_has_account has_account_bl
ren bl_has_account_miss has_account_miss_bl
ren bl_has_buss_bank has_buss_bank_bl
ren bl_has_buss_bank_miss has_buss_bank_miss_bl
ren bl_avg_z_hyp_cs4e avg_z_hyp_cs4e_bl
ren bl_discuss_ideas discuss_ideas_bl 
ren bl_discuss_ideas_miss discuss_ideas_miss_bl
ren bl_discuss_entrep discuss_entrep_bl
ren bl_discuss_entrep_miss discuss_entrep_miss_bl

** Overall **
ren fu4_* *_fu4
ren fu3_* *_fu3
ren fu2_* *_fu2
ren fu1_* *_fu1
ren bl_* *_bl

ren win_fu4_* *_win_fu4
ren win_fu3_* *_win_fu3
ren win_fu2_* *_win_fu2
ren win_fu1_* *_win_fu1

** Reshape **
keep id_ent assign_man assign_ent assign_group avg_z_hyp_a1* female strata avg_z_hyp_b1* owner_worked_win* n_workers* ///
	paid_workers* stipend_workers* unpaid_workers* hours_open* inventory* k_stock* ///
	k_invest* big_invest* has_business_* business_practice* marketing* record_index* operations* information* hr_index* ///
	interviewed_* autonomy_women* exp_sexual* loan_bank* ///
	hrs_not_care* women_influence* decision_making* sexual_harassment* avg_z_hyp_b5* avg_z_hyp_cs4a* ///
	process* new_products* num_new_products* new_line* own_inspired* neighborhood_* num_ideas* innovation* avg_z_hyp_cs4b* ///
	pri_sector_change* sec_sector_change* avg_z_hyp_cs4c* amount_borrow* loan_bank* tot_recent_loans* ///
	has_account* has_buss_bank* avg_z_hyp_cs4e* discuss_ideas* discuss_entrep* meets_entrep* ///
	total_annual_freq* entrep_network* registered* money_networks* supp_networks* ///
	cust_networks* tools_networks* stocks_networks* changes_networks* ///
	asks_customers* asks_satisfaction* offers_promotions* changes_presentation* one_publicity* asks_notback* ///
	keeps_acc_books* all_acc_books* written_budget* budget_monthly* budget_yearly* no_mix_money* registers_all* ///
	solvable_bank* sales_objectives* real_vs_objectives* negotiate_suppliers* sufficient_stock* inventory_stock* ///
	analyzes_trends* analyzes_performance* calculates_costs* calculates_benefit* knows_most_profit* visit_competitors* ///
	evaluates_need* new_market* new_clients* compares_quality* discuss_ideas* more_capital* read_sector* discuss_entrep* ///
	meets_entrep* sells_sector* written_contract* training_external* training_internal* evaluates_employee* ///
	provides_feedback* two_publicity* receipts_system* keeps_receipts* has_* self_salary* new_techniques* money_acc*
	
reshape long avg_z_hyp_a1_fu mo_profits_fu mo_profits_win_fu mo_profits_ihs_fu week_profits_win_fu mo_sales_fu ///
	mo_sales_win_fu mo_sales_ihs_fu week_sales_win_fu total_profits_fu total_profits_win_fu avg_z_b2_index_fu b2_index_fu ///
	business_practice_fu increased_use_index_fu marketing_index_fu record_index_fu operations_index_fu information_index_fu ///
	hr_index_fu marketing_incr_index_fu operations_incr_index_fu information_incr_index_fu avg_z_hyp_b1_fu avg_z_hyp_b1_k_fu ///
	owner_worked_win_fu n_workers_fu paid_workers_fu stipend_workers_fu unpaid_workers_fu hours_open_fu inventory_win_fu ///
	k_stock_win_fu k_invest_win_fu big_invest_fu has_business_fu autonomy_women_fu exp_sexual_harassment_fu ///
	total_income_win_fu avg_z_hyp_b3_fu hrs_not_care_fu women_influence_fu decision_making_fu sexual_harassment_fu ///
	avg_z_hyp_b5_fu avg_z_hyp_cs4a_fu process_innovation_fu new_products_fu num_new_products_fu new_line_fu own_inspired_fu ///
	num_ideas_fu innovation_fu avg_z_hyp_cs4b_fu pri_sector_change_fu sec_sector_change_fu avg_z_hyp_cs4c_fu amount_borrow_fu ///
	one_loan_fu loan_bank_fu tot_recent_loans_fu has_account_fu has_buss_bank_fu avg_z_hyp_cs4e_fu avg_z_benefits_cs4e_fu ///
	discuss_ideas_fu discuss_entrep_fu meets_entrep_fu total_annual_freq_fu entrep_network_fu risk_game_fu registered_fu ///
	money_networks_fu supp_networks_fu cust_networks_fu tools_networks_fu stocks_networks_fu changes_networks_fu ///
	neighborhood_new_fu f_avg_z_hyp_b1_fu f_avg_z_hyp_b1_k_fu f_z_b2_index_fu asks_customers_fu asks_satisfaction_fu ///
	offers_promotions_fu changes_presentation_fu one_publicity_fu asks_notback_fu keeps_acc_books_fu all_acc_books_fu ///
	written_budget_fu budget_monthly_fu budget_yearly_fu no_mix_money_fu registers_all_fu solvable_bank_fu sales_objectives_fu ///
	real_vs_objectives_fu negotiate_suppliers_fu sufficient_stock_fu inventory_stock_fu analyzes_trends_fu ///
	analyzes_performance_fu calculates_costs_fu calculates_benefit_fu knows_most_profit_fu visit_competitors_fu ///
	evaluates_need_fu new_market_fu new_clients_fu compares_quality_fu more_capital_fu read_sector_fu sells_sector_fu ///
	written_contract_fu training_external_fu training_internal_fu evaluates_employee_fu provides_feedback_fu two_publicity_fu ///
	receipts_system_fu keeps_receipts_fu self_salary_fu new_techniques_fu money_acc_fu, i(id_ent) j(fu)

** Impact on marketing index **
xi: areg marketing_index_fu assign_man assign_ent marketing_index_bl marketing_index_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Marketing
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum marketing_index_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)
	estadd scalar control_med = r(p50)

** Impact on record keeping index **
replace record_index_bl=0 if record_index_bl==. & record_index_miss_bl==1 /*no missing values at baseline*/
xi: areg record_index_fu assign_man assign_ent record_index_bl record_index_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Record_keeping
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum record_index_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)
	estadd scalar control_med = r(p50)

** Impact on operations and performance management index **
xi: areg operations_index_fu assign_man assign_ent operations_index_bl operations_index_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Operations_management
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum operations_index_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)	
	estadd scalar control_med = r(p50)

** Impact on information seeking index **
xi: areg information_index_fu assign_man assign_ent information_index_bl information_index_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Information_seeking
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum information_index_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)
	estadd scalar control_med = r(p50)

** Impact on HR index **
xi: areg hr_index_fu assign_man assign_ent i.fu, a(strata) cluster(id_ent) robust
	estimates store HR_management
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum hr_index_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)	
	estadd scalar control_med = r(p50)

** Export Results **
estout Marketing Record_keeping Operations_management Information_seeking HR_management using ///
	"$results\Table_12_`sysdate'.txt", replace cells(b(fmt(%6.3fc)star) se(par fmt(%6.3fc))) drop(_cons) ///
	starlevels(* .1 ** .05 *** .01) legend varlabels(assign_man Managerial assign_ent Entrepreneurial business_practice_bl ///
	Business_BL marketing_index_bl Marketing_BL record_index_bl Record_BL operations_index_bl Operations_BL ///
	information_index_bl Information_BL) stats(N p_joint_significance p_man_ent control_med control_mean, ///
	fmt(0 %12.4fc %12.4fc %12.2fc %12.2fc)) title("B2: Business practice indexes")

**********************************************************************
** Table S13: Further Detail on Impacts on Capital and Labor Inputs **
**********************************************************************
estimates clear

** Capital and Labour Inputs **
xi: areg avg_z_hyp_b1_fu assign_man assign_ent avg_z_hyp_b1_bl avg_z_hyp_b1_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store B1_zscore
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum avg_z_hyp_b1_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)
	estadd scalar control_med = r(p50)

** Owner's worked Hours **Not asked at baseline**
xi: areg owner_worked_win_fu assign_man assign_ent i.fu, a(strata) cluster(id_ent) robust
	estimates store Hours_owner_worked
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum owner_worked_win_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)	
	estadd scalar control_med = r(p50)

** Number of workers **
replace n_workers_bl=0 if n_workers_bl==. & n_workers_miss_bl==1
xi: areg n_workers_fu assign_man assign_ent n_workers_bl n_workers_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Number_workers
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum n_workers_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)	
	estadd scalar control_med = r(p50)

** Number of paid workers **Not asked at baseline**
xi: areg paid_workers_fu assign_man assign_ent i.fu, a(strata) cluster(id_ent) robust
	estimates store Number_paid_workers
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum paid_workers_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)	
	estadd scalar control_med = r(p50)

** Operating Hours **
xi: areg hours_open_fu assign_man assign_ent hours_open_bl hours_open_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Hours_business_open
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum hours_open_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)
	estadd scalar control_med = r(p50)

** Business Assets **
replace k_stock_win_bl=0 if k_stock_win_bl==. & k_stock_miss_bl==1
xi: areg k_stock_win_fu assign_man assign_ent k_stock_win_bl k_stock_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Assets
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum k_stock_win_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)	
	estadd scalar control_med = r(p50)
	
** Investments Made **
replace k_invest_win_bl=0 if k_invest_win_bl==. & k_invest_miss_bl==1
xi: areg k_invest_win_fu assign_man assign_ent k_invest_win_bl k_invest_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Investment
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum k_invest_win_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)	
	estadd scalar control_med = r(p50)

** Inventory levels **
replace inventory_win_bl=0 if inventory_win_bl==. & inventory_miss_bl==1
xi: areg inventory_win_fu assign_man assign_ent inventory_win_bl inventory_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Inventory
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum inventory_win_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)
	estadd scalar control_med = r(p50)

** Major Investment **
replace big_invest_miss_bl=k_invest_miss_bl
xi: areg big_invest_fu assign_man assign_ent big_invest_bl big_invest_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store Big_investment
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum big_invest_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)		
	estadd scalar control_med = r(p50)

** Export Results **
estout B1_zscore Hours_owner_worked Number_workers Number_paid_workers Hours_business_open Assets Investment Inventory ///
	Big_investment using "$results\Table_13_`sysdate'.txt", replace ///
	cells(b(fmt(%12.3fc)star) se(par fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) ///
	legend varlabels(assign_man Managerial assign_ent Entrepreneurial) stats(N p_joint_significance p_man_ent ///
	control_med control_mean, fmt(0 %12.4fc %12.4fc %12.2fc %12.2fc)) title("Impact on capital and labor inputs")

*******************************************************
** Table S14: Further Detail on Innovation Responses **
*******************************************************
estimates clear

** Innovation Index **
xi:	areg avg_z_hyp_cs4a_fu assign_man assign_ent avg_z_hyp_cs4a_bl avg_z_hyp_cs4a_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store z_cs4a
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	sum avg_z_hyp_cs4a_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)
	
** Introduced new products or services **
xi: areg new_products_fu assign_man assign_ent new_products_bl new_products_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store new
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	sum new_products_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)

** Number of new products or services **
/***not asked at baseline***/
xi: areg num_new_products_fu assign_man assign_ent i.fu, a(strata) cluster(id_ent) robust
	estimates store number_new
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	sum num_new_products_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)

** Process innovation **
xi: areg process_innovation_fu assign_man assign_ent process_innovation_bl process_innovation_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store process
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	sum process_innovation_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)

** New product line **
xi: areg new_line_fu assign_man assign_ent new_line_bl new_line_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store new_line
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	sum new_line_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)

** Main new product/service inspired by entrepreneurs own idea **
replace own_inspired_bl=0 if own_inspired_bl==. & own_inspired_miss_bl==1
xi: areg own_inspired_fu assign_man assign_ent own_inspired_bl own_inspired_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store inspired
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	sum own_inspired_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)

** Main new product was new to the neighborhood **
xi: areg neighborhood_new_fu assign_man assign_ent neighborhood_new_bl neighborhood_new_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store neighborhood
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	sum neighborhood_new_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)
	
** Quantitative Innovation **
xi: areg num_ideas_fu assign_man assign_ent, a (strata) cluster(id_ent) robust
	estimates store num_ideas
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	sum num_ideas_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)
	
** Qualitative Innovation ** 
xi: areg innovation_fu assign_man assign_ent, a (strata) cluster(id_ent) robust
	estimates store innovation
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	sum innovation_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)

xi:	areg pri_sector_change_fu assign_man assign_ent i.fu, a(strata) cluster(id_ent) robust
	estimates store pri_sector
	test assign_man=assign_ent	
	estadd scalar p_man_ent = r(p)
	sum pri_sector_change_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)

** Export results **
estout z_cs4a new number_new process new_line inspired neighborhood num_ideas innovation pri_sector using ///
	"$results\Table_14_`sysdate'.txt", replace cells(b(fmt(%12.9fc)star) se(par fmt(%12.3fc))) ///
	starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneuri) ///
	stats(N p_joint_significance p_man_ent control_med control_mean, fmt(0 %12.4fc %12.4fc %12.2fc %12.2fc)) title("Innovation")

***********************************************************************
** Table S15: Evidence on Other Pre-Specified Potential Mechanisms **
***********************************************************************

** Gender Attitudes **
xi: areg avg_z_hyp_b5_fu assign_man assign_ent avg_z_hyp_b5_bl avg_z_hyp_b5_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store zscore
	test assign_man=assign_ent
	estadd scalar p_man_ent = r(p)
	sum avg_z_hyp_b5_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)
	estadd scalar control_med = r(p50)

** Registered formally **
xi: areg registered_fu assign_man assign_ent registered_bl registered_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store registered
	test assign_man=assign_ent	
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum registered_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)
	estadd scalar control_med = r(p50)

** Networking **
xi: areg avg_z_hyp_cs4e_fu assign_man assign_ent avg_z_hyp_cs4e_bl avg_z_hyp_cs4e_miss_bl i.fu, a(strata) cluster(id_ent) robust
	estimates store z_cs4e
	test assign_man=assign_ent	
	estadd scalar p_man_ent = r(p)
	test
	estadd scalar p_joint_significance = r(p)
	sum avg_z_hyp_cs4e_fu if assign_group==3, d
	estadd scalar control_mean = r(mean)
	estadd scalar control_med = r(p50)

estout zscore registered z_cs4e using "$results\Table_15_`sysdate'.txt", replace ///
	cells(b(fmt(%12.9fc)star) se(par fmt(%12.3fc)))starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man ///
	Managerial assign_ent Entrepreneurial) stats(N p_joint_significance p_man_ent control_med control_mean, ///
	fmt(0 %12.4fc %12.2fc)) title("Table S15")

*******************************************
** Table S16: Mediation Analysis Results **
*******************************************
clear
clear mata
clear matrix
set maxvar 10000
use "$Master_final", clear
estimates clear



*Profits and sales index
ren fu1_avg_z_hyp_a1 avg_z_hyp_a1_fu1
ren fu2_avg_z_hyp_a1 avg_z_hyp_a1_fu2
ren fu3_avg_z_hyp_a1 avg_z_hyp_a1_fu3
ren fu4_avg_z_hyp_a1 avg_z_hyp_a1_fu4

*MVs
*Business practices
ren fu1_business_practice business_practice_fu1
ren fu2_business_practice business_practice_fu2
ren fu3_business_practice business_practice_fu3
ren fu4_business_practice business_practice_fu4

*PI - no need to rename

*Capital and labor inputs
ren fu1_avg_z_hyp_b1 avg_z_hyp_b1_fu1
ren fu2_avg_z_hyp_b1 avg_z_hyp_b1_fu2
ren fu3_avg_z_hyp_b1 avg_z_hyp_b1_fu3
ren fu4_avg_z_hyp_b1 avg_z_hyp_b1_fu4

*Innovation index
ren fu1_avg_z_hyp_cs4a avg_z_hyp_cs4a_fu1
ren fu2_avg_z_hyp_cs4a avg_z_hyp_cs4a_fu2
ren fu3_avg_z_hyp_cs4a avg_z_hyp_cs4a_fu3
ren fu4_avg_z_hyp_cs4a avg_z_hyp_cs4a_fu4

*Changed activity index
ren fu1_sec_sector_change sec_sector_change_fu1
ren fu2_sec_sector_change sec_sector_change_fu2
ren fu3_sec_sector_change sec_sector_change_fu3
ren fu4_sec_sector_change sec_sector_change_fu4

*Access to finance index
ren fu2_avg_z_hyp_cs4c avg_z_hyp_cs4c_fu2
ren fu3_avg_z_hyp_cs4c avg_z_hyp_cs4c_fu3
ren fu4_avg_z_hyp_cs4c avg_z_hyp_cs4c_fu4

reshape long avg_z_hyp_a1_fu business_practice_fu PI_fu avg_z_hyp_b1_fu avg_z_hyp_cs4a_fu sec_sector_change_fu avg_z_hyp_cs4c_fu , i(id_ent) j(fu)

drop if avg_z_hyp_a1_fu ==.

********************************************************************************
********************************************************************************
********************************************************************************
**** Regressions for mediation effects *****************************************
********************************************************************************
********************************************************************************
********************************************************************************

*** Controls are management training dummy, strata, and the DV and DV_miss at BL 

******************** DV: PROFITS AND SALES INDEX *******************************
************* MV: Business Practices *************
** Step 1: Regression analysis with IV predicting MV (a path)
xi: areg business_practice_fu assign_man assign_ent bl_avg_z_hyp_a1 bl_avg_z_hyp_a1_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store Business_Practices
	test
	estadd scalar p_joint_significance = r(p)
	sum business_practice_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)
	
// a coefficient: 0.0571327
//a SE = 0.0076578
display  0.0076578^2 // var(a)=0.00005864


#delimit;
estout Business_Practices using "$results\DV_Prof_Sales_Ind_MV_Bus_Prac_a.txt", replace
cells(b(fmt(%12.3fc)star) se(par(`"="("'`")""') fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneurial)
stats(N p_man_ent p_joint_significance control_mean , fmt(0 %12.3fc %12.3fc)) title("DV_Prof_Sales_Ind_MV_Bus_Prac_a");

#delimit cr

** Step 2: Regression analysis with IV and MV predicting DV (b path)
xi: areg avg_z_hyp_a1_fu  assign_man assign_ent business_practice_fu bl_avg_z_hyp_a1 bl_avg_z_hyp_a1_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store Profits_Sales_Index_1
	test
	estadd scalar p_joint_significance = r(p)
	sum avg_z_hyp_a1_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)

// b coefficient: 1.19982
//b SE = 0.0772053 
display 0.0772053^2 // var(b)= 0.00596066

#delimit;
estout Profits_Sales_Index_1 using "$results\DV_Prof_Sales_Ind_MV_Bus_Prac_b.txt", replace
cells(b(fmt(%12.3fc)star) se(par(`"="("'`")""') fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneurial)
stats(N p_man_ent p_joint_significance control_mean, fmt(0 %12.3fc  %12.3fc)) title("DV_Prof_Sales_Ind_MV_Bus_Prac_b");

#delimit cr

************* MV: Personal Initiative *************
** Step 1: Regression analysis with IV predicting MV (a path)
xi: areg PI_fu assign_man assign_ent bl_avg_z_hyp_a1 bl_avg_z_hyp_a1_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store Personal_Initiative
	test
	estadd scalar p_joint_significance = r(p)
	sum business_practice_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)
	
// a coefficient: 0.1204967
//a SE = 0.0156163
display 0.0156163^2 // var(a)= 0.00024387
	
#delimit;
estout Personal_Initiative using "$results\DV_Prof_Sales_Ind_MV_PI_a.txt", replace
cells(b(fmt(%12.3fc)star) se(par(`"="("'`")""') fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneurial)
stats(N p_man_ent p_joint_significance control_mean, fmt(0 %12.3fc %12.3fc)) title("DV_Prof_Sales_Ind_MV_PI_a");

#delimit cr


** Step 2: Regression analysis with IV and MV predicting DV (b path)
xi: areg avg_z_hyp_a1_fu  assign_man assign_ent PI_fu bl_avg_z_hyp_a1 bl_avg_z_hyp_a1_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store Profits_Sales_Index_2
	test
	estadd scalar p_joint_significance = r(p)
	sum avg_z_hyp_a1_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)

// b coefficient: 0.0893418
//b SE = 0.0205673
display 0.0205673^2 // var(b)= 0.00042301

#delimit;
estout Profits_Sales_Index_2 using "$results\DV_Prof_Sales_Ind_MV_PI_b.txt", replace
cells(b(fmt(%12.3fc)star) se(par(`"="("'`")""') fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneurial)
stats(N p_man_ent p_joint_significance control_mean, fmt(0 %12.3fc %12.3fc)) title("DV_Prof_Sales_Ind_MV_PI_b");

#delimit cr




************* MV: Capital and Labor Inputs *************
** Step 1: Regression analysis with IV predicting MV (a path)
xi: areg avg_z_hyp_b1_fu assign_man assign_ent bl_avg_z_hyp_a1 bl_avg_z_hyp_a1_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store Capital_and_Labor_Inputs
	test
	estadd scalar p_joint_significance = r(p)
	sum business_practice_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)

// a coefficient: 0.0794818 
//a SE = 0.0219941
display 0.0219941^2 // var(a)= 0.00048374

#delimit;
estout Capital_and_Labor_Inputs using "$results\DV_Prof_Sales_Ind_MV_Capital_and_Labor_a.txt", replace
cells(b(fmt(%12.3fc)star) se(par(`"="("'`")""') fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneurial)
stats(N p_man_ent p_joint_significance control_mean, fmt(0 %12.3fc %12.3fc)) title("DV_Prof_Sales_Ind_MV_Capital_and_Labor_a");

#delimit cr

** Step 2: Regression analysis with IV and MV predicting DV (b path)
xi: areg avg_z_hyp_a1_fu  assign_man assign_ent avg_z_hyp_b1_fu bl_avg_z_hyp_a1 bl_avg_z_hyp_a1_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store Profits_Sales_Index_3
	test
	estadd scalar p_joint_significance = r(p)
	sum avg_z_hyp_a1_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)

// b coefficient: 0.5866218
//b SE =  0.0473775
display 0.0473775^2 // var(b)= 0.00224463

#delimit;
estout Profits_Sales_Index_3 using "$results\DV_Prof_Sales_Ind_MV_Capital_and_Labor_b.txt", replace
cells(b(fmt(%12.3fc)star) se(par(`"="("'`")""') fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneurial)
stats(N p_man_ent p_joint_significance control_mean, fmt(0 %12.3fc %12.3fc)) title("DV_Prof_Sales_Ind_MV_Capital_and_Labor_b");

#delimit cr


************* MV: Innovation Index *************
** Step 1: Regression analysis with IV predicting MV (a path)
xi: areg avg_z_hyp_cs4a_fu assign_man assign_ent bl_avg_z_hyp_a1 bl_avg_z_hyp_a1_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store Innovation_Index
	test
	estadd scalar p_joint_significance = r(p)
	sum business_practice_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)

// a coefficient: 0.3096783
//a SE = 0.0710215
display 0.0710215^2 // var(a)= 0.00504405

#delimit;
estout Innovation_Index using "$results\DV_Prof_Sales_Ind_MV_Innovation_Index_a.txt", replace
cells(b(fmt(%12.3fc)star) se(par(`"="("'`")""') fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneurial)
stats(N p_man_ent p_joint_significance control_mean, fmt(0 %12.3fc %12.3fc)) title("DV_Prof_Sales_Ind_MV_Innovation_Index_a");

#delimit cr

** Step 2: Regression analysis with IV and MV predicting DV (b path)
xi: areg avg_z_hyp_a1_fu assign_man assign_ent avg_z_hyp_cs4a_fu bl_avg_z_hyp_a1 bl_avg_z_hyp_a1_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store Profits_Sales_Index_4
	test
	estadd scalar p_joint_significance = r(p)
	sum avg_z_hyp_a1_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)

// b coefficient: 0.0288382 ns
//b SE =  0.0226656
display  0.0226656^2 // var(b)= 0.00051373

#delimit;
estout Profits_Sales_Index_4 using "$results\DV_Prof_Sales_Ind_MV_Innovation_Index_b.txt", replace
cells(b(fmt(%12.3fc)star) se(par(`"="("'`")""') fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneurial)
stats(N p_man_ent p_joint_significance control_mean, fmt(0 %12.3fc %12.3fc)) title("DV_Prof_Sales_Ind_MV_Innovation_Index_b");

#delimit cr


************* MV: Changed Activity *************
** Step 1: Regression analysis with IV predicting MV (a path)
xi: areg sec_sector_change_fu assign_man assign_ent bl_avg_z_hyp_a1 bl_avg_z_hyp_a1_miss  i.fu, a(strata) cluster(id_ent) robust
	estimates store Changed_Activity
	test
	estadd scalar p_joint_significance = r(p)
	sum business_practice_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)
	
// a coefficient: 0.0915248
//a SE = 0.0181824
display 0.0181824^2 // var(a)= 0.0003306

#delimit;
estout Changed_Activity using "$results\DV_Prof_Sales_Ind_MV_Changed_Activity_a.txt", replace
cells(b(fmt(%12.3fc)star) se(par(`"="("'`")""') fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneurial)
stats(N p_man_ent p_joint_significance control_mean, fmt(0 %12.3fc %12.3fc)) title("DV_Prof_Sales_Ind_MV_Changed_Activity_a");

#delimit cr

** Step 2: Regression analysis with IV and MV predicting DV (b path)
xi: areg avg_z_hyp_a1_fu assign_man assign_ent sec_sector_change_fu bl_avg_z_hyp_a1 bl_avg_z_hyp_a1_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store Profits_Sales_Index_5
	test
	estadd scalar p_joint_significance = r(p)
	sum avg_z_hyp_a1_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)


// b coefficient: 0.0520723
//b SE = 0.024756
display 0.024756^2 // var(b)= 0.00061286

#delimit;
estout Profits_Sales_Index_5 using "$results\DV_Prof_Sales_Ind_MV_Changed_Activity_b.txt", replace
cells(b(fmt(%12.3fc)star) se(par(`"="("'`")""') fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneurial)
stats(N p_man_ent p_joint_significance control_mean, fmt(0 %12.3fc %12.3fc)) title("DV_Prof_Sales_Ind_MV_Changed_Activity_b");

#delimit cr

************** MV: Access to Finance Index *************
** Step 1: Regression analysis with IV predicting MV (a path)
xi:	areg avg_z_hyp_cs4c_fu assign_man assign_ent bl_avg_z_hyp_a1 bl_avg_z_hyp_a1_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store Access_to_Finance
	test assign_man=assign_ent	
	estadd scalar p_joint_significance = r(p)
	sum avg_z_hyp_cs4c_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)
	
// a coefficient: 0.1258192 
//a SE = 0.0420799
display 0.0420799^2 // var(a)= 0.00177072

#delimit;
estout Access_to_Finance using "$results\DV_Prof_Sales_Ind_MV_Access_to_Finance_a.txt", replace
cells(b(fmt(%12.3fc)star) se(par(`"="("'`")""') fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneurial)
stats(N p_man_ent p_joint_significance control_mean, fmt(0 %12.3fc %12.3fc)) title("DV_Prof_Sales_Ind_MV_Changed_Activity_a");

#delimit cr

** Step 2: Regression analysis with IV and MV predicting DV (b path)
xi: areg avg_z_hyp_a1_fu assign_man assign_ent avg_z_hyp_cs4c_fu bl_avg_z_hyp_a1 bl_avg_z_hyp_a1_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store Profits_Sales_Index_6
	test
	estadd scalar p_joint_significance = r(p)
	sum avg_z_hyp_a1_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)


// b coefficient: 0.1877289
//b SE = 0.0790211
display 0.0790211^2 // var(b)= 0.00624433

#delimit;
estout Profits_Sales_Index_6 using "$results\DV_Prof_Sales_Ind_MV_Access_to_Finance_b.txt", replace
cells(b(fmt(%12.3fc)star) se(par(`"="("'`")""') fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneurial)
stats(N p_man_ent p_joint_significance control_mean, fmt(0 %12.3fc %12.3fc)) title("DV_Prof_Sales_Ind_MV_Access_to_Finance_b");

#delimit cr

************* MV: All Significant Mediators (Business Practices, PI, Capital and Labor Input, Changed Activity) *************
*** a paths ***
************* MV: Business Practices *************
** Step 1: Regression analysis with IV predicting MV (a path)
xi: areg business_practice_fu assign_man assign_ent bl_avg_z_hyp_a1 bl_avg_z_hyp_a1_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store Business_Practices
	test
	estadd scalar p_joint_significance = r(p)
	sum business_practice_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)
	
// a coefficient: 0.0571327
//a SE = 0.0076578
display  0.0076578^2 // var(a)=0.00005864


#delimit;
estout Business_Practices using "$results\DV_Prof_Sales_Ind_MV_Bus_Prac_a.txt", replace
cells(b(fmt(%12.3fc)star) se(par(`"="("'`")""') fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneurial)
stats(N p_man_ent p_joint_significance control_mean , fmt(0 %12.3fc %12.3fc)) title("DV_Prof_Sales_Ind_MV_Bus_Prac_a");

#delimit cr


************* MV: Personal Initiative *************
** Step 1: Regression analysis with IV predicting MV (a path)
xi: areg PI_fu assign_man assign_ent bl_avg_z_hyp_a1 bl_avg_z_hyp_a1_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store Personal_Initiative
	test
	estadd scalar p_joint_significance = r(p)
	sum business_practice_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)
	
// a coefficient: 0.1204967
//a SE = 0.0156163
display 0.0156163^2 // var(a)= 0.00024387
	
#delimit;
estout Personal_Initiative using "$results\DV_Prof_Sales_Ind_MV_PI_a.txt", replace
cells(b(fmt(%12.3fc)star) se(par(`"="("'`")""') fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneurial)
stats(N p_man_ent p_joint_significance control_mean, fmt(0 %12.3fc %12.3fc)) title("DV_Prof_Sales_Ind_MV_PI_a");

#delimit cr



************* MV: Capital and Labor Inputs *************
** Step 1: Regression analysis with IV predicting MV (a path)
xi: areg avg_z_hyp_b1_fu assign_man assign_ent bl_avg_z_hyp_a1 bl_avg_z_hyp_a1_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store Capital_and_Labor_Inputs
	test
	estadd scalar p_joint_significance = r(p)
	sum business_practice_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)

// a coefficient: 0.0794818 
//a SE = 0.0219941
display 0.0219941^2 // var(a)= 0.00048374

#delimit;
estout Capital_and_Labor_Inputs using "$results\DV_Prof_Sales_Ind_MV_Capital_and_Labor_a.txt", replace
cells(b(fmt(%12.3fc)star) se(par(`"="("'`")""') fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneurial)
stats(N p_man_ent p_joint_significance control_mean, fmt(0 %12.3fc %12.3fc)) title("DV_Prof_Sales_Ind_MV_Capital_and_Labor_a");

#delimit cr


************* MV: Changed Activity *************
** Step 1: Regression analysis with IV predicting MV (a path)
xi: areg sec_sector_change_fu assign_man assign_ent bl_avg_z_hyp_a1 bl_avg_z_hyp_a1_miss  i.fu, a(strata) cluster(id_ent) robust
	estimates store Changed_Activity
	test
	estadd scalar p_joint_significance = r(p)
	sum business_practice_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)
	
// a coefficient: 0.0915248
//a SE = 0.0181824
display 0.0181824^2 // var(a)= 0.0003306

#delimit;
estout Changed_Activity using "$results\DV_Prof_Sales_Ind_MV_Changed_Activity_a.txt", replace
cells(b(fmt(%12.3fc)star) se(par(`"="("'`")""') fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneurial)
stats(N p_man_ent p_joint_significance control_mean, fmt(0 %12.3fc %12.3fc)) title("DV_Prof_Sales_Ind_MV_Changed_Activity_a");

#delimit cr

************** MV: Access to Finance Index *************
** Step 1: Regression analysis with IV predicting MV (a path)
xi:	areg avg_z_hyp_cs4c_fu assign_man assign_ent bl_avg_z_hyp_a1 bl_avg_z_hyp_a1_miss i.fu, a(strata) cluster(id_ent) robust
	estimates store Access_to_Finance
	test assign_man=assign_ent	
	estadd scalar p_joint_significance = r(p)
	sum avg_z_hyp_cs4c_fu if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)
	
// a coefficient: 0.1258192 
//a SE = 0.0420799
display 0.0420799^2 // var(a)= 0.00177072

#delimit;
estout Access_to_Finance using "$results\DV_Prof_Sales_Ind_MV_Access_to_Finance_a.txt", replace
cells(b(fmt(%12.3fc)star) se(par(`"="("'`")""') fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneurial)
stats(N p_man_ent p_joint_significance control_mean, fmt(0 %12.3fc %12.3fc)) title("DV_Prof_Sales_Ind_MV_Changed_Activity_a");

#delimit cr

*** b paths - Model with PI scale ***
** Step 2: Regression analysis with IV and MVs predicting DV (b paths)
xi: areg avg_z_hyp_a1_fu  assign_man assign_ent business_practice_fu PI_fu avg_z_hyp_b1_fu sec_sector_change_fu avg_z_hyp_cs4c_fu bl_avg_z_hyp_a1 bl_avg_z_hyp_a1_miss  i.fu, a(strata) cluster(id_ent) robust
	estimates store Profits_Sales_Index_allMV
	test
	estadd scalar p_joint_significance = r(p)
	sum avg_z_hyp_a1 if assign_group==3
	estadd scalar control_mean = r(mean)
	
	test assign_man=assign_ent
	estadd scalar F_value=r(F)
	estadd scalar p_man_ent=r(p)

// b1 coefficient: 0.580693  
//b1 SE = 0.0920903

// b2 coefficient: 0.0014903
//b2 SE = 0.022839

// b3 coefficient: 0.4775332
//b3 SE = 0.0596089

// b4 coefficient:  -0.0451788
//b4 SE = 0.0274434

// b5 coefficient:  0.0961155
//b5 SE = 0.0618281

#delimit;
estout Profits_Sales_Index_allMV using "$results\DV_Prof_Sales_Index_MV_Bus_Prac_allMV_bs.txt", replace
cells(b(fmt(%12.3fc)star) se(par(`"="("'`")""') fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneurial)
stats(N p_man_ent p_joint_significance control_mean, fmt(0 %12.3fc  %12.3fc)) title("DV_Prof_Sales_Index_MV_Bus_Prac_allMV_bs");

#delimit cr


#delimit;
estout Profits_Sales_Index_1 Profits_Sales_Index_2 Profits_Sales_Index_3 Profits_Sales_Index_4 Profits_Sales_Index_5 Profits_Sales_Index_6 Profits_Sales_Index_allMV using "$results\Table 16.txt", replace
cells(b(fmt(%12.3fc)star) se(par(`"="("'`")""') fmt(%12.3fc))) starlevels(* .1 ** .05 *** .01) drop(_cons) legend varlabels(assign_man Managerial assign_ent Entrepreneurial)
stats(N p_man_ent p_joint_significance control_mean, fmt(0 %12.3fc  %12.3fc)) title("Table 16");

#delimit cr
