// ----- basic environment --------//

clear
use  workhouse_bench.dta

merge m:1 IO using alpha_90.dta
drop _merge

keep if sigma_IO!=0
gen sigma_IO_o=sigma_IO
replace sigma_IO=sigma_IO-alpha  // 

 
sort sigma_IO
_pctile sigma_IO, nq(2)
return list   

gen sigma_IO_0_two=1 if sigma_IO<r(r1)	
replace sigma_IO_0_two=0 if sigma_IO_0_two==.	

gen sigma_IO_1_two=1 if sigma_IO>r(r1)	
replace sigma_IO_1_two=0 if sigma_IO_1_two==.

forvalues i=0(1)1{
gen fin1_up_sigma_IO_`i'_two=sigma_IO_`i'_two*upstream_fin1
}

forvalues i=0(1)1{
gen fin2_up_sigma_IO_`i'_two=sigma_IO_`i'_two*upstream_fin2
}

forvalues i=0(1)1{
gen fin3_up_sigma_IO_`i'_two=sigma_IO_`i'_two*upstream_fin3
}

forvalues i=0(1)1{
gen fin4_up_sigma_IO_`i'_two=sigma_IO_`i'_two*upstream_fin4
}

xtreg dvar   fin1_up_sigma_IO_*_two   in_I in_K in_S tfp_lp $dum_con if dvar<0.985 ,fe 
est store m1
xtreg dvar   fin2_up_sigma_IO_*_two   in_I in_K in_S tfp_lp $dum_con if dvar<0.985 ,fe 
est store m2
xtreg dvar   fin4_up_sigma_IO_*_two   in_I in_K in_S tfp_lp $dum_con if dvar<0.985 ,fe 
est store m3
esttab  m* using "Table_4_4.rtf",  ///
    p star(* 0.1 ** 0.05 *** 0.01) r2  drop($dum_con in_I in_K in_S tfp_lp) nogap replace
