'********************************************************************************************
'this program collects responses of output, taxes, spending and F(s) and plots them
'********************************************************************************************
SMPL !START !YEAR 
PAGESELECT TimeSeries
%MODEL5 = "SD2"	
%MODEL0 = "SPND_DOWN SPND_UP TAX_DOWN TAX_UP"  
%MODEL0_UP = "SPND_UP TAX_UP"  
%MODEL0_DOWN = "SPND_DOWN TAX_DOWN"  

'collect responses of output, taxes and spending
FOR %VAR {%VARS}
		FOR %IDC {%LIST}
				!j=1
				MATRIX(!HORZ,12) rsp_{%VAR}_{%MODEL5}_{%IDC}
				FOR %MOD {%MODEL0}
						FOR !i=1 TO 3	
								FOR !k=1 to !HORZ
									rsp_{%VAR}_{%MODEL5}_{%IDC}(!k,!j) = rsp_{%VAR}_{%MOD}_{%IDC}(!k,!i)
								NEXT
							!j=!j+1
						NEXT
				NEXT
		NEXT
NEXT
'fs up matrix
FOR %IDC {%LIST}
		!j=1
		MATRIX(!HORZ,8) rsp_fsup_{%MODEL5}_{%IDC}
		FOR %MOD {%MODEL0_UP}
			FOR !i=1 TO 4
				FOR !k=1 to !HORZ
					rsp_fsup_{%MODEL5}_{%IDC}(!k,!j) = rsp_fs_{%MOD}_{%IDC}(!k,!i)
				NEXT
				!j=!j+1
			NEXT
		NEXT
NEXT
'fs down matrix
FOR %IDC {%LIST}
		!j=1
		MATRIX(!HORZ,8) rsp_fsdown_{%MODEL5}_{%IDC}
		FOR %MOD {%MODEL0_DOWN}
			FOR !i=1 TO 4
				FOR !k=1 to !HORZ
					rsp_fsdown_{%MODEL5}_{%IDC}(!k,!j) = rsp_fs_{%MOD}_{%IDC}(!k,!i)
				NEXT
				!j=!j+1
			NEXT
		NEXT
NEXT
'fs deviation
FOR %IDC {%LIST}
		!j=1
		MATRIX(!HORZ,12) rsp_fsd_{%MODEL5}_{%IDC}
		FOR %MOD {%MODEL0}
			FOR !i=1 TO 3	
				FOR !k=1 to !HORZ
					rsp_fsd_{%MODEL5}_{%IDC}(!k,!j) = rsp_fsd_{%MOD}_{%IDC}(!k,!i)
				NEXT
				!j=!j+1
			NEXT
		NEXT
NEXT

'graph output taxes and spending
FOR %IDC {%LIST}
	%FIG = "FIG1"
		FOR %NAME {%VARS} 
			DELETE FIG_{%NAME}_{%IDC}*
			FREEZE({%FIG}_{%NAME}_{%IDC}) rsp_{%NAME}_{%MODEL5}_{%IDC}.LINE
			{%FIG}_{%NAME}_{%IDC}.OPTION linepat 
			{%FIG}_{%NAME}_{%IDC}.ELEM(1) lcolor(102,178,255) lpat(dash7) lwidth(0.25)
			{%FIG}_{%NAME}_{%IDC}.ELEM(3) lcolor(102,178,255) lpat(dash7) lwidth(0.25)
			{%FIG}_{%NAME}_{%IDC}.ELEM(2) lcolor(102,178,255) lpat(solid) lwidth(2) sym(circle) symbolsize(4xl)
			{%FIG}_{%NAME}_{%IDC}.ELEM(4) lcolor(blue) lpat(dash7) lwidth(0.25)
			{%FIG}_{%NAME}_{%IDC}.ELEM(6) lcolor(blue) lpat(dash7) lwidth(0.25)
			{%FIG}_{%NAME}_{%IDC}.ELEM(5) lcolor(blue) lpat(solid) lwidth(2) sym(circle) symbolsize(4xl)
			{%FIG}_{%NAME}_{%IDC}.ELEM(7) lcolor(255,153,153) lpat(dash7) lwidth(0.25)
			{%FIG}_{%NAME}_{%IDC}.ELEM(9) lcolor(255,153,153) lpat(dash7) lwidth(0.25)
			{%FIG}_{%NAME}_{%IDC}.ELEM(8) lcolor(255,153,153) lpat(solid) lwidth(2) sym(circle) symbolsize(4xl)
			{%FIG}_{%NAME}_{%IDC}.ELEM(10) lcolor(red) lpat(dash7) lwidth(0.25)
			{%FIG}_{%NAME}_{%IDC}.ELEM(12) lcolor(red) lpat(dash7) lwidth(0.25)
			{%FIG}_{%NAME}_{%IDC}.ELEM(11) lcolor(red) lpat(solid) lwidth(2) sym(circle) symbolsize(4xl)
			{%FIG}_{%NAME}_{%IDC}.AXIS(l) grid zeroline  range(-8,10)
			{%FIG}_{%NAME}_{%IDC}.LEGEND(off,inbox,b)
			{%FIG}_{%NAME}_{%IDC}.SETOBSLABEL(blank) "0" "1" "2" "3" "4" "5"
			{%FIG}_{%NAME}_{%IDC}.OPTIONS backfade(none) backcolor(white)
			{%FIG}_{%NAME}_{%IDC}.AXIS overlap	
			RENAME {%FIG}_{%NAME}_{%IDC} fig_{%NAME}_{%IDC}_{%MODEL5}
		NEXT
NEXT
'graph fs up
FOR %IDC {%LIST}
	%FIG = "FIG2"
	%NAME="fsup"
	DELETE FIG_{%NAME}_{%IDC}*
	FREEZE({%FIG}_{%NAME}_{%IDC}) rsp_fsup_{%MODEL5}_{%IDC}.LINE
	{%FIG}_{%NAME}_{%IDC}.OPTION linepat 
	{%FIG}_{%NAME}_{%IDC}.ELEM(1) lcolor(black) lpat(solid) lwidth(1) 
	{%FIG}_{%NAME}_{%IDC}.ELEM(3) lcolor(blue) lpat(solid) lwidth(1)
	{%FIG}_{%NAME}_{%IDC}.ELEM(2) lcolor(blue) lpat(dash7) lwidth(0.25) 
	{%FIG}_{%NAME}_{%IDC}.ELEM(4) lcolor(blue) lpat(dash7) lwidth(0.25)
	{%FIG}_{%NAME}_{%IDC}.ELEM(7) lcolor(red) lpat(solid) lwidth(1)
	{%FIG}_{%NAME}_{%IDC}.ELEM(6) lcolor(red) lpat(dash7) lwidth(0.25) 
	{%FIG}_{%NAME}_{%IDC}.ELEM(8) lcolor(red) lpat(dash7) lwidth(0.25)
	{%FIG}_{%NAME}_{%IDC}.ELEM(5) lcolor(black) lpat(solid) lwidth(1) 
	{%FIG}_{%NAME}_{%IDC}.AXIS(l) grid zeroline range(-0.16,0.35)
	{%FIG}_{%NAME}_{%IDC}.LEGEND(off,inbox,b)
	{%FIG}_{%NAME}_{%IDC}.SETOBSLABEL(blank)  "0" "1" "2" "3" "4" "5"
	{%FIG}_{%NAME}_{%IDC}.OPTIONS backfade(none) backcolor(white)
	{%FIG}_{%NAME}_{%IDC}.AXIS overlap	
	RENAME {%FIG}_{%NAME}_{%IDC} fig_{%NAME}_{%IDC}_{%MODEL5}
NEXT
'graph fs down
FOR %IDC {%LIST}
	%FIG = "FIG2"
	%NAME="fsdown"
	DELETE FIG_{%NAME}_{%IDC}*
	FREEZE({%FIG}_{%NAME}_{%IDC}) rsp_fsdown_{%MODEL5}_{%IDC}.LINE
	{%FIG}_{%NAME}_{%IDC}.OPTION linepat 
	{%FIG}_{%NAME}_{%IDC}.ELEM(1) lcolor(black) lpat(solid) lwidth(1) 
	{%FIG}_{%NAME}_{%IDC}.ELEM(3) lcolor(102,178,255) lpat(solid) lwidth(1)
	{%FIG}_{%NAME}_{%IDC}.ELEM(2) lcolor(102,178,255) lpat(dash7) lwidth(0.25) 
	{%FIG}_{%NAME}_{%IDC}.ELEM(4) lcolor(102,178,255) lpat(dash7) lwidth(0.25)
	{%FIG}_{%NAME}_{%IDC}.ELEM(7) lcolor(255,153,153) lpat(solid) lwidth(1)
	{%FIG}_{%NAME}_{%IDC}.ELEM(6) lcolor(255,153,153) lpat(dash7) lwidth(0.25) 
	{%FIG}_{%NAME}_{%IDC}.ELEM(8) lcolor(255,153,153) lpat(dash7) lwidth(0.25)
	{%FIG}_{%NAME}_{%IDC}.ELEM(5) lcolor(black) lpat(solid) lwidth(1) 
	{%FIG}_{%NAME}_{%IDC}.AXIS(l) grid zeroline range(-0.16,0.35)
	{%FIG}_{%NAME}_{%IDC}.LEGEND(off,inbox,b)
	{%FIG}_{%NAME}_{%IDC}.SETOBSLABEL(blank)  "0" "1" "2" "3" "4" "5"
	{%FIG}_{%NAME}_{%IDC}.OPTIONS backfade(none) backcolor(white)
	{%FIG}_{%NAME}_{%IDC}.AXIS overlap		
	RENAME {%FIG}_{%NAME}_{%IDC} fig_{%NAME}_{%IDC}_{%MODEL5}
NEXT
'graph fs deviaiton
FOR %IDC {%LIST}
	%FIG = "FIG2"
	%NAME="fsd"
	DELETE FIG_{%NAME}_{%IDC}*
	FREEZE({%FIG}_{%NAME}_{%IDC}) rsp_fsd_{%MODEL5}_{%IDC}.LINE
	{%FIG}_{%NAME}_{%IDC}.OPTION linepat 
	{%FIG}_{%NAME}_{%IDC}.ELEM(1) lcolor(102,178,255) lpat(dash7) lwidth(0.25)
	{%FIG}_{%NAME}_{%IDC}.ELEM(3) lcolor(102,178,255) lpat(dash7) lwidth(0.25)
	{%FIG}_{%NAME}_{%IDC}.ELEM(2) lcolor(102,178,255) lpat(solid) lwidth(2) sym(circle) symbolsize(4xl)
	{%FIG}_{%NAME}_{%IDC}.ELEM(4) lcolor(blue) lpat(dash7) lwidth(0.25)
	{%FIG}_{%NAME}_{%IDC}.ELEM(6) lcolor(blue) lpat(dash7) lwidth(0.25)
	{%FIG}_{%NAME}_{%IDC}.ELEM(5) lcolor(blue) lpat(solid) lwidth(2) sym(circle) symbolsize(4xl)
	{%FIG}_{%NAME}_{%IDC}.ELEM(7) lcolor(255,153,153) lpat(dash7) lwidth(0.25)
	{%FIG}_{%NAME}_{%IDC}.ELEM(9) lcolor(255,153,153) lpat(dash7) lwidth(0.25)
	{%FIG}_{%NAME}_{%IDC}.ELEM(8) lcolor(255,153,153) lpat(solid) lwidth(2) sym(circle) symbolsize(4xl)
	{%FIG}_{%NAME}_{%IDC}.ELEM(10) lcolor(red) lpat(dash7) lwidth(0.25)
	{%FIG}_{%NAME}_{%IDC}.ELEM(12) lcolor(red) lpat(dash7) lwidth(0.25)
	{%FIG}_{%NAME}_{%IDC}.ELEM(11) lcolor(red) lpat(solid) lwidth(2) sym(circle) symbolsize(4xl)
	{%FIG}_{%NAME}_{%IDC}.AXIS(l) grid zeroline  range(-8,10)
	{%FIG}_{%NAME}_{%IDC}.LEGEND(off,inbox,b)
	{%FIG}_{%NAME}_{%IDC}.SETOBSLABEL(blank) "0" "1" "2" "3" "4" "5"
	{%FIG}_{%NAME}_{%IDC}.OPTIONS backfade(none) backcolor(white)
	{%FIG}_{%NAME}_{%IDC}.AXIS overlap	
	RENAME {%FIG}_{%NAME}_{%IDC} fig_{%NAME}_{%IDC}_{%MODEL5}
NEXT


