Announcement

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

  • One-way vs. Multi-way clustering of standard errors

    Hello guys,

    I am unsure about clustering standard errors in panel data and would appreciate your help a lot!
    I know how to do this technically with "reghdfe", but I can not find out or do not really understand what different clustering does or when to use which level of clustering (at least not on a level where I fully understand it).
    So, in a lot of academic papers (Finance or Accounting e.g.) the SE are clustered, sometimes on firm or fund level and sometimes on firm and year level etc.

    But how do I find out which one I should use? I have around 5000 firms in my sample and around 70 quarters. How do I find out, wether I should use firm or firm + quarter or firm + year clustered SE?
    My Coefficients are pretty stabil, no wether what clustering I use (they become a bit bigger when time level is also applied, but not much).

    What are your thoughts and recommendations on this topic? Is it even advised to cluster on year-level if I have quarterly data? If I just cluster on firm-level I have 5000 cluster and if I cluster on firm + quarter I have 70 cluster, which is somhwat logical to me, but it is a large difference in the number of clusters, but it has a very small influence on the resutls. What does this tell me exactly?
    If it is important for this: I use Firm and Country and Industry and and also time fixed effects.

    Thanks a lot in advance!

  • #2
    Anela:
    I would cluster at -firm- level only and plug in -timevar- as a categorical predictor.
    Country and Industry are time-invariant and will be wioped out by the -fe- estimator.
    For more details on clustering see: Cameron_Miller_JHR_2015_February.pdf
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Originally posted by Carlo Lazzaro View Post
      Anela:
      I would cluster at -firm- level only and plug in -timevar- as a categorical predictor.
      Country and Industry are time-invariant and will be wioped out by the -fe- estimator.
      For more details on clustering see: Cameron_Miller_JHR_2015_February.pdf
      Thank you Carlo!
      I read the paper, but I did not understand everything unfortunately. But it still helped me to understand some parts on clustering.

      At the moment, I cluster on firm and quarter. I also use firm+time fe, country + time fe and industry + time fe.

      You would suggest to drop the time clustered SE, right? Why exactly? I am unsure about it. The paper talks about an overfitting problem and thus providing larger se, lowering significance, as I understood it.
      Now I would like to keep time fe, as most of the papers in this topic use time and firm fe and it was advised to me. Would this be okay in your opinion and wouldn't this be the same as using time (quarter) as a categorical variable?

      Now, I am unsure about this sentence: "Country and Industry are time-invariant and will be wiped out by the -fe- estimator."
      Could you please explain this further? Would it be okay to use the 3 combinations above + clustered SE on firm-level (instead of firm+time as before)?

      Comment


      • #4
        Additionally to the questions above, I am also unsure about wether I should use time fixed effects using quarter or year if I have quarterly data. So for each firm I have on observation per quarter. I also read that one can not use time fixed effects e.g. on quarter if there is only one obervation per firm.
        But I receive estimates from stata doing exactly that. Or are the results just ignoring the time FE? What would your recommendations be for the final model/or models. I want to use different variations of FE. Clustered SE should be the same across the models, I think.

        Comment


        • #5
          Anela:
          1) due to demeaning, the -fe- estimator wipes out time-invariant variables. Why is it so? Because if you subtract from a constant (say, -industry- that is not expecte to change during the firm's life) its mean, the resut is zero, that is no coefficient. ;
          2) keeping time -fe- via the -absorb- option available from the community-contributed module -reghdfe- is recommended. But it is different from clustering on -quarter (if you have quarterly-spaced waves of data);
          3) it depends on kow many panels have one obsercation only, as you can see from the following toy-example, where the machinery works even if panel #3 is composed of one onservation only:
          Code:
          . set obs 7
          Number of observations (_N) was 0, now 7.
          
          . g id=1 in 1/3
          
          . replace id=2 in 4/6
          
          . replace id=3 in 7
          
          . g depvar=runiform()*1000
          
          . bysort id: g timevar=_n
          
          . list
          
               +-------------------------+
               | id     depvar   timevar |
               |-------------------------|
            1. |  1   850.6309         1 |
            2. |  1   391.3819         2 |
            3. |  1   119.6613         3 |
            4. |  2   754.2434         1 |
            5. |  2   695.0234         2 |
               |-------------------------|
            6. |  2   686.6152         3 |
            7. |  3   931.9346         1 |
               +-------------------------+
          
          . xtset id timevar
          
          Panel variable: id (unbalanced)
           Time variable: timevar, 1 to 3
                   Delta: 1 unit
          
          . xtreg depvar i.timevar
          
          Random-effects GLS regression                   Number of obs     =          7
          Group variable: id                              Number of groups  =          3
          
          R-squared:                                      Obs per group:
               Within  = 0.5946                                         min =          1
               Between = 0.7092                                         avg =        2.3
               Overall = 0.5362                                         max =          3
          
                                                          Wald chi2(2)      =       4.78
          corr(u_i, X) = 0 (assumed)                      Prob > chi2       =     0.0914
          
          ------------------------------------------------------------------------------
                depvar | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
          -------------+----------------------------------------------------------------
               timevar |
                    2  |  -300.6838   210.5732    -1.43   0.153    -713.3997    112.0322
                    3  |  -440.7481   210.5732    -2.09   0.036     -853.464   -28.03218
                       |
                 _cons |    845.603   135.3707     6.25   0.000     580.2813    1110.925
          -------------+----------------------------------------------------------------
               sigma_u |  48.063895
               sigma_e |  236.18116
                   rho |  .03976711   (fraction of variance due to u_i)
          ------------------------------------------------------------------------------
          
          . gen sample=e(sample)
          
          . tab sample
          
               sample |      Freq.     Percent        Cum.
          ------------+-----------------------------------
                    1 |          7      100.00      100.00
          ------------+-----------------------------------
                Total |          7      100.00
          
          .
          and compare with the following exercise that shows an -fe-impairment:
          Code:
          . set obs 4
          Number of observations (_N) was 0, now 4.
          
          . g id=1 in 1/3
          
          
          . replace id=2 in 4
          
          
          . g depvar=runiform()*1000
          
          . bysort id: g timevar=_n
          
          . list
          
               +-------------------------+
               | id     depvar   timevar |
               |-------------------------|
            1. |  1   454.8882         1 |
            2. |  1    67.4011         2 |
            3. |  1   337.9889         3 |
            4. |  2   974.8848         1 |
               +-------------------------+
          
          . xtset id timevar
          
          Panel variable: id (unbalanced)
           Time variable: timevar, 1 to 3
                   Delta: 1 unit
          
          . xtreg depvar i.timevar
          insufficient observations
          r(2001);
          
          . gen sample=e(sample)
          
          . tab sample
          
               sample |      Freq.     Percent        Cum.
          ------------+-----------------------------------
                    0 |          4      100.00      100.00
          ------------+-----------------------------------
                Total |          4      100.00
          
          .
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            Hello Carlo, thanks for the example.

            I thought that using reghdfe with firm and time absorbed would be the same as using categorical variables like i.time. Is this not true? Now, I still do not know wether it would be an better option to cluster on year instead of quarter. Then, I would have 4 observations per firm. Or even leave out the time clustering and just cluster on firm level, based on 5000 firms and 70 quarters.
            What models would you use regarding unit fe (firm, industry, country and time fe (quarter, year) and clustered se (firm, firm+quarter, firm+year).
            I would be thankful for your opinion. I understand that it is maybe not so easy to tell based on the information I can provide, but what would your intuitive opinion be?

            Thanks till now and in advanced!

            Comment


            • #7
              Anela:
              the weakest part of this query is not reading what you typed and what Stata gave you back (as per FAQ).
              Personally, I shy away form having too many fixed effects, as it may be complicated to explain them in a paper.
              If I were you, I wouls ask myself, knowing the data generating process I'm dealing with, what's the gain in considering so many fixed effects instead of focusing on -panelid- and -timevar- fixed effect only?
              Eventually, I would cimply cluster at -panelid- level.
              Kind regards,
              Carlo
              (Stata 19.0)

              Comment


              • #8
                reghdfe doesn't care if you use i.id and i.time or just id and time.

                There is no problem using quarterly FE with only one observation per quarter. The quarter FE is absorbing the time FE for all firms, not just one. Essentially, you are subtracting the mean at time t from all observations. Having a state*year FE would be a problem, since everything is a singleton (Stata would balk at that in any case). If you FE on year and not quarter, then you are allowing some between effects among quarters.

                reghdfe y x1 x2 x3, absorb(id qtr) cluster(id)

                Comment


                • #9
                  Thank you so much! I will do it exactly as you explained which would now have been my best guess, given the information above. Panelid is firm and timevar is quarter.

                  Comment

                  Working...
                  X