Announcement

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

  • coefplot with different regressors

    Hi all,

    I am running 2 regressions of income growth on a set of dummies capturing which income bin individuals belong to at the start of that period. For instance, delta_inc_X is growth in income in period X, and inc_X_dummy_Y is a dummy for being in income bin Y in period X.

    I run the two regressions below, and plot with coefplot:

    Code:
    reg delta_inc_1 inc_1_dummy_1-inc_1_dummy_10
    estimates store PERIOD1
    
    reg delta_inc_2 inc_2_dummy_1-inc_2_dummy_10
    estimates store PERIOD1
    
    coefplot(PERIOD1) (PERIOD2), vertical xlabel(0) noci
    Click image for larger version

Name:	Old.PNG
Views:	1
Size:	23.2 KB
ID:	1750973



    I would like to get something like this (crudely photoshopped) in order to more easily compare them, as the actual income bins are the same in the two periods:
    Click image for larger version

Name:	New.PNG
Views:	1
Size:	23.8 KB
ID:	1750974



    However, since the independent variables have different names (I presume), coefplot cannot do this on its own. Is there any hopefully simple way to accomplish this?

  • #2
    coefplot is from SSC (FAQ Advice #12). Provide a data example.

    Comment


    • #3
      Example data:

      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input byte id float delta_inc_1 int(inc_1 inc_1_bin) float delta_inc_2 int(inc_2 inc_2_bin)
       1  312.2421 530  500  663.9331 887  900
       2  111.9108 642  600  345.6753 944  900
       3  517.9137 784  800  255.2613 745  700
       4 211.80515 216  200 420.84985 867  900
       5  452.8405 971 1000   629.835 842  800
       6 289.84222 305  300 251.58385 260  300
       7  488.1814 751  800 112.28683 493  500
       8  736.3892 773  800 459.17685 640  600
       9  450.9423 887  900 224.62064 246  200
      10 145.21048 514  500 134.07838 991 1000
      end
      Then need some extra code to generate the dummies:

      Code:
      tab inc_1_bin, gen(inc_1_dummy_)
      tab inc_2_bin, gen(inc_2_dummy_)
      Please let me know if there is anything else I can do.

      Comment


      • #4
        Code:
        * Example generated by -dataex-. For more info, type help dataex
        clear
        input byte id float delta_inc_1 int(inc_1 inc_1_bin) float delta_inc_2 int(inc_2 inc_2_bin)
         1  312.2421 530  500  663.9331 887  900
         2  111.9108 642  600  345.6753 944  900
         3  517.9137 784  800  255.2613 745  700
         4 211.80515 216  200 420.84985 867  900
         5  452.8405 971 1000   629.835 842  800
         6 289.84222 305  300 251.58385 260  300
         7  488.1814 751  800 112.28683 493  500
         8  736.3892 773  800 459.17685 640  600
         9  450.9423 887  900 224.62064 246  200
        10 145.21048 514  500 134.07838 991 1000
        end
        
        reshape long delta_inc_ inc_ inc_@_bin, i(id) j(which)
        reg delta_inc_ i.inc__bin if which==1
        estimates store PERIOD1
        reg delta_inc_ i.inc__bin if which==2
        estimates store PERIOD2
        coefplot(PERIOD1) (PERIOD2), vertical xlabel(0) noci
        Res.:

        Click image for larger version

Name:	Graph.png
Views:	1
Size:	17.8 KB
ID:	1750984

        Comment


        • #5
          Can confirm this works great! Thank you so much for the help Andrew!

          Click image for larger version

Name:	works.PNG
Views:	1
Size:	66.4 KB
ID:	1751125

          Comment

          Working...
          X