clear
use  workhouse_bench.dta


//  -----electrity of demand and production //
merge m:1 IO using alpha_90.dta
drop _merge

sort alphac
_pctile alphac, nq(2)
return list   

gen alphac_0_two=1 if alphac<r(r1)	
replace alphac_0_two=0 if alphac_0_two==.	

gen alphac_1_two=1 if alphac>r(r1)	
replace alphac_1_two=0 if alphac_1_two==.

forvalues i=0(1)1{
gen fin1_up_alphac_`i'_two=alphac_`i'_two*upstream_fin1
}
forvalues i=0(1)1{
gen fin2_up_alphac_`i'_two=alphac_`i'_two*upstream_fin2
}
forvalues i=0(1)1{
gen fin3_up_alphac_`i'_two=alphac_`i'_two*upstream_fin3
}
forvalues i=0(1)1{
gen fin4_up_alphac_`i'_two=alphac_`i'_two*upstream_fin4
}

xtreg dvar   fin1_up_alphac_*_two   in_I in_K in_S tfp_lp $dum_con if dvar<0.985 ,robust
est store m1
xtreg dvar   fin2_up_alphac_*_two   in_I in_K in_S tfp_lp $dum_con if dvar<0.985 ,robust
est store m2
xtreg dvar   fin4_up_alphac_*_two   in_I in_K in_S tfp_lp $dum_con if dvar<0.985 ,robust
est store m3
esttab  m* using "Table_3_2.rtf",  ///
    p star(* 0.1 ** 0.05 *** 0.01) r2  drop($dum_con in_I in_K in_S tfp_lp) nogap replace
