Announcement

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

  • fixed effect interaction with many values of FE

    Hi,

    I am trying to run a specification using reghdfe, where I interact a district indicator (uniqueid) with another variable using the specification below. The district variable has ~2500 values, and I have set the maxvar size using stata MP and set empty cells drop, but Stata stops responding every time I run the specification. Is there anyway to estimate this interaction in a way that gets around this?

    Code:
     reghdfe y x##i.uniqueid w z , cluster(uniqueid) a(uniqueid year)

  • #2
    reghdfe is from SSC (as you are asked to explain). Do you need the dummy coefficients of the interaction term? If not, the solution is simple - absorb them.

    Code:
    reghdfe y w z , cluster(uniqueid) a(uniqueid year c.x#i.uniqueid )
    Note that there is no need to include the variable "x" in the regression as it will be collinear with the interaction dummies, i.e., you cannot identify its effect.

    Comment


    • #3
      With just year and uniqueid as panel variables, some would use xtreg:

      xtset uniqueid year
      xtreg y c.x c.x#i.uniqueid i.year , vce(cluster, uniquid) fe

      i.uniqueid drops one of the values (allowing an estimate on x which is essentially the value for the dropped panel).

      Comment


      • #4
        Andrew Musau just a quick question. what if I needed coefficients as well even after absorbing interaction

        Comment


        • #5
          Code:
          reghdfe y w z , cluster(uniqueid) a(uniqueid year c.x#i.uniqueid, savefe)
          will save the estimated fixed effects as variables. Here is an example:


          Code:
          webuse grunfeld, clear
          reghdfe invest mvalue kstock i.year, a(company)
          qui reghdfe invest mvalue kstock, a(company year, savefe)
          sort year
          gen yearcoef= __hdfe2__-__hdfe2__[1]
          tabdisp year, cell(yearcoef)
          Res.:

          Code:
          . reghdfe invest mvalue kstock i.year, a(company)
          (MWFE estimator converged in 1 iterations)
          
          HDFE Linear regression                            Number of obs   =        200
          Absorbing 1 HDFE group                            F(  21,    169) =      31.90
                                                            Prob > F        =     0.0000
                                                            R-squared       =     0.9517
                                                            Adj R-squared   =     0.9431
                                                            Within R-sq.    =     0.7985
                                                            Root MSE        =    51.7245
          
          ------------------------------------------------------------------------------
                invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
                mvalue |   .1177158   .0137513     8.56   0.000     .0905694    .1448623
                kstock |   .3579163    .022719    15.75   0.000     .3130667    .4027659
                       |
                  year |
                 1936  |  -19.19741   23.67586    -0.81   0.419    -65.93593    27.54112
                 1937  |  -40.69001   24.69541    -1.65   0.101    -89.44122    8.061213
                 1938  |   -39.2264   23.23594    -1.69   0.093    -85.09647    6.643667
                 1939  |  -69.47029   23.65607    -2.94   0.004    -116.1698   -22.77083
                 1940  |  -44.23507   23.80979    -1.86   0.065      -91.238     2.76785
                 1941  |  -18.80446     23.694    -0.79   0.429     -65.5788    27.96987
                 1942  |  -21.13979   23.38163    -0.90   0.367    -67.29748    25.01789
                 1943  |  -42.97762   23.55287    -1.82   0.070    -89.47334    3.518104
                 1944  |  -43.09876    23.6102    -1.83   0.070    -89.70766    3.510134
                 1945  |  -55.68303   23.89561    -2.33   0.021    -102.8554   -8.510689
                 1946  |  -31.16928   24.11598    -1.29   0.198    -78.77665    16.43809
                 1947  |  -39.39223   23.78368    -1.66   0.100    -86.34361    7.559141
                 1948  |  -43.71651   23.96965    -1.82   0.070    -91.03501    3.601991
                 1949  |   -73.4951   24.18292    -3.04   0.003    -121.2346   -25.75559
                 1950  |  -75.89611   24.34553    -3.12   0.002    -123.9566    -27.8356
                 1951  |   -62.4809   24.86425    -2.51   0.013    -111.5654   -13.39637
                 1952  |  -64.63233    25.3495    -2.55   0.012    -114.6748   -14.58987
                 1953  |  -67.71796   26.61108    -2.54   0.012    -120.2509   -15.18501
                 1954  |  -93.52622   27.10786    -3.45   0.001    -147.0399   -40.01257
                       |
                 _cons |  -32.83631   18.87533    -1.74   0.084     -70.0981    4.425483
          ------------------------------------------------------------------------------
          
          Absorbed degrees of freedom:
          -----------------------------------------------------+
           Absorbed FE | Categories  - Redundant  = Num. Coefs |
          -------------+---------------------------------------|
               company |        10           0          10     |
          -----------------------------------------------------+
          
          . 
          . qui reghdfe invest mvalue kstock, a(company year, savefe)
          
          . 
          . sort year
          
          . 
          . gen yearcoef= __hdfe2__-__hdfe2__[1]
          
          . 
          . tabdisp year, cell(yearcoef)
          
          ----------------------
               year |   yearcoef
          ----------+-----------
               1935 |          0
               1936 |  -19.19741
               1937 |  -40.69001
               1938 |   -39.2264
               1939 |  -69.47029
               1940 |  -44.23507
               1941 |  -18.80446
               1942 |  -21.13979
               1943 |  -42.97762
               1944 |  -43.09877
               1945 |  -55.68303
               1946 |  -31.16928
               1947 |  -39.39223
               1948 |  -43.71651
               1949 |  -73.49509
               1950 |  -75.89611
               1951 |   -62.4809
               1952 |  -64.63232
               1953 |  -67.71796
               1954 |  -93.52622
          ----------------------
          
          .
          Last edited by Andrew Musau; 17 Aug 2022, 02:26.

          Comment


          • #6
            Hi Andrew Musau,

            I am using the following command for my panel data estimation:

            reghdfe y x1 x2 x3 x4, absorb(bank year bank*year) vce(cluster bank); where I declare my dataset as xtset bank year, yearly.

            Does it make sense if I consider bank, year and their interaction together as fixed effects? Many previous studies drop bank and year individual fixed effects before including their interaction.

            Many thanks for considering my request.


            Kind Regards,
            Woahid

            Comment


            • #7
              I declare my dataset as xtset bank year, yearly.
              If your panel identifier is bank and your time variable is year, then a bank-year is an observation in that dataset. You cannot have fixed effects at the observation level. So you probably want:

              Code:
              reghdfe y x1 x2 x3 x4, absorb(bank year) vce(cluster bank)
              Additionally, no need to create interactions manually. Use factor variables.

              Code:
              help fvvarlist

              Comment

              Working...
              X