/* ******************************************************************* LAST UPDATE: Oct 2018 THIS FILE DOES THE FOLLOWING 1) Expolores the WIOD data used in Doda, B. (2018). Tales from the tails: Sector-level carbon intensity distribution. Climate Change Economics, forthcoming. 2) Provides the empirical analysis, tables, figures behind Section 3 INPUT: data file which can be constructed following the instructions in Section 2. OUTPUT: various tables and graphs saved in "\doda2018_CCE_results" ******************************************************************* */ clear graph drop _all use "...\WIOD_data_oct2017.dta", replace cd "...\doda2018_CCE_S3results" drop if sector==35 drop if cou=="LUX" drop if cou=="CYP" drop if cou=="MLT" drop if year>2009 rename va va_ncu gene va_cncu=va_ncu/va_p*100 gene va_usd=va_ncu*exr sort country sector year by country sector: gene aux=va_usd if year==1995 by country sector: egen base=max(aux) by country sector: gene va_cusd=base*va_qi/100 drop aux base gene lprod_cusd=log(va_cusd/emp) ************************************************************************ * Rich and poor countries based on economy wide output per worker (2009) sort country year sector gene aux=lprod_cusd if sec==36 by country year: egen lopw_cusd=max(aux) drop aux sum lopw_cu if year==2009 & sec==36, d scalar med2009=r(p50) gene aux=0 replace aux=1 if lopw_cu>med2009 by country: egen rich=max(aux) drop aux *Rich and poor countries based on economy wide output per worker (1995) sum lopw_cu if year==1995 & sec==36, d scalar med1995=r(p50) gene aux=0 replace aux=1 if lopw_cu>med1995 by country: egen rich95=max(aux) drop aux * Rich and poor countries based on WB classficiation (1995) gene richWB95=rich replace richWB95=1 if cou=="PRT" *browse cou rich* if year==2009 & sec==36 ************************************************************************ drop if sector==36 keep panel cou sec year desc1 co2 va_cncu rich* order country year desc1 co2 va_cncu rich * ANALYSIS STARTS ******************* * IDA on WIOD using notation in ANG (2005) * switch to million tonnes by dividing through by 1000 ******************* sort country year sec by country year: egen Q=sum(va_cncu) by country year: egen E=sum(co2/1000) sort country sec year gene E_i=co2/1000 gene I_i=E_i/va_c gene S_i=va_c/Q ******************************************************************************** *additive decomposition (chained) sort panelid year by panelid: gene dE_act_i=(E_i-l.E_i)/(ln(E_i)-ln(l.E_i))*ln(Q/l.Q) by panelid: gene dE_str_i=(E_i-l.E_i)/(ln(E_i)-ln(l.E_i))*ln(S_i/l.S_i) by panelid: gene dE_int_i=(E_i-l.E_i)/(ln(E_i)-ln(l.E_i))*ln(I_i/l.I_i) sort year country by year country: egen dE_act=sum(dE_act_i) by year country: egen dE_str=sum(dE_str_i) by year country: egen dE_int=sum(dE_int_i) sort panel year gen dE_act_chain=dE_act bysort panel (year) : replace dE_act_chain=dE_act_chain[_n]+dE_act_chain[_n-1] if _n > 1 gen dE_str_chain=dE_str bysort panel (year) : replace dE_str_chain=dE_str_chain[_n]+dE_str_chain[_n-1] if _n > 1 gen dE_int_chain=dE_int bysort panel (year) : replace dE_int_chain=dE_int_chain[_n]+dE_int_chain[_n-1] if _n > 1 rename dE_act_chain act_LMDIa rename dE_str_chain str_LMDIa rename dE_int_chain int_LMDIa ******************************************************************************** keep if sec==27 gen aux=E if year==1995 sort country year by country: egen E_1995=max(aux) drop aux gen E_nic = E_1995 + str_LMDIa + act_LMDIa gen E_nsc = E_1995 + int_LMDIa + act_LMDIa gen E_nac = E_1995 + str_LMDIa + int_LMDIa by country: egen num_nic=sum(E_nic) by country: egen num_nsc=sum(E_nsc) by country: egen num_nac=sum(E_nac) by country: egen den=sum(E) gen rce_nic=num_nic/den-1 gen rce_nsc=num_nsc/den-1 gen rce_nac=num_nac/den-1 ******************************************************************************** * REPORTS GRAPHS to paper gsort year -richWB95 rce_nic browse country rce_* richWB95 if year==2007 sum rce* if year==2007 & richWB95==1 sum rce* if year==2007 & richWB95==0 *sum rce* if year==2007 & richWB09==1 *sum rce* if year==2007 & richWB09==1 & cou~="TWN" *sum rce* if year==2007 & richWB09==0 *sum rce* if year==2007 & rich==1 *sum rce* if year==2007 & rich==1 & cou~="TWN" *sum rce* if year==2007 & rich==0 * ADV count if year==2007 & richWB95==1 & rce_nic>0 count if year==2007 & richWB95==1 & rce_nsc>0 count if year==2007 & richWB95==1 & rce_nic>0 & rce_nsc>0 * DEV count if year==2007 & richWB95==0 & rce_nic>0 count if year==2007 & richWB95==0 & rce_nsc>0 count if year==2007 & richWB95==0 & rce_nic>0 & rce_nsc>0 * ALL count if year==2007 & rce_nic>0 count if year==2007 & rce_nsc>0 count if year==2007 & rce_nic>0 & rce_nsc>0 * equality of means and variances *NIC ttest rce_nic if year==2007, by(richWB95) une sdtest rce_nic if year==2007, by(richWB95) *NSC ttest rce_nsc if year==2007, by(richWB95) une sdtest rce_nsc if year==2007, by(richWB95) *NAC ttest rce_nac if year==2007, by(richWB95) une sdtest rce_nac if year==2007, by(richWB95) twoway (tsline E, lw(0.8)) (tsline E_nic E_nsc E_nac) if cou=="USA", /// legend(order(1 "Observed" 2 "Absent intensity change (NIC)" 3 "Absent structure change (NSC)" 4 "Absent activity change (NAC)") rows(2) size(2.5)) /// xtitle("") title("USA") ytitle("mt of CO2") saving(USA, replace) twoway (tsline E, lw(0.8)) (tsline E_nic E_nsc E_nac) if cou=="CHN", /// legend(order(1 "Observed" 2 "Absent intensity change (NIC)" 3 "Absent structure change (NSC)" 4 "Absent activity change (NAC)") rows(2) size(2.5)) /// xtitle("") title("CHN") saving(CHN, replace) grc1leg USA.gph CHN.gph, cols(2) legendfrom(CHN.gph) ycomm *graph export "figures\IDA_counterfactuals_USA_CHN.eps", as(eps) preview(on) replace *graph export "figures\IDA_counterfactuals_USA_CHN.pdf", replace twoway (scatter rce_nic rce_nsc if year==2007 & richWB95==1, msym(none) mlab(cou) mlabsize(1.5) mlabpos(0)) /// (scatter rce_nic rce_nsc if year==2007 & richWB95==0, msym(none) mlab(cou) mlabsize(1.5) mlabpos(0)), /// xsc(r(-0.4 0.6)) ysc(r(-0.4 0.6)) legend(order() off) /// xline(0,lwidth(0.1) lcolor(grey)) yline(0, lwidth(0.1) lcolor(grey)) /// xtitle("rce{superscript:NSC}") ytitle("rce{superscript:NIC}") *graph export "figures\IDA_counterfactuals_xc.eps", as(eps) preview(on) replace *graph export "figures\IDA_counterfactuals_xc.pdf", replace