Announcement

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

  • In Stata can I estimate robust standard errors AND cluster?

    Hi all,

    A thought, in Stata is it possible to estimate a fixed effects linear probability model with robust standard errors that are also clustered at a certain level?

    i.e. I look at panel data that is nested in region of location in an analysis of local area unemployment on health, estimating a linear probability model I know I should model estimates of the standard errors that are robust to heteroskedasticity. At the same time, I want to cluster the standard errors to allow for within area correlation.

    I notice that doing both provides diffferent results than doing one or the other:

    Clustered and robust:

    Code:
    . xtreg binary_health_y localunemploy i.localarea i.year age_y i.maritalstatus_y, cluster (current_county_y
    > 1) fe robust 
    note: 6.localarea omitted because of collinearity
    note: 8.localarea omitted because of collinearity
    note: 10.localarea omitted because of collinearity
    note: 34.localarea omitted because of collinearity
    note: 37.localarea omitted because of collinearity
    note: 45.localarea omitted because of collinearity
    note: 48.localarea omitted because of collinearity
    note: 49.localarea omitted because of collinearity
    note: 10.year omitted because of collinearity
    
    Fixed-effects (within) regression               Number of obs      =      1938
    Group variable: id                              Number of groups   =       998
    
    R-sq:  within  = 0.0502                         Obs per group: min =         1
           between = 0.0011                                        avg =       1.9
           overall = 0.0016                                        max =         3
    
                                                    F(18,28)           =         .
    corr(u_i, Xb)  = -0.6945                        Prob > F           =         .
    
                                    (Std. Err. adjusted for 29 clusters in current_county_y1)
    -----------------------------------------------------------------------------------------
                            |               Robust
            binary_health_y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    ------------------------+----------------------------------------------------------------
              localunemploy |  -.0102855   .0048639    -2.11   0.043    -.0202487   -.0003222
                            |
                  localarea |
                     Cavan  |   -.018267   .2273549    -0.08   0.937    -.4839823    .4474484
                     Clare  |  -.5252115    .202224    -2.60   0.015    -.9394486   -.1109744
                      Cork  |   .3906244    .277995     1.41   0.171    -.1788225    .9600713
                   Donegal  |          0  (omitted)
                    Dublin  |   .1718237   .2243842     0.77   0.450    -.2878065    .6314539
                  Dublin 1  |          0  (omitted)
                 Dublin 10  |  -.3292192   .3845495    -0.86   0.399    -1.116933    .4584948
                 Dublin 11  |          0  (omitted)
                 Dublin 12  |  -.3186343   .4026879    -0.79   0.435    -1.143503    .5062344
                 Dublin 14  |  -.1434118   .2753101    -0.52   0.607    -.7073589    .4205354
                 Dublin 15  |  -.5067857    .424403    -1.19   0.242    -1.376136    .3625644
                 Dublin 16  |   .6643994   .4014137     1.66   0.109    -.1578593    1.486658
                 Dublin 18  |  -.5712014   .3931835    -1.45   0.157    -1.376601    .2341985
                 Dublin 22  |   .1140665   .2237254     0.51   0.614    -.3442143    .5723472
                 Dublin 24  |   .0648586   .2437201     0.27   0.792    -.4343794    .5640965
                  Dublin 4  |   .7202541   .3564456     2.02   0.053    -.0098916      1.4504
                  Dublin 6  |  -.1533908   .2727381    -0.56   0.578    -.7120695    .4052879
                 Dublin 6W  |   .4818072   .1726109     2.79   0.009     .1282297    .8353847
                  Dublin 7  |     .41868   .2412359     1.74   0.094    -.0754693    .9128293
                  Dublin 8  |   .0001566   .2048933     0.00   0.999    -.4195483    .4198615
               Dublin City  |  -.1254077   .2426099    -0.52   0.609    -.6223715    .3715561
    Dún Laoghaire-Rathdown  |  -.0052935   .2083417    -0.03   0.980    -.4320622    .4214752
                    Fingal  |  -.6266997   .3952099    -1.59   0.124     -1.43625     .182851
                    Galway  |   .4612002   .0138068    33.40   0.000     .4329181    .4894822
               Galway City  |   .5672523   .0295165    19.22   0.000     .5067906    .6277141
                     Kerry  |  -.5674608   .2992189    -1.90   0.068    -1.180383    .0454613
                   Kildare  |   .5304143   .1802315     2.94   0.006     .1612269    .8996017
                  Kilkenny  |          0  (omitted)
                     Laois  |  -.0744377   .0603635    -1.23   0.228    -.1980866    .0492113
                   Leitrim  |   .5543939   .1863086     2.98   0.006     .1727581    .9360297
                  Limerick  |          0  (omitted)
                  Longford  |   .1264136   .2217173     0.57   0.573    -.3277537     .580581
                     Louth  |   .2030122   .2284723     0.89   0.382     -.264992    .6710165
                      Mayo  |   1.439586   .0208783    68.95   0.000     1.396819    1.482354
                     Meath  |  -.1253544   .3548841    -0.35   0.727    -.8523016    .6015928
                  Monaghan  |  -.2798706   .4087279    -0.68   0.499    -1.117112    .5573706
                    Offaly  |   .0461998   .2164787     0.21   0.833    -.3972368    .4896363
                 Roscommon  |    .639648   .2214608     2.89   0.007     .1860061     1.09329
                     Sligo  |          0  (omitted)
              South Dublin  |   .7029383   .3204609     2.19   0.037      .046504    1.359373
                 Tipperary  |  -.0259743   .0450085    -0.58   0.568    -.1181701    .0662215
           Tipperary North  |          0  (omitted)
                 Waterford  |          0  (omitted)
                 Westmeath  |   .0048053   .2280608     0.02   0.983     -.462356    .4719667
                   Wexford  |   .1496822   .2138671     0.70   0.490    -.2884047    .5877691
                   Wicklow  |   .3035418   .2532448     1.20   0.241    -.2152065    .8222902
                            |
                       year |
                         5  |  -.0829668    .032599    -2.55   0.017    -.1497429   -.0161908
                        10  |          0  (omitted)
                            |
                      age_y |   .0071394   .0044921     1.59   0.123    -.0020622     .016341
                            |
            maritalstatus_y |
                Cohabiting  |    .048518   .0301603     1.61   0.119    -.0132625    .1102985
                 Separated  |  -.0904769   .2354731    -0.38   0.704    -.5728216    .3918679
                  Divorced  |  -.1477058   .0899841    -1.64   0.112      -.33203    .0366183
                   Widowed  |   .0203674    .305638     0.07   0.947    -.6057036    .6464385
      Single/Never married  |   .0082783   .0633101     0.13   0.897    -.1214065    .1379631
                            |
                      _cons |   .3698727   .1396175     2.65   0.013     .0838793    .6558661
    ------------------------+----------------------------------------------------------------
                    sigma_u |  .54578273
                    sigma_e |  .35656453
                        rho |  .70086315   (fraction of variance due to u_i)
    -----------------------------------------------------------------------------------------
    ​​​​​​

    Just clustered:

    Code:
    . xtreg binary_health_y localunemploy i.localarea i.year age_y i.maritalstatus_y, fe cluster (current_count
    > y_y1) 
    note: 6.localarea omitted because of collinearity
    note: 8.localarea omitted because of collinearity
    note: 10.localarea omitted because of collinearity
    note: 34.localarea omitted because of collinearity
    note: 37.localarea omitted because of collinearity
    note: 45.localarea omitted because of collinearity
    note: 48.localarea omitted because of collinearity
    note: 49.localarea omitted because of collinearity
    note: 10.year omitted because of collinearity
    
    Fixed-effects (within) regression               Number of obs      =      1938
    Group variable: id                              Number of groups   =       998
    
    R-sq:  within  = 0.0502                         Obs per group: min =         1
           between = 0.0011                                        avg =       1.9
           overall = 0.0016                                        max =         3
    
                                                    F(18,28)           =         .
    corr(u_i, Xb)  = -0.6945                        Prob > F           =         .
    
                                    (Std. Err. adjusted for 29 clusters in current_county_y1)
    -----------------------------------------------------------------------------------------
                            |               Robust
            binary_health_y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    ------------------------+----------------------------------------------------------------
              localunemploy |  -.0102855   .0048639    -2.11   0.043    -.0202487   -.0003222
                            |
                  localarea |
                     Cavan  |   -.018267   .2273549    -0.08   0.937    -.4839823    .4474484
                     Clare  |  -.5252115    .202224    -2.60   0.015    -.9394486   -.1109744
                      Cork  |   .3906244    .277995     1.41   0.171    -.1788225    .9600713
                   Donegal  |          0  (omitted)
                    Dublin  |   .1718237   .2243842     0.77   0.450    -.2878065    .6314539
                  Dublin 1  |          0  (omitted)
                 Dublin 10  |  -.3292192   .3845495    -0.86   0.399    -1.116933    .4584948
                 Dublin 11  |          0  (omitted)
                 Dublin 12  |  -.3186343   .4026879    -0.79   0.435    -1.143503    .5062344
                 Dublin 14  |  -.1434118   .2753101    -0.52   0.607    -.7073589    .4205354
                 Dublin 15  |  -.5067857    .424403    -1.19   0.242    -1.376136    .3625644
                 Dublin 16  |   .6643994   .4014137     1.66   0.109    -.1578593    1.486658
                 Dublin 18  |  -.5712014   .3931835    -1.45   0.157    -1.376601    .2341985
                 Dublin 22  |   .1140665   .2237254     0.51   0.614    -.3442143    .5723472
                 Dublin 24  |   .0648586   .2437201     0.27   0.792    -.4343794    .5640965
                  Dublin 4  |   .7202541   .3564456     2.02   0.053    -.0098916      1.4504
                  Dublin 6  |  -.1533908   .2727381    -0.56   0.578    -.7120695    .4052879
                 Dublin 6W  |   .4818072   .1726109     2.79   0.009     .1282297    .8353847
                  Dublin 7  |     .41868   .2412359     1.74   0.094    -.0754693    .9128293
                  Dublin 8  |   .0001566   .2048933     0.00   0.999    -.4195483    .4198615
               Dublin City  |  -.1254077   .2426099    -0.52   0.609    -.6223715    .3715561
    Dún Laoghaire-Rathdown  |  -.0052935   .2083417    -0.03   0.980    -.4320622    .4214752
                    Fingal  |  -.6266997   .3952099    -1.59   0.124     -1.43625     .182851
                    Galway  |   .4612002   .0138068    33.40   0.000     .4329181    .4894822
               Galway City  |   .5672523   .0295165    19.22   0.000     .5067906    .6277141
                     Kerry  |  -.5674608   .2992189    -1.90   0.068    -1.180383    .0454613
                   Kildare  |   .5304143   .1802315     2.94   0.006     .1612269    .8996017
                  Kilkenny  |          0  (omitted)
                     Laois  |  -.0744377   .0603635    -1.23   0.228    -.1980866    .0492113
                   Leitrim  |   .5543939   .1863086     2.98   0.006     .1727581    .9360297
                  Limerick  |          0  (omitted)
                  Longford  |   .1264136   .2217173     0.57   0.573    -.3277537     .580581
                     Louth  |   .2030122   .2284723     0.89   0.382     -.264992    .6710165
                      Mayo  |   1.439586   .0208783    68.95   0.000     1.396819    1.482354
                     Meath  |  -.1253544   .3548841    -0.35   0.727    -.8523016    .6015928
                  Monaghan  |  -.2798706   .4087279    -0.68   0.499    -1.117112    .5573706
                    Offaly  |   .0461998   .2164787     0.21   0.833    -.3972368    .4896363
                 Roscommon  |    .639648   .2214608     2.89   0.007     .1860061     1.09329
                     Sligo  |          0  (omitted)
              South Dublin  |   .7029383   .3204609     2.19   0.037      .046504    1.359373
                 Tipperary  |  -.0259743   .0450085    -0.58   0.568    -.1181701    .0662215
           Tipperary North  |          0  (omitted)
                 Waterford  |          0  (omitted)
                 Westmeath  |   .0048053   .2280608     0.02   0.983     -.462356    .4719667
                   Wexford  |   .1496822   .2138671     0.70   0.490    -.2884047    .5877691
                   Wicklow  |   .3035418   .2532448     1.20   0.241    -.2152065    .8222902
                            |
                       year |
                         5  |  -.0829668    .032599    -2.55   0.017    -.1497429   -.0161908
                        10  |          0  (omitted)
                            |
                      age_y |   .0071394   .0044921     1.59   0.123    -.0020622     .016341
                            |
            maritalstatus_y |
                Cohabiting  |    .048518   .0301603     1.61   0.119    -.0132625    .1102985
                 Separated  |  -.0904769   .2354731    -0.38   0.704    -.5728216    .3918679
                  Divorced  |  -.1477058   .0899841    -1.64   0.112      -.33203    .0366183
                   Widowed  |   .0203674    .305638     0.07   0.947    -.6057036    .6464385
      Single/Never married  |   .0082783   .0633101     0.13   0.897    -.1214065    .1379631
                            |
                      _cons |   .3698727   .1396175     2.65   0.013     .0838793    .6558661
    ------------------------+----------------------------------------------------------------
                    sigma_u |  .54578273
                    sigma_e |  .35656453
                        rho |  .70086315   (fraction of variance due to u_i)
    -----------------------------------------------------------------------------------------
    Just Robust


    Code:
    . xtreg binary_health_y localunemploy i.localarea i.year age_y i.maritalstatus_y, fe robust 
    note: 6.localarea omitted because of collinearity
    note: 8.localarea omitted because of collinearity
    note: 10.localarea omitted because of collinearity
    note: 34.localarea omitted because of collinearity
    note: 37.localarea omitted because of collinearity
    note: 45.localarea omitted because of collinearity
    note: 48.localarea omitted because of collinearity
    note: 49.localarea omitted because of collinearity
    note: age_y omitted because of collinearity
    
    Fixed-effects (within) regression               Number of obs     =      1,938
    Group variable: id                              Number of groups  =        998
    
    R-sq:                                           Obs per group:
         within  = 0.0502                                         min =          1
         between = 0.0004                                         avg =        1.9
         overall = 0.0010                                         max =          3
    
                                                    F(30,997)         =          .
    corr(u_i, Xb)  = -0.6927                        Prob > F          =          .
    
                                                  (Std. Err. adjusted for 998 clusters in id)
    -----------------------------------------------------------------------------------------
                            |               Robust
            binary_health_y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    ------------------------+----------------------------------------------------------------
              localunemploy |  -.0102855    .009136    -1.13   0.261    -.0282135    .0076425
                            |
                  localarea |
                     Cavan  |   -.018267   .3280089    -0.06   0.956     -.661934    .6254001
                     Clare  |  -.5252115   .2191949    -2.40   0.017    -.9553479   -.0950751
                      Cork  |   .3906244   .3120468     1.25   0.211    -.2217194    1.002968
                   Donegal  |          0  (omitted)
                    Dublin  |   .1718237   .2348421     0.73   0.465    -.2890178    .6326652
                  Dublin 1  |          0  (omitted)
                 Dublin 10  |  -.3292192   .3181444    -1.03   0.301    -.9535287    .2950903
                 Dublin 11  |          0  (omitted)
                 Dublin 12  |  -.3186343   .3398729    -0.94   0.349    -.9855827     .348314
                 Dublin 14  |  -.1434118   .3021666    -0.47   0.635    -.7363673    .4495437
                 Dublin 15  |  -.5067857    .414741    -1.22   0.222    -1.320651    .3070797
                 Dublin 16  |   .6643994   .3542445     1.88   0.061    -.0307509     1.35955
                 Dublin 18  |  -.5712014   .3740661    -1.53   0.127    -1.305249    .1628458
                 Dublin 22  |   .1140665   .2433277     0.47   0.639    -.3634266    .5915596
                 Dublin 24  |   .0648586   .2873856     0.23   0.821    -.4990915    .6288086
                  Dublin 4  |   .7202541   .3323103     2.17   0.030     .0681463    1.372362
                  Dublin 6  |  -.1533908   .2910491    -0.53   0.598    -.7245299    .4177484
                 Dublin 6W  |   .4818072   .1536192     3.14   0.002     .1803532    .7832612
                  Dublin 7  |     .41868   .3057638     1.37   0.171    -.1813345    1.018695
                  Dublin 8  |   .0001566   .2215372     0.00   0.999    -.4345761    .4348893
               Dublin City  |  -.1254077   .3059933    -0.41   0.682    -.7258726    .4750572
    Dún Laoghaire-Rathdown  |  -.0052935   .2563242    -0.02   0.984    -.5082903    .4977033
                    Fingal  |  -.6266997   .3751952    -1.67   0.095    -1.362963    .1095632
                    Galway  |   .4612002    .022001    20.96   0.000     .4180265    .5043738
               Galway City  |   .5672523   .1131448     5.01   0.000     .3452231    .7892816
                     Kerry  |  -.5674607   .3302368    -1.72   0.086      -1.2155    .0805781
                   Kildare  |   .5304143   .1514385     3.50   0.000     .2332395    .8275891
                  Kilkenny  |          0  (omitted)
                     Laois  |  -.0744377   .1677833    -0.44   0.657    -.4036866    .2548113
                   Leitrim  |   .5543939   .1556817     3.56   0.000     .2488924    .8598954
                  Limerick  |          0  (omitted)
                  Longford  |   .1264136   .2309013     0.55   0.584    -.3266948     .579522
                     Louth  |   .2030123   .2354136     0.86   0.389    -.2589508    .6649753
                      Mayo  |   1.439586   .0363067    39.65   0.000      1.36834    1.510833
                     Meath  |  -.1253544   .3039104    -0.41   0.680    -.7217319    .4710231
                  Monaghan  |  -.2798706    .337875    -0.83   0.408    -.9428984    .3831572
                    Offaly  |   .0461998   .2550179     0.18   0.856    -.4542336    .5466331
                 Roscommon  |    .639648   .2367404     2.70   0.007     .1750813    1.104215
                     Sligo  |          0  (omitted)
              South Dublin  |   .7029384   .3211111     2.19   0.029     .0728072     1.33307
                 Tipperary  |  -.0259743   .1005386    -0.26   0.796    -.2232658    .1713171
           Tipperary North  |          0  (omitted)
                 Waterford  |          0  (omitted)
                 Westmeath  |   .0048053   .3137501     0.02   0.988    -.6108809    .6204916
                   Wexford  |   .1496822   .2336562     0.64   0.522    -.3088322    .6081965
                   Wicklow  |   .3035418    .262532     1.16   0.248    -.2116368    .8187205
                            |
                       year |
                         5  |    -.04727   .0245417    -1.93   0.054    -.0954292    .0008893
                        10  |   .0713938   .0874613     0.82   0.415    -.1002356    .2430231
                            |
                      age_y |          0  (omitted)
                            |
            maritalstatus_y |
                Cohabiting  |    .048518   .0688095     0.71   0.481      -.08651    .1835459
                 Separated  |  -.0904769   .2322185    -0.39   0.697    -.5461699    .3652162
                  Divorced  |  -.1477058   .1709027    -0.86   0.388    -.4830761    .1876644
                   Widowed  |   .0203674   .2799886     0.07   0.942    -.5290672    .5698021
      Single/Never married  |   .0082783   .0760861     0.11   0.913    -.1410291    .1575856
                            |
                      _cons |   .5902072   .1579593     3.74   0.000     .2802364    .9001781
    ------------------------+----------------------------------------------------------------
                    sigma_u |  .54471768
                    sigma_e |  .35656453
                        rho |  .70004346   (fraction of variance due to u_i)
    -----------------------------------------------------------------------------------------
    It looks like clustering is automatically robust, but that robust obviously doesnt automatically cluster because it doesnt know which level to cluster at. So, should I include both or just cluster, and why?

    Thanks for any help,

    John

  • #2
    John:
    under -xtreg-, both -robust- and -cluster()- options do the very same job and produce a cluster robust standard error, clustered on the -panelid-, as you can see form the following information provided by Stata outcome:
    Code:
    (Std. Err. adjusted for 998 clusters in id)
    Kind regards,
    Carlo
    (Stata 16.0 SE)

    Comment


    • #3
      Hi Carlos,

      Thank you for your reply, I guess the distinction comes in an analysis like mine when you feel the clustering should be at the regional level rather than the individual level, in that case I guess that cluster is necessary but robust is not?

      Very best,

      John

      Comment


      • #4
        John:
        yes, you're right.
        It remains to be seen if, given the way you -xtset- your data, Stata allows clustering SE at regional level.
        Kind regards,
        Carlo
        (Stata 16.0 SE)

        Comment


        • #5
          You should be able to cluster at a higher nest without a problem even if you have set your panel variable to be in the lower nest. For your example let's say you set your panel variable to id with xtset id month, or whatever time variable you have, and you have a variable region that nests id within it.

          The following should not be a problem
          Code:
          xtreg y x1 x2 x3, fe vce(cluster region)
          What happens is that the heteroskedsatic-robust variance estimator that is used with the vce(robust) option of regress is no longer consistent with panel data, so Stata has appropriately programmed that option to be equivalent to clustering at the panel variable. But there shouldn't be anything stopping you from clustering at a higher nest.

          Notice that the higher you cluster the less structure you impose on the variance-covariance matrix, but you run into issues of having less clusters. Check the following out for a good guide to cluster-robust inference:

          Cameron, A. Colin and Douglas L. Miller (2015) "A Practitioner's Guide to Cluster-Robust Inference", The Journal of Human Resources 50(2), pp. 317-372
          Last edited by Alfonso Sánchez-Peñalver; 26 Nov 2019, 08:16.
          Alfonso Sanchez-Penalver

          Comment

          Working...
          X