Guest User

Untitled

a guest
Dec 16th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.06 KB | None | 0 0
  1. ssc install synth
  2. ipolate educ year, gen(educ2) epolate by(countrycode)
  3. clear
  4.  
  5. cd "C:\Users\Mandlenkosi Sibanda\Documents\Synth2"
  6. use "data\sanctions.dta"
  7. tsset countrycode year, year
  8.  
  9. #delimit;
  10.  
  11. synth gdp
  12. fdi(1997) gdp(1990) gdp(1999) inflation(1997) educ2(1998) trade2(1999)
  13. ,
  14. trunit(40) trperiod(2001) unitnames(country)
  15. mspeperiod(1990(1)2001) resultsperiod(1990(1)2017)
  16. keep(data\synth\synth_sanctions.dta) replace fig;
  17.  
  18. mat list e(V_matrix);
  19. #delimit cr
  20.  
  21.  
  22. * Plot the gap in predicted error
  23. use data\synth\synth_sanctions.dta, clear
  24. keep _Y_treated _Y_synthetic _time
  25. drop if _time==.
  26. rename _time year
  27. rename _Y_treated treat
  28. rename _Y_synthetic counterfact
  29. gen gap40=treat-counterfact
  30. sort year
  31. twoway (line gap40 year,lp(solid)lw(vthin)lcolor(black)), yline(0, lpattern(shortdash) lcolor(black)) xline(2001, lpattern(shortdash) lcolor(black)) xtitle("",si(medsmall)) xlabel(#10) ytitle("Gap in GDP prediction error", size(medsmall)) legend(off)
  32. save data\synth\synth_sanctions_40.dta, replace
  33.  
  34.  
  35. * Placebo test
  36. clear
  37. use "data\sanctions.dta"
  38. tsset countrycode year, year
  39.  
  40. #delimit;
  41. set more off;
  42.  
  43. local countrycode 1 2 3 4 6 7 8 9 10 11 13 15 16 17 18 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40;
  44.  
  45. foreach i of local countrycode {;
  46.  
  47. synth gdp
  48. fdi(1997) gdp(1990) gdp(1999) inflation(1997) educ2(1998) trade2(1999)
  49. ,
  50. trunit(`i') trperiod(2001)
  51. mspeperiod(1990(1)2001) resultsperiod(1990(1)2009)
  52. keep(data\synth\synth_sanctions_`i'.dta) replace;
  53. matrix country`i' = e(RMSPE); /* check the V matrix*/
  54. };
  55.  
  56.  
  57. foreach i of local countrycode {;
  58. matrix rownames country`i'=`i';
  59. matlist country`i', names(rows);
  60. };
  61.  
  62. #delimit cr
  63.  
  64.  
  65. local countrycode 1 2 3 4 6 7 8 9 10 11 13 15 16 17 18 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
  66.  
  67. foreach i of local countrycode {
  68. use data\synth\synth_sanctions_`i' ,clear
  69. keep _Y_treated _Y_synthetic _time
  70. drop if _time==.
  71. rename _time year
  72. rename _Y_treated treat`i'
  73. rename _Y_synthetic counterfact`i'
  74. gen gap`i'=treat`i'-counterfact`i'
  75. sort year
  76. save data\synth\synth_gap_sanctions`i'.dta, replace
  77. }
  78.  
  79. use data\synth\synth_gap_sanctions40.dta, clear
  80. sort year
  81. save data\synth\placebo_sanctions40.dta, replace
  82.  
  83. foreach i of local countrycode {
  84.  
  85. merge year using data\synth\synth_gap_sanctions`i'
  86. drop _merge
  87. sort year
  88.  
  89. save data\synth\placebo_sanctions.dta, replace
  90. }
  91.  
  92. * All the placeboes on the same picture
  93. use data\synth\placebo_sanctions.dta, replace
  94.  
  95. * Picture of the full sample, including outlier RSMPE
  96. #delimit;
  97.  
  98. twoway
  99. (line gap1 year ,lp(solid)lw(vthin))
  100. (line gap2 year ,lp(solid)lw(vthin))
  101. (line gap4 year ,lp(solid)lw(vthin))
  102. (line gap6 year ,lp(solid)lw(vthin))
  103. (line gap8 year ,lp(solid)lw(vthin))
  104. (line gap9 year ,lp(solid)lw(vthin))
  105. (line gap10 year ,lp(solid)lw(vthin))
  106. (line gap11 year ,lp(solid)lw(vthin))
  107. (line gap13 year ,lp(solid)lw(vthin))
  108. (line gap15 year ,lp(solid)lw(vthin))
  109. (line gap16 year ,lp(solid)lw(vthin))
  110. (line gap17 year ,lp(solid)lw(vthin))
  111. (line gap18 year ,lp(solid)lw(vthin))
  112. (line gap20 year ,lp(solid)lw(vthin))
  113. (line gap21 year ,lp(solid)lw(vthin))
  114. (line gap22 year ,lp(solid)lw(vthin))
  115. (line gap23 year ,lp(solid)lw(vthin))
  116. (line gap24 year ,lp(solid)lw(vthin))
  117. (line gap25 year ,lp(solid)lw(vthin))
  118. (line gap26 year ,lp(solid)lw(vthin))
  119. (line gap27 year ,lp(solid)lw(vthin))
  120. (line gap28 year ,lp(solid)lw(vthin))
  121. (line gap29 year ,lp(solid)lw(vthin))
  122. (line gap30 year ,lp(solid)lw(vthin))
  123. (line gap31 year ,lp(solid)lw(vthin))
  124. (line gap32 year ,lp(solid)lw(vthin))
  125. (line gap33 year ,lp(solid)lw(vthin))
  126. (line gap34 year ,lp(solid)lw(vthin))
  127. (line gap35 year ,lp(solid)lw(vthin))
  128. (line gap36 year ,lp(solid)lw(vthin))
  129. (line gap37 year ,lp(solid)lw(vthin))
  130. (line gap38 year ,lp(solid)lw(vthin))
  131. (line gap39 year ,lp(solid)lw(vthin))
  132. (line gap40 year ,lp(solid)lw(thick)lcolor(black)), /*treatment unit, Zimbabwe*/
  133. yline(0, lpattern(shortdash) lcolor(black)) xline(2001, lpattern(shortdash) lcolor(black))
  134. xtitle("",si(small)) xlabel(#10) ytitle("Gap in GDP per capita prediction error", size(small))
  135. legend(off);
  136.  
  137. #delimit cr
Add Comment
Please, Sign In to add comment