Announcement

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

  • Factor variable question

    Hello,

    I am trying to do a coefficient plot. The simple regression is:

    Code:
     eststo m: reghdfe cons ib1997.year##c.Treatment X, absorb(i.var1 i.var2)
    coefplot m, keep(*year#*) vert
    However, my baseline period should be 1994-1997. Is there a way to specify as the baseline year more than one year? Thank you.

  • #2
    Ema:
    probably the simplest way is starting from:
    Code:
    gen new_wave=1 if year<=1997
    and then reclassifying the following years accordingly via -replace-.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Originally posted by Carlo Lazzaro View Post
      Ema:
      probably the simplest way is starting from:
      Code:
      gen new_wave=1 if year<=1997
      and then reclassifying the following years accordingly via -replace-.
      Thank you very much, Carlo!

      Comment


      • #4
        Another possibility is to use the omissions operator. See

        Code:
        help fvvarlist
        Code:
        webuse grunfeld, clear
        *OMIT 1950-1952
        xtreg invest mvalue kstock ib1950.year o1951.year o1952.year, fe
        Res.:

        Code:
        . xtreg invest mvalue kstock ib1950.year o1951.year o1952.year, fe
        
        Fixed-effects (within) regression               Number of obs     =        200
        Group variable: company                         Number of groups  =         10
        
        R-sq:                                           Obs per group:
             within  = 0.7981                                         min =         20
             between = 0.8151                                         avg =       20.0
             overall = 0.8069                                         max =         20
        
                                                        F(19,171)         =      35.57
        corr(u_i, Xb)  = -0.3396                        Prob > F          =     0.0000
        
        ------------------------------------------------------------------------------
              invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
              mvalue |   .1190015   .0135188     8.80   0.000     .0923163    .1456867
              kstock |   .3579224   .0225819    15.85   0.000     .3133471    .4024976
                     |
                year |
               1935  |   68.23652   20.76802     3.29   0.001     27.24182    109.2312
               1936  |   48.56065   20.43599     2.38   0.019     8.221357    88.89994
               1937  |   26.71726   20.76167     1.29   0.200    -14.26491    67.69943
               1938  |   28.83008   19.98559     1.44   0.151    -10.62015    68.28031
               1939  |  -1.713604   19.79239    -0.09   0.931    -40.78248    37.35527
               1940  |   23.45247   19.81807     1.18   0.238    -15.66708    62.57203
               1941  |    48.9422   19.65333     2.49   0.014     10.14784    87.73657
               1942  |   46.87297   19.57677     2.39   0.018     8.229717    85.51622
               1943  |   24.88811   19.42455     1.28   0.202    -13.45467    63.23089
               1944  |   24.72505   19.42574     1.27   0.205    -13.62007    63.07017
               1945  |   11.99632   19.43475     0.62   0.538     -26.3666    50.35923
               1946  |   36.42788   19.43034     1.87   0.063     -1.92632    74.78208
               1947  |   28.56017   19.12425     1.49   0.137    -9.189846    66.31019
               1948  |   24.27462   19.10048     1.27   0.205    -13.42846     61.9777
               1949  |  -5.530632   19.03164    -0.29   0.772    -43.09783    32.03657
               1951  |          0  (omitted)
               1952  |          0  (omitted)
               1953  |  -.4748497   19.33956    -0.02   0.980    -38.64986    37.70016
               1954  |  -26.23238   19.48787    -1.35   0.180    -64.70014    12.23538
                     |
               _cons |  -101.9828   18.35087    -5.56   0.000    -138.2062   -65.75936
        -------------+----------------------------------------------------------------
             sigma_u |  92.216992
             sigma_e |  51.478662
                 rho |   .7624129   (fraction of variance due to u_i)
        ------------------------------------------------------------------------------
        F test that all u_i=0: F(9, 171) = 52.94                     Prob > F = 0.0000

        Comment


        • #5
          Originally posted by Andrew Musau View Post
          Another possibility is to use the omissions operator. See

          Code:
          help fvvarlist
          Code:
          webuse grunfeld, clear
          *OMIT 1950-1952
          xtreg invest mvalue kstock ib1950.year o1951.year o1952.year, fe
          Res.:

          Code:
          . xtreg invest mvalue kstock ib1950.year o1951.year o1952.year, fe
          
          Fixed-effects (within) regression Number of obs = 200
          Group variable: company Number of groups = 10
          
          R-sq: Obs per group:
          within = 0.7981 min = 20
          between = 0.8151 avg = 20.0
          overall = 0.8069 max = 20
          
          F(19,171) = 35.57
          corr(u_i, Xb) = -0.3396 Prob > F = 0.0000
          
          ------------------------------------------------------------------------------
          invest | Coef. Std. Err. t P>|t| [95% Conf. Interval]
          -------------+----------------------------------------------------------------
          mvalue | .1190015 .0135188 8.80 0.000 .0923163 .1456867
          kstock | .3579224 .0225819 15.85 0.000 .3133471 .4024976
          |
          year |
          1935 | 68.23652 20.76802 3.29 0.001 27.24182 109.2312
          1936 | 48.56065 20.43599 2.38 0.019 8.221357 88.89994
          1937 | 26.71726 20.76167 1.29 0.200 -14.26491 67.69943
          1938 | 28.83008 19.98559 1.44 0.151 -10.62015 68.28031
          1939 | -1.713604 19.79239 -0.09 0.931 -40.78248 37.35527
          1940 | 23.45247 19.81807 1.18 0.238 -15.66708 62.57203
          1941 | 48.9422 19.65333 2.49 0.014 10.14784 87.73657
          1942 | 46.87297 19.57677 2.39 0.018 8.229717 85.51622
          1943 | 24.88811 19.42455 1.28 0.202 -13.45467 63.23089
          1944 | 24.72505 19.42574 1.27 0.205 -13.62007 63.07017
          1945 | 11.99632 19.43475 0.62 0.538 -26.3666 50.35923
          1946 | 36.42788 19.43034 1.87 0.063 -1.92632 74.78208
          1947 | 28.56017 19.12425 1.49 0.137 -9.189846 66.31019
          1948 | 24.27462 19.10048 1.27 0.205 -13.42846 61.9777
          1949 | -5.530632 19.03164 -0.29 0.772 -43.09783 32.03657
          1951 | 0 (omitted)
          1952 | 0 (omitted)
          1953 | -.4748497 19.33956 -0.02 0.980 -38.64986 37.70016
          1954 | -26.23238 19.48787 -1.35 0.180 -64.70014 12.23538
          |
          _cons | -101.9828 18.35087 -5.56 0.000 -138.2062 -65.75936
          -------------+----------------------------------------------------------------
          sigma_u | 92.216992
          sigma_e | 51.478662
          rho | .7624129 (fraction of variance due to u_i)
          ------------------------------------------------------------------------------
          F test that all u_i=0: F(9, 171) = 52.94 Prob > F = 0.0000
          Thank you, Andrew! But, in this case, if I run the following:
          Code:
          reghdfe cons io(1994 1995 1996 1997).year##c.Treatment X, absorb(i.var1 i.var2)
          will only 1994 be considered as the control period?

          Code:
          cons | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
          --------------------+----------------------------------------------------------------
                         year |
                        1995  |  -.0418246   .0306833    -1.36   0.173    -.1019635    .0183142
                        1996  |  -.0024095   .0318186    -0.08   0.940    -.0647735    .0599544
                        1997  |   .0073645   .0311169     0.24   0.813    -.0536242    .0683533
                        1998  |   .0471531   .0323903     1.46   0.145    -.0163314    .1106377
                        1999  |   .0861303   .0310884     2.77   0.006     .0251975    .1470631
                        2000  |   .1240435   .0323347     3.84   0.000      .060668     .187419
                        2001  |   .1360961    .029535     4.61   0.000     .0782078    .1939843
                        2002  |    .150825   .0299085     5.04   0.000     .0922047    .2094453
                        2003  |   .0877611      .0295     2.97   0.003     .0299415    .1455807
                        2004  |   .1191502   .0297324     4.01   0.000     .0608751    .1774253
                        2005  |   .1802079   .0301286     5.98   0.000     .1211563    .2392596
                        2006  |   .1843179   .0307819     5.99   0.000     .1239858      .24465
                        2007  |    .144096   .0300586     4.79   0.000     .0851814    .2030105
                        2008  |   .1426111   .0303837     4.69   0.000     .0830596    .2021627
                        2009  |    .119994   .0296087     4.05   0.000     .0619615    .1780266
                        2010  |   .1076873   .0298239     3.61   0.000     .0492328    .1661418
                        2011  |   .1545632   .0297881     5.19   0.000      .096179    .2129475
                        2012  |   .1306673   .0302573     4.32   0.000     .0713634    .1899713
                        2013  |   .1543471   .0301624     5.12   0.000     .0952292    .2134649
                        2014  |   .1717409   .0303895     5.65   0.000      .112178    .2313038
                        2015  |   .2087413   .0335709     6.22   0.000     .1429429    .2745398
                        2016  |   .2262304   .0322334     7.02   0.000     .1630534    .2894073
                        2017  |   .2309591   .0332754     6.94   0.000     .1657399    .2961783
                        2018  |   .1065833   .0432057     2.47   0.014     .0219008    .1912658
                              |
                Treatment |   -.098335   .0303575    -3.24   0.001    -.1578353   -.0388346
                              |
          year#c.Treatment |
                        1995  |   .0361356   .0399952     0.90   0.366    -.0422544    .1145256
                        1996  |   .0047749   .0408649     0.12   0.907    -.0753197    .0848695
                        1997  |   .0150391    .040305     0.37   0.709    -.0639581    .0940363
                        1998  |   .0001122   .0410946     0.00   0.998    -.0804327     .080657
                        1999  |  -.0200371   .0398878    -0.50   0.615    -.0982167    .0581425
                        2000  |  -.0029137   .0412349    -0.07   0.944    -.0837335    .0779062
                        2001  |   .3168738   .0383318     8.27   0.000     .2417439    .3920036
                        2002  |   .3432739   .0378454     9.07   0.000     .2690974    .4174504
                        2003  |    .285272   .0379893     7.51   0.000     .2108135    .3597304
                        2004  |   .3308906   .0380806     8.69   0.000     .2562532    .4055281
                        2005  |   .3237228   .0384378     8.42   0.000     .2483851    .3990604
                        2006  |   .3869605   .0393964     9.82   0.000     .3097441     .464177
                        2007  |   .4384216   .0392285    11.18   0.000     .3615343     .515309
                        2008  |   .4381863   .0399101    10.98   0.000      .359963    .5164095
                        2009  |   .3669527   .0390612     9.39   0.000     .2903932    .4435122
                        2010  |   .4329885   .0396025    10.93   0.000     .3553682    .5106089
                        2011  |   .3626566   .0387714     9.35   0.000     .2866653     .438648
                        2012  |   .2692198   .0397264     6.78   0.000     .1913567     .347083
                        2013  |   .2780833   .0402569     6.91   0.000     .1991804    .3569862
                        2014  |   .2727495   .0410175     6.65   0.000     .1923557    .3531432
                        2015  |   .2405152   .0450115     5.34   0.000     .1522934     .328737
                        2016  |   .2106162   .0419468     5.02   0.000     .1284011    .2928313
                        2017  |   .2307915   .0430275     5.36   0.000     .1464583    .3151247
                        2018  |   .2578779   .0594559     4.34   0.000     .1413453    .3744105
                              |
                         age   |   .0033892   .0002724    12.44   0.000     .0028553    .0039232
                     gender  |   .4005027   .0062808    63.77   0.000     .3881923     .412813
                       _cons |    5.78063   .0284114   203.46   0.000     5.724944    5.836316
          -------------------------------------------------------------------------------------

          Comment


          • #6
            Code:
            reghdfe cons o(1994 1995 1996 1997).year##co.Treatment o(1994 1995 1996 1997).year X, absorb(i.var1 i.var2)

            Comment

            Working...
            X