Announcement

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

  • Drawing a line between points in coefplot

    Graph.gph

    I have the following graph where I plot the Coefficients of a Difference in Difference analysis (using coefplot). To make the graph look nicer, I would like to draw a line between all red and all blue points respectively. How would I do that?

    I used the following command to plot the graph:

    ```
    *Running the regressions
    reg deal_rate dummy_plus_7 dummy_plus_6 dummy_plus_5 dummy_plus_4 dummy_plus_3 dummy_plus_2 dummy_plus_1 cut_dummy dummy_lag_* if Single_Collateral == 1 , vce(robust)
    estimates store Single

    reg deal_rate dummy_plus_7 dummy_plus_6 dummy_plus_5 dummy_plus_4 dummy_plus_3 dummy_plus_2 dummy_plus_1 cut_dummy dummy_lag_* if Single_Collateral == 0, vce(robust)
    estimates store Pool

    *Plotting the graph
    coefplot Single Pool, vertical drop(_cons) yline(0) xlabel(, angle(90))

    ````
    Attached Files

  • #2
    Reproducible example? coefplot is from SSC. Also note the advice to upload images in PNG format (FAQ Advice #12) .

    Comment


    • #3
      Okay then here we go: I took a random dataset from Stata. The regression does not make any sense but it shows what I want to do with my data.

      The code is:
      ```
      ssc install coefplot

      sysuse emd, clear

      *Creating Random Dummy
      gen dummy = 1 if income_pc > 6000
      replace dummy = 0 if income_pc <= 6000

      *Having two random regressions
      reg ln_income median_age fips hhsize if dummy == 1
      estimates store model1

      reg ln_income median_age fips hhsize if dummy == 0
      estimates store model2

      coefplot model1 model2, vertical drop(_cons) yline(0) xlabel(, angle(90))

      ```

      I want to connect the blue and red points with a line each.

      Comment


      • #4
        And here in picture format
        Attached Files

        Comment


        • #5
          Thanks for the data example. Does this do it?

          Code:
          webuse emd, clear
          
          *Creating Random Dummy
          gen dummy = 1 if income_pc > 6000
          replace dummy = 0 if income_pc <= 6000
          
          *Having two random regressions
          reg ln_income median_age fips hhsize if dummy == 1
          estimates store m1
          
          reg ln_income median_age fips hhsize if dummy == 0
          estimates store m2
          
          coefplot m1 m2 , vert drop(_cons) yline(0) xlab(, angle(90))  recast(connected)
          Click image for larger version

Name:	Graph.png
Views:	1
Size:	26.6 KB
ID:	1676591

          Comment

          Working...
          X