Announcement

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

  • How to cluster standard error at country level?

    Hey!

    I tried to run panal data regression, and worked for cluster standard error at firm level(permno). (ym is year and month)

    xtset permno ym
    xtreg f6ret PF POSTPF POSTT PFT POSTPFT i.year, fe cluster(permno)

    but when I try
    xtreg f6ret PF POSTPF POSTT PFT POSTPFT i.year, fe cluster(country)

    it says 'panels are not nested within clusters'.

    Sample:
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double permno float(ym f6ret year PF POSTPF POSTT PFT POSTPFT country)
    10207 368     .06632764 1990 .7 0 0 0 0 4
    10207 369     -.0794038 1990 .9 0 0 0 0 4
    10207 370   -.003264269 1990 .9 0 0 0 0 4
    10207 371    -.05579877 1990 .9 0 0 0 0 4
    10207 372    -.20440815 1991  1 0 0 0 0 4
    10207 373    -.05142857 1991 .8 0 0 0 0 4
    10207 374   -.024201704 1991 .6 0 0 0 0 4
    10207 375     .10524093 1991 .2 0 0 0 0 4
    10207 376     .10358141 1991 .4 0 0 0 0 4
    10207 377     .10524093 1991 .2 0 0 0 0 4
    10207 378     .17792796 1991 .1 0 0 0 0 4
    10207 379      .1547932 1991 .1 0 0 0 0 4
    10207 380     .16414873 1991 .5 0 0 0 0 4
    10207 381      .1838134 1991 .7 0 0 0 0 4
    10207 382     .07760347 1991 .7 0 0 0 0 4
    10207 383     .10672788 1991 .8 0 0 0 0 4
    10207 384     .15785037 1992 .7 0 0 0 0 4
    10207 385      .1630513 1992 .7 0 0 0 0 4
    10207 386    .033496205 1992 .7 0 0 0 0 4
    11077 366   -.59090906 1990 .2 0 0 .2 0 22
    11077 367          -.5 1990 .2 0 0 .2 0 22
    11077 368    .20833334 1990 .1 0 0 .1 0 22
    11077 369    .08333334 1990 .1 0 0 .1 0 22
    11077 370           .5 1990 .1 0 0 .1 0 22
    11077 371      .888889 1990 .1 0 0 .1 0 22
    11077 372     .7777778 1991 .1 0 0 .1 0 22
    11077 373      .631579 1991 .1 0 0 .1 0 22
    11077 374  -.034482747 1991 .8 0 0 .8 0 22
    11077 375    .03846155 1991 .4 0 0 .4 0 22
    
    11845 449   .16019306 1997 .5 0 0 .5 0 12
    11845 450   .11007067 1997 .2 0 0 .2 0 12
    11845 451   .06033811 1997 .4 0 0 .4 0 12
    11845 452   .16861244 1997 .5 0 0 .5 0 12
    11845 453    .2673978 1997 .5 0 0 .5 0 12
    11845 454     .395664 1997 .6 0 0 .6 0 12
    11845 455    .4124138 1997 .7 0 0 .7 0 12
    11845 456   .49556565 1998 .7 0 0 .7 0 12
    11845 457    .5543182 1998 .8 0 0 .8 0 12
    11845 458  .017565502 1998 .7 0 0 .7 0 12
    11845 459  -.21058515 1998 .9 0 0 .9 0 12
    end
    format %tm ym
    Thank you!


  • #2
    Edward:
    I was not able to replicate the problem you reported:
    Code:
    . xtset permno ym
           panel variable:  permno (unbalanced)
            time variable:  ym, 1990m7 to 1998m4
                    delta:  1 month
    
    . xtreg f6ret PF POSTPF POSTT PFT POSTPFT i.year, fe cluster(permno)
    note: POSTPF omitted because of collinearity
    note: POSTT omitted because of collinearity
    note: POSTPFT omitted because of collinearity
    note: 1998.year omitted because of collinearity
    
    Fixed-effects (within) regression               Number of obs     =         40
    Group variable: permno                          Number of groups  =          3
    
    R-sq:                                           Obs per group:
         within  = 0.1445                                         min =         10
         between = 0.6243                                         avg =       13.3
         overall = 0.0041                                         max =         19
    
                                                    F(2,2)            =          .
    corr(u_i, Xb)  = -0.9174                        Prob > F          =          .
    
                                     (Std. Err. adjusted for 3 clusters in permno)
    ------------------------------------------------------------------------------
                 |               Robust
           f6ret |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
              PF |  -.1052988   .1717658    -0.61   0.602    -.8443473    .6337497
          POSTPF |          0  (omitted)
           POSTT |          0  (omitted)
             PFT |  -.5526351   .7961855    -0.69   0.559    -3.978345    2.873075
         POSTPFT |          0  (omitted)
                 |
            year |
           1991  |   .2083706    .236178     0.88   0.471    -.8078211    1.224562
           1992  |   .2339173   .1588834     1.47   0.279    -.4497026    .9175372
           1997  |  -.1795912   .1875728    -0.96   0.439    -.9866517    .6274692
           1998  |          0  (omitted)
                 |
           _cons |   .2445696   .0988045     2.48   0.132    -.1805518    .6696909
    -------------+----------------------------------------------------------------
         sigma_u |  .38582298
         sigma_e |  .28449884
             rho |  .64778088   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    
    . xtreg f6ret PF POSTPF POSTT PFT POSTPFT i.year, fe cluster(country)
    note: POSTPF omitted because of collinearity
    note: POSTT omitted because of collinearity
    note: POSTPFT omitted because of collinearity
    note: 1997.year omitted because of collinearity
    
    Fixed-effects (within) regression               Number of obs      =        40
    Group variable: permno                          Number of groups   =         3
    
    R-sq:  within  = 0.1445                         Obs per group: min =        10
           between = 0.7422                                        avg =      13.3
           overall = 0.0003                                        max =        19
    
                                                    F(2,2)             =         .
    corr(u_i, Xb)  = -0.8551                        Prob > F           =         .
    
                                    (Std. Err. adjusted for 3 clusters in country)
    ------------------------------------------------------------------------------
                 |               Robust
           f6ret |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
              PF |  -.1052988   .1717658    -0.61   0.602    -.8443473    .6337497
          POSTPF |          0  (omitted)
           POSTT |          0  (omitted)
             PFT |  -.5526351   .7961855    -0.69   0.559    -3.978345    2.873075
         POSTPFT |          0  (omitted)
                 |
            year |
           1991  |   .2083706    .236178     0.88   0.471    -.8078211    1.224562
           1992  |   .2339173   .1588834     1.47   0.279    -.4497026    .9175372
           1997  |          0  (omitted)
           1998  |   .1795912   .1875728     0.96   0.439    -.6274692    .9866517
                 |
           _cons |    .195182   .0883056     2.21   0.158    -.1847666    .5751305
    -------------+----------------------------------------------------------------
         sigma_u |  .29336188
         sigma_e |  .28449884
             rho |  .51533407   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    Perhaps your data excerpt does not include the critical issues.
    That said, to avoid the problem, you may try to create a new panel_id, that takes into account both -permno- and -country-:
    Code:
    egen new-panel_id=group(permno country)
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Sure thanks!

      Comment

      Working...
      X