Announcement

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

  • Graphing shaded confidence interval

    Hi

    I am trying to generate a graph that looks like this:


    Click image for larger version

Name:	all 3 controls with year 1980-2021.jpg
Views:	1
Size:	25.0 KB
ID:	1709179


    I have the following command but am unsure how I can modify it to get the above graph to plot my confidence intervals and coefficient.

    Code:
    graph twoway (scatter ATT_coefficient Iterations, yline(0, lc(black) lp(dash) lwidth(thick)) xline(96,
    lc(black) lp(dash) lwidth(thick)) lwidth(thick) lcolor(red)) (rcap ll ul Iterations, lcolor(sand))
    Thank you!

  • #2
    can you be more specific?
    how are you getting the ATT_coeffiient sor the ll ul. Furthermore, what problems are you having

    Comment


    • #3
      hello FernandoRios

      I ran a loop with different values using csdid command and extracted and saved them in a matrix form. So I have ATT coefficient at various iterations. I just want to graph them in a similar way that the csdid_plot gives me but I can't figure out how to.

      Thank you for your response!

      Comment


      • #4
        The graph must come from somewhere -- doesn't the source explain?

        Comment


        • #5
          if you are getting info from multiple CSDID get the r(table) matrix.
          That is mostly what you need.
          Code:
          ssc install frause
          frause mpdta
          csdid lemp lpop, ivar( countyreal) time( year) gvar( first_treat) long2
          estat event
          matrix b=r(table)
          clear
          matrix b=b'
          lbsvmat b
          drop in 1/2
          gen t = -5+_n + (_n>3)
          two rbar b5 b6 t || line b1 t
          This is the basic code. It needs extra work to get the shading colors labels, but this is how you can use the Stored coefficients to get the new figures

          Comment


          • #6
            Nick Cox

            HI

            The graph came from the csdid_plot that I ran for my data set. I want to create the same graph. When I type in csdid_plot after my estimation results, it gives me this kind of plot automatically so I didn't have to enter any specifics. I now want to replicate this graph for another set of results that I have.

            Comment


            • #7
              FernandoRios Thank you so much

              my question actually is more related to altering the opacity of rbar. What can I do to make it more transparent?

              Comment


              • #8
                OK, so look inside the csdid_plot code for details on how the plot was done. I see that FernandoRios is the first author, but you're asked to explain where community-contributed commands you refer to come from, in this case SSC. See FAQ Advice #12.

                Comment


                • #9
                  Thanks for Checking into the program Nick Cox
                  Yes, its from ssc, and Sharma
                  the general code would be like this:

                  Code:
                  two rbar b5 b6 t if t<0, color(%50) pstyle(p1) || rbar b5 b6 t if t>0, color(%50) pstyle(p2) || line b1 t

                  Comment


                  • #10
                    FernandoRios This works great! Thank you so much! I also looked at the graph editor option to see the specification in the csdid_plot to replicate.

                    Comment

                    Working...
                    X