Announcement

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

  • #16
    Now should you have a line graph for each wave in a particular by-graph?
    . I have posted the data below. 1st, I want to plot mean income by displacement status for all the wave ( wave goes from 0 to 6). this graph should contain one line for mean income of displaced workers and other line of non-displaced person. Then, I want to plot the mean income by rural status for displaced workers. Like how income of displaced workers change over wave for rural and urban areas.
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long WAVE float displaced long rural float income
    1 0 2 30422.863
    4 0 2 26786.404
    2 0 2  28065.07
    5 0 2  27018.12
    0 0 2 19283.504
    3 0 2  20797.26
    6 0 2  27726.43
    4 1 1 22522.334
    2 1 1  13179.65
    0 1 1  17196.21
    3 1 1 17571.824
    6 1 1     15000
    1 1 2 23686.174
    4 1 2 16711.127
    5 1 2  27955.92
    0 1 2  29033.45
    6 1 2  27726.43
    0 0 2  13708.59
    1 1 1         0
    4 1 1  23582.42
    2 1 1 1608.7517
    5 1 1 12952.664
    0 1 1  17701.98
    3 1 1   11016.6
    6 1 1         0
    1 1 1         0
    4 1 1         0
    2 1 1         0
    5 1 1         0
    0 1 1  9103.876
    3 1 1         0
    6 1 1         0
    1 0 2         .
    4 0 2         .
    0 0 2  32767.17
    6 0 2 19716.574
    1 1 2   6090.73
    4 1 2  9566.573
    2 1 2  5364.809
    5 1 2  8856.247
    0 1 2  9734.009
    3 1 2  8163.368
    6 1 2  7393.715
    1 1 2         0
    4 1 2         0
    2 1 2         0
    5 1 2         0
    0 1 2  54729.95
    3 1 2         0
    6 1 2         0
    1 1 2 12930.771
    4 1 2 10116.385
    2 1 2  8696.105
    5 1 2    7075.6
    0 1 2  26655.48
    3 1 2  8307.677
    6 1 2 10166.358
    5 0 2  16301.72
    0 0 2 17478.453
    6 0 2 18484.287
    1 1 1         .
    4 1 1  5734.343
    5 1 1         .
    0 1 1  5359.365
    1 0 1         .
    0 0 1  3349.603
    0 0 1         .
    1 0 2  33837.39
    4 0 2   56632.6
    5 0 2  49189.82
    0 0 2  26447.07
    3 0 2  48821.57
    6 0 2   65927.3
    0 0 2 22016.266
    1 1 2  5405.428
    4 1 2         0
    2 1 2         0
    5 1 2         0
    0 1 2  10922.39
    3 1 2         0
    6 1 2         0
    1 1 2  8623.723
    4 1 2 15624.082
    2 1 2  8365.341
    5 1 2 17074.277
    0 1 2  17093.03
    3 1 2 12800.214
    6 1 2 18484.287
    2 1 2  10472.64
    5 1 2 22374.174
    0 1 2  30844.33
    3 1 2 17918.514
    6 1 2 17252.002
    2 1 2  5600.174
    5 1 2 17721.934
    0 1 2  27417.18
    3 1 2         0
    6 1 2  9858.287
    1 0 1  6583.279
    4 0 1  6377.551
    end
    label values WAVE WAVE
    label def WAVE 0 "Q3_19", modify
    label def WAVE 1 "Q1_20", modify
    label def WAVE 2 "Q2_20", modify
    label def WAVE 3 "Q3_20", modify
    label def WAVE 4 "Q1_21", modify
    label def WAVE 5 "Q2_21", modify
    label def WAVE 6 "Q3_21", modify
    label values rural rural
    label def rural 1 "RURAL", modify
    label def rural 2 "URBAN", modify
    ------------------ copy up to and including the previous line ------------------

    Click image for larger version

Name:	displacement graph.png
Views:	1
Size:	56.7 KB
ID:	1654078

    Comment


    • #17
      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input long WAVE float displaced long rural float income
      1 0 2 30422.863
      4 0 2 26786.404
      2 0 2  28065.07
      5 0 2  27018.12
      0 0 2 19283.504
      3 0 2  20797.26
      6 0 2  27726.43
      4 1 1 22522.334
      2 1 1  13179.65
      0 1 1  17196.21
      3 1 1 17571.824
      6 1 1     15000
      1 1 2 23686.174
      4 1 2 16711.127
      5 1 2  27955.92
      0 1 2  29033.45
      6 1 2  27726.43
      0 0 2  13708.59
      1 1 1         0
      4 1 1  23582.42
      2 1 1 1608.7517
      5 1 1 12952.664
      0 1 1  17701.98
      3 1 1   11016.6
      6 1 1         0
      1 1 1         0
      4 1 1         0
      2 1 1         0
      5 1 1         0
      0 1 1  9103.876
      3 1 1         0
      6 1 1         0
      1 0 2         .
      4 0 2         .
      0 0 2  32767.17
      6 0 2 19716.574
      1 1 2   6090.73
      4 1 2  9566.573
      2 1 2  5364.809
      5 1 2  8856.247
      0 1 2  9734.009
      3 1 2  8163.368
      6 1 2  7393.715
      1 1 2         0
      4 1 2         0
      2 1 2         0
      5 1 2         0
      0 1 2  54729.95
      3 1 2         0
      6 1 2         0
      1 1 2 12930.771
      4 1 2 10116.385
      2 1 2  8696.105
      5 1 2    7075.6
      0 1 2  26655.48
      3 1 2  8307.677
      6 1 2 10166.358
      5 0 2  16301.72
      0 0 2 17478.453
      6 0 2 18484.287
      1 1 1         .
      4 1 1  5734.343
      5 1 1         .
      0 1 1  5359.365
      1 0 1         .
      0 0 1  3349.603
      0 0 1         .
      1 0 2  33837.39
      4 0 2   56632.6
      5 0 2  49189.82
      0 0 2  26447.07
      3 0 2  48821.57
      6 0 2   65927.3
      0 0 2 22016.266
      1 1 2  5405.428
      4 1 2         0
      2 1 2         0
      5 1 2         0
      0 1 2  10922.39
      3 1 2         0
      6 1 2         0
      1 1 2  8623.723
      4 1 2 15624.082
      2 1 2  8365.341
      5 1 2 17074.277
      0 1 2  17093.03
      3 1 2 12800.214
      6 1 2 18484.287
      2 1 2  10472.64
      5 1 2 22374.174
      0 1 2  30844.33
      3 1 2 17918.514
      6 1 2 17252.002
      2 1 2  5600.174
      5 1 2 17721.934
      0 1 2  27417.18
      3 1 2         0
      6 1 2  9858.287
      1 0 1  6583.279
      4 0 1  6377.551
      end
      label values WAVE WAVE
      label def WAVE 0 "Q3_19", modify
      label def WAVE 1 "Q1_20", modify
      label def WAVE 2 "Q2_20", modify
      label def WAVE 3 "Q3_20", modify
      label def WAVE 4 "Q1_21", modify
      label def WAVE 5 "Q2_21", modify
      label def WAVE 6 "Q3_21", modify
      label values rural rural
      label def rural 1 "RURAL", modify
      label def rural 2 "URBAN", modify
      
      *IN GENERAL, YOU SHOULD USE RESHAPE HERE
      gen which= rural +1
      expand 2, g(new)
      replace which= displaced if new
      
      *LABELS, XTSET & PLOT
      lab def which 0 "non-displaced" 1 "displaced" 2 "Rural" 3 "Urban"
      label values which which
      collapse income, by(WAVE which)
      xtset which WAVE
      set scheme s1mono
      xtline income, overlay xlab(1/6) xtitle("Wave") plot2opts(lp(--)) plot3opts(lp(-.-)) plot4opts(lp(longdash_dot))
      Click image for larger version

Name:	Graph.png
Views:	1
Size:	51.2 KB
ID:	1654168

      Comment


      • #18
        Dear sir,
        I am running fixed effect event regression model. Results are given below. I want to plot the coefficient of interaction term. However, coefficient of displaced is zero. Because of that I am not able to get the margins and marginsplot. I tried coefplot also. It is also not giving me any result.

        Code:
         . xtreg earning i.WAVE##displaced age age2, fe vce(cluster psid)
        note: 1.displaced omitted because of collinearity
        
        Fixed-effects (within) regression               Number of obs     =    131,235
        Group variable: psid                            Number of groups  =     28,632
        
        R-sq:                                           Obs per group:
        within  = 0.1689                                         min =          1
        between = 0.2550                                         avg =        4.6
        overall = 0.2374                                         max =          7
        
        F(14,28631)       =     887.61
        corr(u_i, Xb)  = 0.1609                         Prob > F          =     0.0000
        
        (Std. Err. adjusted for 28,632 clusters in psid)
        
        Robust
        earning       Coef.   Std. Err.      t    P>t     [95% Conf. Interval]
        
        WAVE 
        Q1_20    -788.8036   92.44224    -8.53   0.000    -969.9947   -607.6125
        Q2_20    -2547.133   129.8328   -19.62   0.000    -2801.612   -2292.655
        Q3_20    -2621.068    111.972   -23.41   0.000    -2840.539   -2401.598
        Q1_21    -1810.567   114.4584   -15.82   0.000     -2034.91   -1586.223
        Q2_21    -2740.832   117.5878   -23.31   0.000     -2971.31   -2510.354
        Q3_21    -2784.326   117.7342   -23.65   0.000    -3015.091   -2553.562
        
        1.displaced           0  (omitted)
        
        WAVE#displaced 
        Q1_20#1     -5916.44   146.5836   -40.36   0.000    -6203.751   -5629.129
        Q2_20#1    -7992.828   169.5341   -47.15   0.000    -8325.123   -7660.533
        Q3_20#1    -6210.598   151.5363   -40.98   0.000    -6507.616    -5913.58
        Q1_21#1    -6579.703   154.8131   -42.50   0.000    -6883.144   -6276.262
        Q2_21#1    -6244.414   157.9918   -39.52   0.000    -6554.085   -5934.743
        Q3_21#1    -5381.335    163.267   -32.96   0.000    -5701.346   -5061.324
        
        age    1422.744    76.3388    18.64   0.000     1273.117    1572.372
        age2   -15.74068   .8893274   -17.70   0.000     -17.4838   -13.99756
        _cons   -8108.331   1654.061    -4.90   0.000    -11350.37   -4866.294
        
        sigma_u   8878.7468
        sigma_e   7211.0256
        rho   .60254927   (fraction of variance due to u_i)
        Code:
         coefplot, keep(WAVE#displaced)
        (.: no coefficients found, all dropped, or none kept)
        (nothing to plot)
        Please suggest me how could I get the plot of interaction term?



        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input float(earning displaced) long WAVE int age float age2
        19283.504 0 0 37 1369
        30422.863 0 1 35 1225
         28065.07 0 2 37 1369
         20797.26 0 3 39 1521
        26786.404 0 4 41 1681
         27018.12 0 5 40 1600
         27726.43 0 6 42 1764
         17196.21 1 0 31  961
         13179.65 1 2 31  961
        17571.824 1 3 31  961
        22522.334 1 4 31  961
            15000 1 6 33 1089
         29033.45 1 0 60 3600
        23686.174 1 1 62 3844
        16711.127 1 4 60 3600
         27955.92 1 5 60 3600
         27726.43 1 6 61 3721
         13708.59 0 0 32 1024
         17701.98 1 0 23  529
                0 1 1 21  441
        1608.7517 1 2 22  484
          11016.6 1 3 22  484
         23582.42 1 4 24  576
        12952.664 1 5 26  676
         21253.05 1 6 26  676
         9103.876 1 0 22  484
                0 1 1 20  400
                0 1 2 18  324
                0 1 3 16  256
                0 1 4 18  324
                0 1 5 20  400
                0 1 6 20  400
         32767.17 0 0 42 1764
                . 0 1 42 1764
                . 0 4 44 1936
        19716.574 0 6 46 2116
         9734.009 1 0 40 1600
          6090.73 1 1 42 1764
         5364.809 1 2 42 1764
         8163.368 1 3 42 1764
         9566.573 1 4 42 1764
         8856.247 1 5 42 1764
         7393.715 1 6 42 1764
         54729.95 1 0 56 3136
                0 1 1 56 3136
         48470.15 1 2 56 3136
         42889.97 1 3 56 3136
         54849.15 1 4 56 3136
         56215.73 1 5 56 3136
         57917.44 1 6 56 3136
         26655.48 1 0 48 2304
        12930.771 1 1 50 2500
         8696.105 1 2 50 2500
         8307.677 1 3 50 2500
        10116.385 1 4 52 2704
           7075.6 1 5 52 2704
        10166.358 1 6 52 2704
        17478.453 0 0 55 3025
         16301.72 0 5 55 3025
        18484.287 0 6 55 3025
         5359.365 1 0 35 1225
                . 1 1 35 1225
         5734.343 1 4 35 1225
                . 1 5 35 1225
         3349.603 0 0 30  900
                . 0 1 28  784
                . 0 0 25  625
         26447.07 0 0 45 2025
         33837.39 0 1 45 2025
         48821.57 0 3 45 2025
          56632.6 0 4 44 1936
         49189.82 0 5 44 1936
          65927.3 0 6 44 1936
        22016.266 0 0 45 2025
         10922.39 1 0 56 3136
         5405.428 1 1 57 3249
        11175.128 1 2 58 3364
        11523.492 1 3 59 3481
         11799.28 1 4 58 3364
         9048.236 1 5 58 3364
         6839.187 1 6 57 3249
         17093.03 1 0 44 1936
         8623.723 1 1 43 1849
         8365.341 1 2 43 1849
        12800.214 1 3 43 1849
        15624.082 1 4 44 1936
        17074.277 1 5 46 2116
        18484.287 1 6 48 2304
         30844.33 1 0 37 1369
          5236.32 1 2 35 1225
        17918.514 1 3 35 1225
        22374.174 1 5 35 1225
         8626.001 1 6 37 1369
         27417.18 1 0 27  729
         2800.087 1 2 29  841
                0 1 3 28  784
        17721.934 1 5 30  900
         4929.144 1 6 32 1024
         6886.663 0 0 35 1225
         6583.279 0 1 35 1225
        end
        label values WAVE WAVE
        label def WAVE 0 "Q3_19", modify
        label def WAVE 1 "Q1_20", modify
        label def WAVE 2 "Q2_20", modify
        label def WAVE 3 "Q3_20", modify
        label def WAVE 4 "Q1_21", modify
        label def WAVE 5 "Q2_21", modify
        label def WAVE 6 "Q3_21", modify
        ------------------ copy up to and including the previous line ------------------

        Listed 100 out of 141772 observations
        Use the count() option to list more

        Comment


        • #19
          Use -coeflegend- option when running your regression command to see how Stata names the coefficients.

          Code:
          xtreg earning i.WAVE##displaced age age2, fe vce(cluster psid) coeflegend
          Res.:

          Code:
          WAVE#displaced |
                Q1_20#1  |  -20329.81  _b[1.WAVE#1.displaced]
                Q2_20#1  |  -9452.594  _b[2.WAVE#1.displaced]
                Q3_20#1  |   -22868.5  _b[3.WAVE#1.displaced]
                Q1_21#1  |  -27743.88  _b[4.WAVE#1.displaced]
                Q2_21#1  |  -18437.67  _b[5.WAVE#1.displaced]
                Q3_21#1  |  -19693.51  _b[6.WAVE#1.displaced]
          This suggests use of the wildcards

          Code:
          ooefplot, keep(*WAVE#*displaced)
          Click image for larger version

Name:	Graph.png
Views:	1
Size:	36.9 KB
ID:	1655170


          Comment


          • #20
            Thank you very much Andrew.

            Comment


            • #21
              Dear sir,
              I am using the Coefplot command as given below:
              xtreg logarning displaced##ib(0).WAVE age age2 if edu_cat19==0 , fe vce(cluster psid)
              estimates store m1, title(Upto Primary)
              xtreg logarning displaced##ib(0).WAVE age age2 if edu_cat19==1 , fe vce(cluster psid)
              estimates store m2, title(Secondary)
              coefplot (m1, label("Upto Primary Education") lp(solid) mcolor(black) msymbol(smx) lc(black) ciopts(color(black))) ///
              (m2, label("Secondary Education") lp(--) mcolor(balck) msymbol(smx) lc(black) ciopts(color(black))) ///
              , keep(*displaced#*WAVE) graphregion(color(white)) bgcolor(white) recast(connected) xlab(0/6) xtitle("Waves") ytitle("log earnings") vertical
              In the below graph, for a specific wave, why the points are shifted and not on the top of one another for different education categories ?



              Click image for larger version

Name:	stata_edu_cat.png
Views:	1
Size:	51.5 KB
ID:	1656201


              Comment


              • #22
                Most probably the points coincide. Look at fabplot from the Stata Journal by Nick Cox for an alternative presentation. An example is here: https://www.statalist.org/forums/for...s-of-countries

                Comment

                Working...
                X