Announcement

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

  • outreg2 does not report r2

    Dear Stata users,

    I have some issues with the outreg2 commend when I export my results to excel. I have panel data and perform a diff-in-diff regression using time fixed effects, (a) individual fixed effects, and (b) country fixed effects. I have xtset the data on ID and time.

    (a)
    Code:
    xtreg depvar controls  i.yr2 post15 govsupp2_50 i.post15##i.govsupp2_50 , fe vce(cluster idno)
    outreg2 using fund_govsupp, replace excel dec(3) adjr2
    (b)
    Code:
    xtreg depvar controls  i.yr2  i.countryid post15 govsupp2_50 i.post15##i.govsupp2_50 , vce(cluster idno)
    outreg2 using fund_govsupp, replace excel dec(3) adjr2
    The problem I have is that outreg2 will not report the r2 (or adjr2) when I do not employ individual fixed effects (b). The line in the excel command is then missing. Has anybody faced that problem before? Or am I doing something wrong here? The help file and the web have no entry for this problem as far as I know.

    I would appreciate some advice.

    Regards,
    Julian
    Last edited by Julian Scholz; 28 Feb 2020, 09:46.

  • #2
    xtreg depvar controls i.yr2 i.countryid post15 govsupp2_50 i.post15##i.govsupp2_50 , vce(cluster idno)
    You are estimating a random effects model here, and -xtreg, re- does not report an R2 statistic.

    Edit: Sorry, I am confusing this with mixed. Can you show the result of

    Code:
    ereturn list
    after running the regression?
    Last edited by Andrew Musau; 28 Feb 2020, 10:04.

    Comment


    • #3
      Thank you, Andrew!

      I thouguht that the country dummies "automatically" would make this a fe model to stata. Anyhow, the stata output I get does report an R2.

      Code:
      xtreg CUTOMER_DEPOSITS_TOTAL_FUND_D post15 govsupp2_50 i.post15##i.govsupp2_50 CAR_w HHI3_w strate realgdp inflrate  i.yr2 i.countryid if SRM==1 &
      >  head7==1 & inrange(yr2, 2010, 2018) & yr2 != 2014 & noobs>5 & foreign==0, vce(cluster idno)
      note: 1.post15 omitted because of collinearity
      note: 1.govsupp2_50 omitted because of collinearity
      note: 2018.yr2 omitted because of collinearity
      
      Random-effects GLS regression                   Number of obs     =      4,625
      Group variable: idno                            Number of groups  =        646
      
      R-sq:                                           Obs per group:
           within  = 0.2627                                         min =          1
           between = 0.2928                                         avg =        7.2
           overall = 0.3071                                         max =          8
      
                                                      Wald chi2(31)     =          .
      corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =          .
      
                                             (Std. Err. adjusted for 646 clusters in idno)
      ------------------------------------------------------------------------------------
                         |               Robust
      CUTOMER_DEPOSITS~D |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------------+----------------------------------------------------------------
                  post15 |   21.65075    7.18297     3.01   0.003     7.572385    35.72911
             govsupp2_50 |  -14.13188   3.016256    -4.69   0.000    -20.04364   -8.220131
                1.post15 |          0  (omitted)
           1.govsupp2_50 |          0  (omitted)
                         |
      post15#govsupp2_50 |
                    1 1  |   2.257576    1.11016     2.03   0.042     .0817024    4.433449
                         |
                   CAR_w |   .2076756   .1668671     1.24   0.213     -.119378    .5347291
                  HHI3_w |   5.186592   3.871955     1.34   0.180      -2.4023    12.77548
                  strate |   13.03415   6.989953     1.86   0.062    -.6659026    26.73421
                 realgdp |   .8850633   .1986051     4.46   0.000     .4958044    1.274322
                inflrate |    .211915    .404738     0.52   0.601     -.581357    1.005187
                         |
                     yr2 |
                   2011  |  -3.029358   2.005698    -1.51   0.131    -6.960453    .9017366
                   2012  |   3.709052   .6776741     5.47   0.000     2.380835    5.037269
                   2013  |   11.92399   3.913154     3.05   0.002      4.25435    19.59363
                   2015  |  -2.784333   .7731177    -3.60   0.000    -4.299616    -1.26905
                   2016  |  -.8149415   .6441331    -1.27   0.206    -2.077419    .4475361
                   2017  |  -.8918276   .5211024    -1.71   0.087     -1.91317    .1295143
                   2018  |          0  (omitted)
                         |
               countryid |
                      2  |   15.08964   7.802729     1.93   0.053    -.2034274    30.38271
                      6  |   12.40239   9.170884     1.35   0.176    -5.572215    30.37699
                      9  |          0  (empty)
                     10  |  -8.916917   9.836678    -0.91   0.365    -28.19645    10.36262
                     11  |  -18.14767   4.989036    -3.64   0.000      -27.926   -8.369337
                     12  |   16.75844   4.186881     4.00   0.000     8.552307    24.96458
                     14  |   10.92928   6.637257     1.65   0.100    -2.079509    23.93806
                     17  |   10.52616   5.691866     1.85   0.064    -.6296964    21.68201
                     18  |   .6637391    4.59839     0.14   0.885     -8.34894    9.676418
                     20  |   31.99255   4.494103     7.12   0.000     23.18427    40.80083
                     22  |   28.84748   5.694651     5.07   0.000     17.68617    40.00879
                     23  |   20.49885    9.65097     2.12   0.034     1.583293     39.4144
                     24  |    2.53113   18.79307     0.13   0.893    -34.30262    39.36488
                     25  |   9.093083   7.054994     1.29   0.197    -4.734451    22.92062
                     28  |   16.09133   8.279405     1.94   0.052    -.1360044    32.31867
                     30  |   31.66989   5.878638     5.39   0.000     20.14797    43.19181
                     31  |   2.344348   24.45748     0.10   0.924    -45.59143    50.28012
                     32  |   11.96707   5.499994     2.18   0.030     1.187285    22.74686
                         |
                   _cons |   37.74621   8.871828     4.25   0.000     20.35775    55.13468
      -------------------+----------------------------------------------------------------
                 sigma_u |   19.95451
                 sigma_e |  6.4851037
                     rho |  .90446878   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------------


      Am I estimating the model incorrectly in (b) when I like to use country and time fixed effects and do this via xtreg? When I use reg instead of xtreg, the panel structure is ignored by stata and, of course, the coefficients are different.

      Comment


      • #4
        If you want

        time fixed effects.
        your regression is incorrect. Of course, if you estimate a time fixed effects model, you assume that you can pool countries, so OLS with time dummies is a valid estimation method. Perhaps you want both country and time fixed effects? You can absorb the time dummies in regress.

        Code:
        reg depvar controls i.yr2 i.countryid post15 govsupp2_50 i.post15##i.govsupp2_50, absorb(time)
        Last edited by Andrew Musau; 28 Feb 2020, 10:17.

        Comment


        • #5
          I am a bit confused now. And sorry for being incorrect. You are right, I want country and time fixed effects and I need to cluster the SE on the individual level. I thought that xtreg is the way to go. I mainly use the individual and time fixed effects and time and country fixed effects mainly as a sort of robustness check. My interest is the within variation, I therefore always preferred xtreg.

          I ran both specifications the one you suggested:
          Code:
          reg WHOLESALE_FUNDING_TOTAL_FUNDI_w logta2010EUR_w CAR_w HHI3_w strate realgdp inflrate  i.yr2 i.countryid post15 govsupp2_50 i.post15##i.govsupp2_50 if SRM==1 & head7==1 & inrange(yr2, 2010, 2018) & yr2 != 2014 & noobs>5 & foreign==0, absorb(yr2)
          The results for "reg":

          Code:
          Linear regression, absorbing indicators         Number of obs     =      4,780
                                                          F(25, 4747)       =     101.03
                                                          Prob > F          =     0.0000
                                                          R-squared         =     0.3532
                                                          Adj R-squared     =     0.3489
                                                          Root MSE          =     14.292
          
          ------------------------------------------------------------------------------------
          WHOLESALE_FUNDIN~w |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          -------------------+----------------------------------------------------------------
              logta2010EUR_w |   3.344836   .1941833    17.23   0.000     2.964146    3.725525
                       CAR_w |  -.0489296   .0345359    -1.42   0.157    -.1166361    .0187769
                      HHI3_w |  -8.426919   3.949129    -2.13   0.033    -16.16904   -.6847934
                      strate |   2.407241   3.976331     0.61   0.545    -5.388212    10.20269
                     realgdp |  -.5822449   .2183776    -2.67   0.008    -1.010366   -.1541234
                    inflrate |   1.292268    .603211     2.14   0.032     .1096946    2.474841
                             |
                         yr2 |
                       2011  |          0  (omitted)
                       2012  |          0  (omitted)
                       2013  |          0  (omitted)
                       2015  |          0  (omitted)
                       2016  |          0  (omitted)
                       2017  |          0  (omitted)
                       2018  |          0  (omitted)
                             |
                   countryid |
                          2  |  -9.771966   1.815397    -5.38   0.000    -13.33099   -6.212946
                          6  |   -5.48067   3.232896    -1.70   0.090    -11.81865    .8573061
                         10  |   24.52266   3.948529     6.21   0.000     16.78171    32.26361
                         11  |  -10.30081   1.680991    -6.13   0.000    -13.59633   -7.005286
                         12  |  -14.51509   .9108166   -15.94   0.000    -16.30071   -12.72946
                         14  |  -2.699439   2.559911    -1.05   0.292    -7.718052    2.319173
                         17  |  -17.32048   3.275821    -5.29   0.000    -23.74261   -10.89836
                         18  |  -2.730967    1.21269    -2.25   0.024    -5.108403   -.3535319
                         20  |  -13.59528   3.358195    -4.05   0.000     -20.1789   -7.011657
                         22  |  -14.96298   3.872657    -3.86   0.000    -22.55518   -7.370778
                         23  |   6.414087   2.700144     2.38   0.018     1.120552    11.70762
                         24  |  -14.69549   3.735787    -3.93   0.000    -22.01936   -7.371611
                         25  |   3.472669   2.040216     1.70   0.089    -.5271013    7.472439
                         28  |  -15.48202   2.287838    -6.77   0.000    -19.96724   -10.99679
                         30  |   -14.0482   4.435446    -3.17   0.002    -22.74373    -5.35267
                         31  |   3.513107   3.111113     1.13   0.259    -2.586116    9.612331
                         32  |  -14.63665   1.481251    -9.88   0.000    -17.54059   -11.73271
                             |
                      post15 |          0  (omitted)
                 govsupp2_50 |   6.781561   1.068103     6.35   0.000     4.687584    8.875538
                    1.post15 |          0  (omitted)
               1.govsupp2_50 |          0  (omitted)
                             |
          post15#govsupp2_50 |
                        1 1  |  -3.255368   1.273961    -2.56   0.011    -5.752923   -.7578125
                             |
                       _cons |  -54.11611   5.150058   -10.51   0.000    -64.21261   -44.01961
          ------------------------------------------------------------------------------------
          My original regression with xtreg:

          Code:
          xtreg WHOLESALE_FUNDING_TOTAL_FUNDI_w logta2010EUR_w CAR_w HHI3_w strate realgdp inflrate  i.yr2 i.countryid post15 govsupp2_50 i.post15##i.govsupp2_50 if SRM==1 & head7==1 & inrange(yr2, 2010, 2018) & yr2 != 2014 & noobs>5 & foreign==0, vce(cluster idno)
          With similar results:

          Code:
          Random-effects GLS regression                   Number of obs     =      4,780
          Group variable: idno                            Number of groups  =        645
          
          R-sq:                                           Obs per group:
               within  = 0.1946                                         min =          1
               between = 0.3583                                         avg =        7.4
               overall = 0.3518                                         max =          8
          
                                                          Wald chi2(32)     =          .
          corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =          .
          
                                                 (Std. Err. adjusted for 645 clusters in idno)
          ------------------------------------------------------------------------------------
                             |               Robust
          WHOLESALE_FUNDIN~w |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
          -------------------+----------------------------------------------------------------
              logta2010EUR_w |   2.740217   .8773462     3.12   0.002      1.02065    4.459784
                       CAR_w |  -.0882923   .1109215    -0.80   0.426    -.3056945    .1291099
                      HHI3_w |  -7.390293   3.444784    -2.15   0.032    -14.14195   -.6386398
                      strate |   2.313236   2.845307     0.81   0.416    -3.263463    7.889936
                     realgdp |  -.5640869   .2260752    -2.50   0.013    -1.007186   -.1209876
                    inflrate |   1.433925   .4097104     3.50   0.000     .6309071    2.236942
                             |
                         yr2 |
                       2011  |  -3.051288   .9651291    -3.16   0.002    -4.942906    -1.15967
                       2012  |  -4.840253   .9272294    -5.22   0.000    -6.657589   -3.022917
                       2013  |  -3.386911   1.728888    -1.96   0.050     -6.77547    .0016475
                       2015  |  -1.140285   2.812718    -0.41   0.685    -6.653112    4.372541
                       2016  |  -1.300787   3.029323    -0.43   0.668    -7.238151    4.636577
                       2017  |  -2.885555   2.982483    -0.97   0.333    -8.731113    2.960004
                       2018  |   -4.48964   3.090716    -1.45   0.146    -10.54733    1.568051
                             |
                   countryid |
                          2  |  -9.024287   5.082674    -1.78   0.076    -18.98615    .9375721
                          6  |  -5.080317   6.165938    -0.82   0.410    -17.16533      7.0047
                          9  |          0  (empty)
                         10  |   22.03503   8.346929     2.64   0.008     5.675351    38.39471
                         11  |  -9.672239    4.28592    -2.26   0.024    -18.07249    -1.27199
                         12  |  -14.32818   3.586634    -3.99   0.000    -21.35785   -7.298506
                         14  |  -1.266456   12.02989    -0.11   0.916    -24.84461    22.31169
                         17  |  -15.50139   4.448659    -3.48   0.000     -24.2206   -6.782182
                         18  |  -2.679981   3.814687    -0.70   0.482    -10.15663    4.796669
                         20  |   -13.3318   3.864144    -3.45   0.001    -20.90538   -5.758213
                         22  |   -14.7788   3.707694    -3.99   0.000    -22.04574    -7.51185
                         23  |   6.318256   14.00189     0.45   0.652    -21.12494    33.76145
                         24  |  -13.26835   6.386231    -2.08   0.038    -25.78513    -.751565
                         25  |   3.682126   7.525735     0.49   0.625    -11.06804     18.4323
                         28  |  -14.96933   4.047216    -3.70   0.000    -22.90173   -7.036935
                         30  |   -15.1761   4.060982    -3.74   0.000    -23.13548   -7.216723
                         31  |   2.973994   14.98794     0.20   0.843    -26.40183    32.34981
                         32  |  -14.23457   3.722171    -3.82   0.000    -21.52989   -6.939253
                             |
                      post15 |          0  (omitted)
                 govsupp2_50 |    8.45553    3.54133     2.39   0.017     1.514652    15.39641
                    1.post15 |          0  (omitted)
               1.govsupp2_50 |          0  (omitted)
                             |
          post15#govsupp2_50 |
                        1 1  |  -3.388407   1.097586    -3.09   0.002    -5.539636   -1.237178
                             |
                       _cons |  -38.58651   19.70383    -1.96   0.050    -77.20531    .0322922
          -------------------+----------------------------------------------------------------
                     sigma_u |  13.349642
                     sigma_e |  5.5176037
                         rho |  .85409564   (fraction of variance due to u_i)
          -----------------------------------------------------------------------------------
          Could you please point out again why xtreg is incorrect here?

          Comment


          • #6
            xtreg can estimate multiple models, among them, fixed effects. The default is random effects, so if you want fixed effects, you must always include the -fe- option. You have multiple fixed effects: individual, time and country.

            1. How did you xtset your data?
            2. Why do you omit the -fe- option in the second command?

            Comment


            • #7
              Thanks, that clears things up a little.

              1. xtset IDvar timevar
              2. I thought that including the fe option would somehow "overload" the model. As I want time and country fixed effects my understanding is that using the fe option in addition to the dummies via i. would give me time, country and individaual fixed effects. But that seems to be the right track, as the r2 gets now reported in excel.

              So to be precise: estimating a model with time and country fixed effects needs (in my case) to be done with xtreg and the fe option. Or can I only estimate what I want when I xtset the data with country and time again? The individuals (banks) are nested in countries here. My main interest is in the within bank variation. By including country dummies I wanted to control for unobserved heterogeneity on the country level.

              Comment


              • #8
                https://www.statalist.org/forums/for...543#post886543

                Sebastian's answer in #10 was why I used

                Code:
                xtreg depvar indepvar i.year i.country, re vce(cluster bank)

                Comment


                • #9
                  So to be precise: estimating a model with time and country fixed effects needs (in my case) to be done with xtreg and the fe option.
                  Yes. Do not estimate a random effects model unless you have confirmed that it is appropriate using a Hausman test or xtoverid in your case as you cluster your standard errors. Fixed effects is consistent in all cases.

                  xtset IDvar timevar

                  I thought that including the fe option would somehow "overload" the model. As I want time and country fixed effects my understanding is that using the fe option in addition to the dummies via i. would give me time, country and individaual fixed effects.
                  Specifying the -fe- option will automatically include individual fixed effects. In fact, using "i.id" in regress is not recommended as you will be asking Stata to invert a very large matrix. Note that a random effects model with year and country dummies is not fixed effects, so there lies your confusion. So do any of the following:

                  Code:
                  *FIXED EFFECTS- INDIVIDUAL, TIME AND COUNTRY
                  regress depvar indepvar i.year i.country, cluster(bank) absorb(id)
                  xtset id year
                  xtreg depvar indepvar i.year i.country, fe cluster(bank)
                  or better still

                  Code:
                  ssc install reghdfe
                  reghdfe depvar indepvar, absorb(id country year) cluster(bank)

                  Comment


                  • #10
                    Andrew, thanks for clearing this up!

                    Comment

                    Working...
                    X