* 	THIS FILE APPENDS THE SOLUTION FILES OF DIFF SCENARIOS AND ANALYSES THE DIFFUSION


** 	CHANGE THE DIRECTORY
	cd $DIR
/*
** 	OPEN SOLUTION.DTA
	use BSL_Solution, clear


**	APPEND THE SOUTION FILES


	append using MAI_solution
	append using MAI_CRE_solution
	append using FERT1_solution
	append using FER_RC1_solution
	append using FER_RC2_solution
	
	save Diffusion, replace
*/
*********************************************************************************************
	use EndData, clear

	g ac_credit =1 if Br_cred > 0
	
	egen c_irmaize = rowtotal(grow_feb_irrimaize_* grow_mar_irrimaize_* grow_aprl_irrimaize_*)
	g ac_irmaize =1 if c_irmaize > 0


	collapse (sum) ac_credit ac_irmaize (count) aID, by( run period) fast

	g pa_ac_credit = ac_credit/aID*100
	g pa_ac_irmaize = ac_irmaize/aID*100

	g 		scenario = 0  if run == "BSL"
	replace 	scenario = 1  if run == "CRE"
	replace 	scenario = 2  if run == "FER1"
	replace  	scenario = 3  if run == "C_FER1"
	replace 	scenario = 4  if run == "FER2"
	replace 	scenario = 5  if run == "C_FER2"
	replace 	scenario = 6  if run == "BSL_DRY"
	replace 	scenario = 7  if run == "CRE_DRY"
	replace 	scenario = 8  if run == "CRE_DRYRIF"

	keep run period scenario pa_ac_credit pa_ac_irmaize
	drop if period==1

	graph twoway (line pa_ac_credit period  if scenario == 1, clw(*1) lc(gs2) ) (line pa_ac_credit period if scenario == 3, clw(*1) lc(red)) (line pa_ac_credit period if scenario == 7, clw(*1) lc(forest_green) ) (line pa_ac_credit period if scenario == 8, clw(*1) lc(lavender) )  , xtitle("Year", size(medium) margin(medium) ) ytitle(" % of agents", size(medium) margin(medium))  ylabel(30(2)50, angle(horizontal)) xlabel(1 (1)10) legend( label(1 "Access to Credit") label(2 "Fertilizer" "price (-25%)") label(3 "Access to" "credit - drought") label(4 "Access to credit" "- drought + Inflow (-75%)") col(1) pos(3) rowgap(6) order(1 2 3 4 ) symx(*0.5) ) legend(title(Scenario,  size(medium) margin(medsmall) ) region(lc(white))) xmt(2(1)10) graphregion(margin(l-5 b-5)) xsize(20) ysize(15) title(" Short-term credit") graphregion(fc(white))plotregion( lc(black))




gg
	graph twoway (line pa_ac_credit period  if scenario == 1, clw(*1) lc(gs2) ) (line pa_ac_credit period if scenario == 3, clw(*1) lc(red)) (line pa_ac_credit period if scenario == 7, clw(*1) lc(forest_green) )  (line pa_ac_credit period if scenario == 7, clw(*1) lc(blue))  (connected pa_ac_credit period if scenario == 9, clw(*1) lc(lavender) ms(S) mc(gs10) mfc(white)), xtitle("Year", size(medium) margin(medium) ) ytitle(" % of agents", size(medium) margin(medium))  ylabel(0(2)30, angle(horizontal)) xlabel(1 (1)10) legend(label(1 "BSL") label(2 "Access to Irrigate Maize") label(3 "Access to Credit") label(4 "Fertilizer price(-50%)") label(5 "Reduced cost(-25%)") label(6 "Reduced cost (-50%)") col(1) pos(3) rowgap(12) order(1 2 3 6 4 5) symx(*0.5) ) legend(title(Scenario,  size(medium) margin(medsmall) ) region(lc(white))) xmt(2(1)10) graphregion(margin(l-5 b-5)) xsize(20) ysize(15) title(" Short-term credit")

