Announcement

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

  • Reghdfe command

    For my master's thesis, I investigate the effect of a closure of cryptomarkets on the number of homicides in U.S. counties through a difference-in-differences regression. I therefore used the reghdfe command in Stata. I want to include a county-fixed effect and a time fixed effect. For the time fixed effect I made a dummy variable (dummy_Time) that equals 1 for the periods after the treatment and 0 for the periods before the treatment (which is the cryptomarket closure). I also made a dummy-variable that equals 1 for counties that are in the treatment group (the group exposed to the treatment) and 0 for the ones in the control group. I also want to account for fixed effects between counties, therefore I have put it in the absorb. Is this correct?

    The model to be estimated is: homicides= dummy_time dummy_group DID
    I used the following code: reghdfe Homicides DummyTime dummygroup DID, absorb(i.CountyCode)

    Thank you in advance for any help!
    Iris
    Last edited by Iris Koppen; 09 Apr 2021, 12:59.

  • #2
    Sounds correct, if DID is the interaction of DummyTime and dummygroup, that is treated group after the treatment.

    Comment


    • #3
      Thank you! I was wondering if account for county fixed effects by: absorb(i.countycode) ?

      Comment


      • #4
        It does not make a difference whether you write absorb(countrycode) or absorb(i.countrycode). The help file says

        absvar Description
        ----------------------------------------------------------------------------------------------------------------------------------------------------
        i.varname categorical variable to be absorbed (the i. prefix is tacit)

        and you can check that the results are the same:

        Code:
        . sysuse auto
        (1978 Automobile Data)
        
        . reghdfe price mpg headroom, absorb(rep)
        (MWFE estimator converged in 1 iterations)
        
        HDFE Linear regression                            Number of obs   =         69
        Absorbing 1 HDFE group                            F(   2,     62) =      10.60
                                                          Prob > F        =     0.0001
                                                          R-squared       =     0.2657
                                                          Adj R-squared   =     0.1946
                                                          Within R-sq.    =     0.2549
                                                          Root MSE        =  2613.7617
        
        ------------------------------------------------------------------------------
               price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
                 mpg |  -297.1542   65.40836    -4.54   0.000    -427.9037   -166.4048
            headroom |  -334.6746   426.4413    -0.78   0.436    -1187.119    517.7695
               _cons |   13476.44    2201.67     6.12   0.000     9075.361    17877.51
        ------------------------------------------------------------------------------
        
        Absorbed degrees of freedom:
        -----------------------------------------------------+
         Absorbed FE | Categories  - Redundant  = Num. Coefs |
        -------------+---------------------------------------|
               rep78 |         5           0           5     |
        -----------------------------------------------------+
        
        . reghdfe price mpg headroom, absorb(i.rep)
        (MWFE estimator converged in 1 iterations)
        
        HDFE Linear regression                            Number of obs   =         69
        Absorbing 1 HDFE group                            F(   2,     62) =      10.60
                                                          Prob > F        =     0.0001
                                                          R-squared       =     0.2657
                                                          Adj R-squared   =     0.1946
                                                          Within R-sq.    =     0.2549
                                                          Root MSE        =  2613.7617
        
        ------------------------------------------------------------------------------
               price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
                 mpg |  -297.1542   65.40836    -4.54   0.000    -427.9037   -166.4048
            headroom |  -334.6746   426.4413    -0.78   0.436    -1187.119    517.7695
               _cons |   13476.44    2201.67     6.12   0.000     9075.361    17877.51
        ------------------------------------------------------------------------------
        
        Absorbed degrees of freedom:
        -----------------------------------------------------+
         Absorbed FE | Categories  - Redundant  = Num. Coefs |
        -------------+---------------------------------------|
               rep78 |         5           0           5     |
        -----------------------------------------------------+

        Comment


        • #5
          Thank you Joro! So what needs to be placed in the absorb() is the variable you want to have fixed effects on?

          Comment


          • #6
            The narrow answer to taking your question literally is Yes, what you "place in the absorb() is the variable you want to have fixed effects on".

            However also placing absorb(i.countrycode) is not a bad guess, and in this case they both work.

            Generally one needs to read the help file for the command and the syntax diagram for the command, because it is up to the person who wrote the command how he programmed the inputs.

            In this case the relevant section of the help file is:

            Absvar Syntax

            absvar Description
            ----------------------------------------------------------------------------------------------------------------------------------------------------
            i.varname categorical variable to be absorbed (the i. prefix is tacit)
            i.var1#i.var2 absorb the interactions of multiple categorical variables
            i.var1#c.var2 absorb heterogeneous slopes, where var2 has a different slope coef. depending on the category of var1
            var1##c.var2 equivalent to "i.var1 i.var1#c.var2", but much faster
            var1##c.(var2 var3) multiple heterogeneous slopes are allowed together. Alternative syntax: var1##(c.var2 c.var3)
            v1#v2#v3##c.(v4 v5) factor operators can be combined
            ----------------------------------------------------------------------------------------------------------------------------------------------------



            Originally posted by Iris Koppen View Post
            Thank you Joro! So what needs to be placed in the absorb() is the variable you want to have fixed effects on?

            Comment

            Working...
            X