Announcement

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

  • reghdfe vs. xtreg different coefficients

    Dear Statlist Community,

    I have a panel data set with daily trading data for 4730 different firms (identified by a variable permno) over a 5 year time horizon (1993 - 1997). I'm using current Stata version 15.1 and want to run regressions with yearly time fixed effects and firm fixed effects taking into account different cluster options. My data is xtset by xtset permno date, where date is variable containing the date from 04jan1993 to 31may1997.

    I discovered that xtreg only allows for one dimensional clustering, while the reghdfe command also allows for multi-way clustering. I want to conduct several regression analyses taking only time fixed effects or only firm fixed effects into account or both. I tested both the xtreg command (clustering over firms) and the reghdfe command (clustering over both firms and years).

    My dependent variable is trades, covering the number of daily trades, and my major independent variable is a dummy variable called postEDGAR, that equals zero for a certain time from 04jan1993 on and switches to 1 at a certain point in time, depending on the firm.

    I run xtreg and reghdfe in the following versions:

    Code:
    // 1: Regression with Time Fixed Effects / Clustering: Firms
    xtreg trades postEDGAR i.year, vce(cluster permno)
    
    // 2: Regression with Firm Fixed Effects / Clustering: Firms
    xtreg trades postEDGAR, fe vce(cluster permno)
    
    // 3: Regression with both Time and Firm Fixed Effects / Clustering: Firms
    xtreg trades postEDGAR i.year, fe vce(cluster permno)
    
    // 4: Regression with Time Fixed Effects / Clustering: Firms and Year
    reghdfe trades postEDGAR, absorb(year) vce(cluster permno year)
    
    // 5: Regression with Firm Fixed Effects / Clustering: Firms and Year
    reghdfe trades postEDGAR, absorb(permno) vce(cluster permno year)
    
    // 6: Regression with both Time and Firm Fixed Effects / Clustering: Firms and Year
    reghdfe trades postEDGAR, absorb(year permno) vce(cluster permno year)
    In general I thought that the xtreg and reghdfe regressions 1&4, 2&5 and 3&6 should have the same coefficients for my independent variable postEDGAR (they are done with only time fixed effects via year dummies (1&4), only firm fixed effects via the permno variable (2&5) and with both time and firm fixed effects via year dummies and permno (3&6)) and that only standard errors and respective t-values should be different due to the difference in one-dimensional and two-dimensional clustering.

    However, I find that the regression coefficients in regression 1&4 (only Time Fixed Effects) are different, while for regressions 2&5 (only Firm Fixed Effects) and 3&6 (both Time and Firm Fixed Effects) they are identical. Attached you can find an Excel File with the regression Output from my described regressions.


    What is the reason for that? I cannot find a mistake in my regression specifications, but probably I'm lacking some thoughts.
    I read in the help of reghdfe that each cluster variable should have at least 50 different categories. Does the described problem arise due to the low number of different categories for the cluster variable year (only 5 categories)? But why are then the coefficients in regression 3&6 identical?

    Any help, suggestions, explanations are highly appreciated!

    I thank you very much in advance!!!

    Best regards
    Phil
    Attached Files
    Last edited by Philipp Rossmanith; 11 Apr 2018, 02:06.

  • #2
    You forgot the *fe* in regression 1 I think?

    Comment


    • #3
      Hey Jesse,

      thank you very much for your quick reply.

      However just adding the *fe* in regression 1 and so running
      Code:
      xtreg trades postEDGAR i.year, fe vce(cluster permno)
      would give me the same results as in regression 3 (naturally as both commands are then identical). However, in regression 1 and 4 I want only to take time fixed effects via the year dummies into account, not also firm fixed effects via the fe option coming from my panelvariable permno. This is what I later do in regressions 3 and 6, where however the resulting coefficients are identical, as expected. So the problem arises only when only using time fixed effects. Best Philipp

      Comment


      • #4
        So the problem arises only when only using time fixed effects.
        What you are estimating in 1 is a random effects model with time dummies (not fixed effects). You have already specified permno as your panel identifier, so you need to change this to get what you want. Therefore, xtset your data with year as the panel variable

        Code:
        xtset, clear
        *Year fixed effects
        xtset year permno
        xtreg trades postEDGAR, fe
        *LSDV
        reg trades postEDGAR i.year

        Comment


        • #5
          Originally posted by Philipp Rossmanith View Post
          Hey Jesse,

          thank you very much for your quick reply.

          However just adding the *fe* in regression 1 and so running
          Code:
          xtreg trades postEDGAR i.year, fe vce(cluster permno)
          would give me the same results as in regression 3 (naturally as both commands are then identical). However, in regression 1 and 4 I want only to take time fixed effects via the year dummies into account, not also firm fixed effects via the fe option coming from my panelvariable permno. This is what I later do in regressions 3 and 6, where however the resulting coefficients are identical, as expected. So the problem arises only when only using time fixed effects. Best Philipp
          The default for xtreg is to use random effects, you need to use reg ... instead of xtreg to get just the time dummies. (Or swap your panel and time indicator as Andrew suggested)

          Comment


          • #6
            Thanks Andrew for your quick reply and the code provided in #4.

            You are totally right about my regression in 1. Diving a little bit deeper into help xtreg I found that (without specifying ,fe) the default option for running xtreg is a random effect model. So as you mentioned the regression in 1 does not include time fixed effects, but it uses random effects with year dummies.

            I have just one short follow up question regarding your code:

            Both your specified regressions
            Code:
            *Year fixed effects
            xtreg trades postEDGAR, fe
            *LSDV
            reg trades postEDGAR i.year
            lead to the same coefficiets after having xtset the data by xtset year (xtset year permno is not allowed as this leads to repeated time values within my data).
            Furthermore those coefficients are identical to the one I receive from regression 4, where I use reghdfe with two dimensional clustering by
            Code:
            reghdfe trades postEDGAR, absorb(year) vce(cluster permno year)
            So this solves exactly my described problem.

            Am I right to assume now that I have now three different possibilities to run a regression with ONLY TIME FIXED EFFECTS with one dimensional clustering by permno?

            Code:
            //1: Change panel identifier to year instead of permno and run xtreg
            xtset year
            xtreg trades postEDGAR, fe vce(cluster permno) 
            
            //2: Leave xtset permno date as it is and run normal regression with year dummies
            reg trades postEDGAR i.year, vce(cluster permno)
            
            //3: Leave xtset permno date as it is and run reghdfe
            reghdfe trades postEDGAR, absorb(year) vce(cluster permno)
            Thank you very much again for your response.

            Best Philipp

            Comment


            • #7
              Yes. Do note that clustering does not affect your coefficients, only the standard errors.

              Comment


              • #8
                Thank you Jesse and yes I'm aware of your remark in #7.
                That was also my point, why the different coefficients in regression 1 (time fixed effects and one dimensional clustering by permno) and regression 4 (time fixed effects and two dimensional clustering by permno and year) heavily surprised me. However now I know, that the regression in 1 was just misspecified.

                The two dimensional clustering via reghdfe is just an additional step / test to have a look, whether coefficients are still significant.

                Comment


                • #9
                  Am I right to assume now that I have now three different possibilities to run a regression with ONLY TIME FIXED EFFECTS with one dimensional clustering by permno?
                  There are other commands like mixed and xtgls which will implement fixed effects but the most popular commands in no particular order are regress, xtreg, reghdfe, and areg. I personally prefer reghdfe because it allows many levels of fixed effects and is generally faster than the rest.

                  Comment

                  Working...
                  X