Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    See Bjarte Aagnes's solution from the following thread: https://www.statalist.org/forums/for...-with-coefplot

    Comment


    • #17
      Dear Andrew Musau

      thank you for the very helpful thread. I coded it now like this (following Bjarte):
      Code:
      gen ll=-0.799
      gen ul=-0.34
      gen range = cond(_n==1, _n-.5, _n+.5)    
      coefplot (sector1, aseq("Sector 1")) (sector2, aseq("Sector 2")) ///
              (sector3, aseq("Sector 3") ciopts(color(orange) recast(rcap)) mcolor(orange)) ///
              (sector4, aseq("Sector 4")) ///
              (sector5, aseq("Sector 5")) (sector6, aseq("Sector 6")) (sector7, aseq("Sector 7")) (sector8, aseq("Sector 8")) ///
              (sector9, aseq("Sector 9")) (sector10, aseq("Sector 10")) (sector11, aseq("Sector 11")) ///
                      (sector12, aseq("Sector 12") ciopts(color(orange) recast(rcap)) mcolor(orange)) ///
              (sector13, aseq("Sector 13")) (sector14, aseq("Sector 14")) (sector15, aseq("Sector 15")) (sector16, aseq("Sector 16")) ///
              (sector17, aseq("Sector 17")) ///
              (sector18, aseq("Sector 18") ciopts(color(orange) recast(rcap)) mcolor(orange)) ///
              (sector19, aseq("Sector 19")) (sector20, aseq("Sector 20")) ///
              (sector21, aseq("Sector 21")) (sector22, aseq("Sector 22")) ///
                  (sector23, aseq("Sector 23") ciopts(color(orange) recast(rcap)) mcolor(orange)), ///
               keep(lndistw) ///
               ciopts(recast(rcap) color(blue)) ///
               msymbol(O) mcolor(blue) ///
               ytitle("Coefficient of distance (log)") ///
               xtitle(" ") ///
               yline (-0.57, lcolor(red)) ///
               yline (0, lcolor(black)) ///
               xlabel( , angle(0) labsize(medium)) ///
               vertical aseq swapnames nokey ///
               level(90) ///
               xlab(1/23) xtitle("Sector") ///
               addplot(rarea ll ul range, color(gs8%40)) ///
                    xlabel(1 "11" 2 "21", add custom labcolor(black) labsize(*0.64)) ///
                   xlabel(3 "22", add custom labcolor(orange) labsize(*0.64)) ///
                   xlabel(4 "23" 5 "31" 6 "32" 7 "33" 8 "42" 9 "44" 10 "45" 11 "48", add custom labcolor(black) labsize(*0.64)) ///
                   xlabel(12 "49",  add custom labcolor(orange) labsize(*0.64)) ///
                   xlabel(13 "51" 14 "52" 15 "53" 16 "54" 17 "55",  add custom labcolor(black) labsize(*0.64)) ///
                   xlabel(18 "56",  add custom labcolor(orange) labsize(*0.64)) ///
                   xlabel(19 "61" 20 "62" 21 "71" 22 "72",  add custom labcolor(black) labsize(*0.64)) ///
                   xlabel(23 "81", add custom labcolor(orange) labsize(*0.64))
      drop ll ul range
      Unfortunately it looks like this now:

      Click image for larger version

Name:	stata.png
Views:	1
Size:	148.0 KB
ID:	1768012


      I think this is because of the xlab(1/23) command. When I delete this one, it looks like this, potentially due to the vertical aseq swapnames nokey /// line:

      Click image for larger version

Name:	stata2.png
Views:	1
Size:	154.9 KB
ID:	1768014


      Unfortunately, I am stuck here, so if you can provide any advice, I would be very helpful.

      Best
      Noemi
      Attached Files

      Comment


      • #18
        I can only help you to the extent that you help me with a reproducible example. See FAQ Advice #12 for details.

        Comment


        • #19
          Dear Andrew Musau

          of course, I'm sorry! Here, I have a reproducible example:

          Code:
          use "http://fmwww.bc.edu/RePEc/bocode/e/EXAMPLE_TRADE_FTA_DATA" , clear
          egen imp = group(isoimp)
          egen exp = group(isoexp)
          
          preserve
          keep if category == "MANUF"
          ppmlhdfe trade fta, a(imp#year exp#year imp#exp) cluster(imp#exp)
          estimates save model1, replace
          restore
          
          preserve
          keep if category == "NONMANUF"
          ppmlhdfe trade fta, a(imp#year exp#year imp#exp) cluster(imp#exp)
          estimates save model2, replace
          restore
          
          preserve
          keep if category == "TOTAL"
          ppmlhdfe trade fta, a(imp#year exp#year imp#exp) cluster(imp#exp)
          estimates save model3, replace
          restore
          
          estimates use model1.ster
          estimates store model1
          
          estimates use model2.ster
          estimates store model2
          
          estimates use model3.ster
          estimates store model3
          
          
          
          coefplot (model1, aseq("Sector 1")) (model2, aseq("Sector 2")) ///
                  (model3, aseq("Sector 3") ciopts(color(red) recast(rcap)) mcolor(red) ),  ///
                  keep(fta) ///
                   xline(0) ///
                   ciopts(recast(rcap) color(blue)) ///
                   msymbol(O) mcolor(blue) ///
                   ytitle("Coefficient of lndistw") ///
                   xtitle("") ///
                   xlabel( , angle(0) labsize(medium)) ///
                   vertical aseq swapnames nokey ///
                        xlabel(1 "11", add custom labcolor(black) labsize(*0.64)) ///
                       xlabel(2 "22", add custom labcolor(orange) labsize(*0.64)) ///
                       xlabel(3 "23" , add custom labcolor(black) labsize(*0.64))
          Click image for larger version

Name:	stata3.png
Views:	1
Size:	104.1 KB
ID:	1768054

          Comment


          • #20
            You need:

            Code:
            use "http://fmwww.bc.edu/RePEc/bocode/e/EXAMPLE_TRADE_FTA_DATA" , clear
            egen imp = group(isoimp)
            egen exp = group(isoexp)
            
            preserve
            keep if category == "MANUF"
            ppmlhdfe trade fta, a(imp#year exp#year imp#exp) cluster(imp#exp)
            estimates save model1, replace
            restore
            
            preserve
            keep if category == "NONMANUF"
            ppmlhdfe trade fta, a(imp#year exp#year imp#exp) cluster(imp#exp)
            estimates save model2, replace
            restore
            
            preserve
            keep if category == "TOTAL"
            ppmlhdfe trade fta, a(imp#year exp#year imp#exp) cluster(imp#exp)
            estimates save model3, replace
            restore
            
            estimates use model1.ster
            estimates store model1
            
            estimates use model2.ster
            estimates store model2
            
            estimates use model3.ster
            estimates store model3
            
            
            
            coefplot (model1, aseq("Sector 1")) (model2, aseq("Sector 2")) ///
                    (model3, aseq("Sector 3") ciopts(color(red) recast(rcap)) mcolor(red) ),  ///
                    keep(fta) ///
                     xline(0) ///
                     ciopts(recast(rcap) color(blue)) ///
                     msymbol(O) mcolor(blue) ///
                     ytitle("Coefficient of lndistw") ///
                     xtitle("") ///
                     xlabel(, labcolor(none) angle(0) labsize(medium)) ///
                     vertical aseq swapnames nokey ///
                          xlabel(1 "11", add custom labcolor(black) labsize(*0.64)) ///
                         xlabel(2 "22", add custom labcolor(orange) labsize(*0.64)) ///
                         xlabel(3 "23" , add custom labcolor(black) labsize(*0.64))
            Res.:

            Click image for larger version

Name:	Graph.png
Views:	1
Size:	16.1 KB
ID:	1768066

            Comment

            Working...
            X