*-----------------------------------------------------------------------------*
* CREATE SCATTERPLOTS OF IMPORT SHARE AGAINST CPI                             *
*-----------------------------------------------------------------------------*

#delimit ;
version 9.2 ;
cd "c:\Rick\UT Economics\Paper Ideas\Dissertation\Data\" ;
capture log close ;
log using OECD_impshr_cpi, replace ;
set more off ;
clear ;

*---------------------------------------------------------------------------- ;
* Get data ;

use OECD_impshr_cpi, clear ;

*---------------------------------------------------------------------------- ;
* Plot average M/Y and CPI for the years 1982 - 2005 for all OECD ;

egen avgimpshr82to05 = rowmean(impshr1982-impshr2005) ;
egen avgCPIrat82to05 = rowmean(CPIrat1982-CPIrat2005) ;
label variable avgCPIrat82to05 "avg annual CPI %chg." ;

reg avgCPIrat82to05 avgimpshr82to05 if _n <= 30 ;
predict predCPIrat82to05all, xb ;
label variable predCPIrat82to05all "predicted CPI" ;

reg avgCPIrat82to05 avgimpshr82to05 if _n <= 30 & abbrev ~= "MEX" &
   abbrev ~= "POL" & abbrev ~= "TUR" ;
predict predCPIrat82to05minMPT, xb ;
label variable predCPIrat82to05minMPT "pred. CPI minus MEX,POL,TUR" ;

reg avgCPIrat82to05 avgimpshr82to05 if _n <= 30 & (abbrev == "CAN" | abbrev == "DEU"
   | abbrev == "FRA" | abbrev == "ITA" | abbrev == "JAP" | abbrev == "GBR" | abbrev == "USA") ;
predict predCPIrat82to05G7, xb ;
label variable predCPIrat82to05G7 "pred. CPI for G7" ;

gen blank82to05minMPT = . ;
label variable blank82to05minMPT " " ;

graph twoway (scatter avgCPIrat82to05 avgimpshr82to05 if _n <= 30, mcolor(red) mlabel(abbrev) mlabsize(vsmall))
   (line predCPIrat82to05all avgimpshr82to05 if _n <= 30, lwidth(medthick))
   (line predCPIrat82to05minMPT avgimpshr82to05 if _n <= 30, lwidth(medthick) lpattern(dash)),
   /*title("Import share vs. CPI for OECD countries") subtitle("average 1982 to 2005")*/
   xtitle("avg annual imports/GDP") ytitle("avg annual CPI growth rate")
   yscale(range(0 0.6)) xscale(range(0 1.1))
   /* xlabel(1970 "70" 1980 "80" 1990 "90" 2000 "00" 2007 "07") ylabel(0.2(0.4)1.4)
   xmtick(1970(1)2007) xtick(1970(5)2007) ytick(0(0.2)1.4)*/
   legend(cols(1) rows(3))
   saving(OECD_impshr_cpi_82to05, replace) ;
cd "c:\Rick\UT Economics\Paper Ideas\Dissertation\OG two country\" ;
graph export OECD_impshr_cpi_82to05.eps, replace ;
! epstopdf OECD_impshr_cpi_82to05.eps ;
cd "c:\Rick\UT Economics\Paper Ideas\Dissertation\Data\" ;

graph twoway (scatter avgCPIrat82to05 avgimpshr82to05 if _n <= 30, mcolor(red) mlabel(abbrev) mlabsize(vsmall))
   (line predCPIrat82to05all avgimpshr82to05 if _n <= 30, lwidth(medthick))
   (line blank82to05minMPT avgimpshr82to05 if _n <= 30, lwidth(none) lpattern(blank)),
   /*title("Import share vs. CPI for OECD countries") subtitle("average 1982 to 2005")*/
   xtitle("avg annual imports/GDP") ytitle("avg annual CPI growth rate")
   yscale(range(-0.0031 0.6)) xscale(range(0 1.5))
   xlabel(0(0.3)1.5) ylabel(0(0.2)0.6)
   legend(cols(1) rows(3))
   saving(OECD_impshr_cpi_82to05_1, replace) ;
cd "c:\Rick\UT Economics\Paper Ideas\Dissertation\OG imperf labor\" ;
graph export OECD_impshr_cpi_82to05_1.eps, replace ;
! epstopdf OECD_impshr_cpi_82to05_1.eps ;
cd "c:\Rick\UT Economics\Paper Ideas\Dissertation\Data\" ;

graph twoway (scatter avgCPIrat82to05 avgimpshr82to05 if _n <= 30, mcolor(red) mlabel(abbrev) mlabsize(vsmall))
   (line predCPIrat82to05all avgimpshr82to05 if _n <= 30, lwidth(medthick))
   (line predCPIrat82to05minMPT avgimpshr82to05 if _n <= 30, lwidth(medthick) lpattern(dash)),
   /*title("Import share vs. CPI for OECD countries") subtitle("average 1982 to 2005")*/
   xtitle("avg annual imports/GDP") ytitle("avg annual CPI growth rate")
   yscale(range(-0.0031 0.6)) xscale(range(0 1.5))
   xlabel(0(0.3)1.5) ylabel(0(0.2)0.6)
   legend(cols(1) rows(3))
   saving(OECD_impshr_cpi_82to05_2, replace) ;
cd "c:\Rick\UT Economics\Paper Ideas\Dissertation\OG imperf labor\" ;
graph export OECD_impshr_cpi_82to05_2.eps, replace ;
! epstopdf OECD_impshr_cpi_82to05_2.eps ;
cd "c:\Rick\UT Economics\Paper Ideas\Dissertation\Data\" ;

*---------------------------------------------------------------------------- ;
* Plot average M/Y and CPI for the years 1992 - 2005 for all OECD ;

egen avgimpshr92to05 = rowmean(impshr1992-impshr2005) ;
egen avgCPIrat92to05 = rowmean(CPIrat1992-CPIrat2005) ;
label variable avgCPIrat92to05 "avg annual CPI %chg." ;

reg avgCPIrat92to05 avgimpshr92to05 if _n <= 30 ;
predict predCPIrat92to05all, xb ;
label variable predCPIrat92to05all "predicted CPI" ;

reg avgCPIrat92to05 avgimpshr92to05 if _n <= 30 & abbrev ~= "TUR" ;
predict predCPIrat92to05minT, xb ;
label variable predCPIrat92to05minT "pred. CPI minus TUR" ;

reg avgCPIrat92to05 avgimpshr92to05 if _n <= 30 & (abbrev == "CAN" | abbrev == "DEU"
   | abbrev == "FRA" | abbrev == "ITA" | abbrev == "JAP" | abbrev == "GBR" | abbrev == "USA") ;
predict predCPIrat92to05G7, xb ;
label variable predCPIrat92to05G7 "pred. CPI for G7" ;

graph twoway (scatter avgCPIrat92to05 avgimpshr92to05 if _n <= 30, mcolor(red) mlabel(abbrev) mlabsize(vsmall))
   (line predCPIrat92to05all avgimpshr92to05 if _n <= 30, lwidth(medthick))
   (line predCPIrat92to05minT avgimpshr92to05 if _n <= 30, lwidth(medthick) lpattern(dash)),
   /*title("Import share vs. CPI for OECD countries") subtitle("average 1992 to 2005")*/
   xtitle("avg annual imports/GDP") ytitle("avg annual CPI growth rate")
   yscale(range(0 0.6)) xscale(range(0 1.1))
   /* xlabel(1970 "70" 1980 "80" 1990 "90" 2000 "00" 2007 "07") ylabel(0.2(0.4)1.4)
   xmtick(1970(1)2007) xtick(1970(5)2007) ytick(0(0.2)1.4)*/
   legend(cols(1) rows(3))
   saving(OECD_impshr_cpi_92to05, replace) ;
cd "c:\Rick\UT Economics\Paper Ideas\Dissertation\OG two country\" ;
graph export OECD_impshr_cpi_92to05.eps, replace ;
! epstopdf OECD_impshr_cpi_92to05.eps ;
cd "c:\Rick\UT Economics\Paper Ideas\Dissertation\Data\" ;

graph twoway (scatter avgCPIrat92to05 avgimpshr92to05 if _n <= 30, mcolor(red) mlabel(abbrev) mlabsize(vsmall))
   (line predCPIrat92to05all avgimpshr92to05 if _n <= 30, lwidth(medthick))
   (line predCPIrat92to05minT avgimpshr92to05 if _n <= 30, lwidth(medthick) lpattern(dash)),
   /*title("Import share vs. CPI for OECD countries") subtitle("average 1992 to 2005")*/
   xtitle("avg annual imports/GDP") ytitle("avg annual CPI growth rate")
   yscale(range(-0.0031 0.6)) xscale(range(0 1.5))
   xlabel(0(0.3)1.5) ylabel(0(0.2)0.6)
   legend(cols(1) rows(3))
   saving(OECD_impshr_cpi_92to05, replace) ;
cd "c:\Rick\UT Economics\Paper Ideas\Dissertation\OG imperf labor\" ;
graph export OECD_impshr_cpi_92to05.eps, replace ;
! epstopdf OECD_impshr_cpi_92to05.eps ;
cd "c:\Rick\UT Economics\Paper Ideas\Dissertation\Data\" ;

*---------------------------------------------------------------------------- ;
* Plot average M/Y and CPI for 2005 for all OECD ;

reg CPIrat2005 impshr2005 if _n <= 30 ;
predict predCPIrat05all, xb ;
label variable predCPIrat05all "predicted CPI" ;

reg CPIrat2005 impshr2005 if _n <= 30 & abbrev ~= "TUR" ;
predict predCPIrat05minT, xb ;
label variable predCPIrat05minT "pred. CPI minus TUR" ;

reg CPIrat2005 impshr2005 if _n <= 30 & (abbrev == "CAN" | abbrev == "DEU"
   | abbrev == "FRA" | abbrev == "ITA" | abbrev == "JAP" | abbrev == "GBR" | abbrev == "USA") ;
predict predCPIrat05G7, xb ;
label variable predCPIrat05G7 "pred. CPI for G7" ;

graph twoway (scatter CPIrat2005 impshr2005 if _n <= 30, mcolor(red) mlabel(abbrev) mlabsize(vsmall))
   (line predCPIrat05all impshr2005 if _n <= 30, lwidth(medthick))
   (line predCPIrat05minT impshr2005 if _n <= 30, lwidth(medthick) lpattern(dash)),
   /*title("Import share vs. CPI for OECD countries") subtitle("average 1992 to 2005")*/
   xtitle("avg annual imports/GDP") ytitle("avg annual CPI growth rate")
   yscale(range(0 0.1)) xscale(range(0 1.5))
   /* xlabel(1970 "70" 1980 "80" 1990 "90" 2000 "00" 2007 "07") ylabel(0.2(0.4)1.4)
   xmtick(1970(1)2007) xtick(1970(5)2007) ytick(0(0.2)1.4)*/
   legend(cols(1) rows(3))
   saving(OECD_impshr_cpi_05, replace) ;
cd "c:\Rick\UT Economics\Paper Ideas\Dissertation\OG two country\" ;
graph export OECD_impshr_cpi_05.eps, replace ;
! epstopdf OECD_impshr_cpi_05.eps ;
cd "c:\Rick\UT Economics\Paper Ideas\Dissertation\Data\" ;

graph twoway (scatter CPIrat2005 impshr2005 if _n <= 30, mcolor(red) mlabel(abbrev) mlabsize(vsmall))
   (line predCPIrat05all impshr2005 if _n <= 30, lwidth(medthick))
   (line predCPIrat05minT impshr2005 if _n <= 30, lwidth(medthick) lpattern(dash)),
   /*title("Import share vs. CPI for OECD countries") subtitle("average 1992 to 2005")*/
   xtitle("avg annual imports/GDP") ytitle("avg annual CPI growth rate")
   yscale(range(-0.0031 0.6)) xscale(range(0 1.5))
   xlabel(0(0.3)1.5) ylabel(0(0.2)0.6)
   legend(cols(1) rows(3))
   saving(OECD_impshr_cpi_05, replace) ;
cd "c:\Rick\UT Economics\Paper Ideas\Dissertation\OG imperf labor\" ;
graph export OECD_impshr_cpi_05.eps, replace ;
! epstopdf OECD_impshr_cpi_05.eps ;
cd "c:\Rick\UT Economics\Paper Ideas\Dissertation\Data\" ;

*---------------------------------------------------------------------------- ;
* Closing commands ;

log close ;
exit ;