Announcement

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

  • Pooled (Panel) Regression

    I am struggling with the specific understanding of panel regressions in connection with STATA. What I basically want to do is to replicate the following work (http://pages.stern.nyu.edu/~sternfin...c_html/sin.pdf), only for a different data sample.

    This work mainly uses “pooled (panel) regressions” (p.24).

    In my understanding, a pooled OLS regression in STATA is provided through the command reg or regress (which is completely the same). However, it does not seem that this approach takes the actual panel structure into account. Nevertheless, the researchers of the mentioned paper utilize exactly this term “pooled (panel) regressions” (p.24).

    A different approach would be to define the panel first and then to provide a regression:
    xtset firmID Time xtreg Y X1 X2 X3
    This would take the panel structure into account, but it would not be a pooled regression anymore or? Moreover, the results are very similar, but the ordinary reg command accomplishes a higher level of significance.

    I spent a lot of time and search to understand the main difference between the ordinary regresscommand and the xtreg command. Still if I am completely honest I do not understand the difference and would be thankful for a clear explanation. Also the help reg and help xtregcommands in STATA could not provide a clear understanding.

  • #2
    Alex:
    welcome to the list.
    Pooled OLS needs clustered standard errors to take the panel data structure into account.
    That said, pooled OLS seldom outperforms -xtreg- when you deal with a panel dataset.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Dear Mr. Lazzaro thank you for your reply.

      So, to provide a correct pooled OLS on the panel data it is not enough to utilize the -reg- command. I have to adjust it in the following way:

      xtset firmID Time
      reg Y X1 X2 X3 firmID, vce(cluster firmID)


      Moreover, you suggest that -xtreg- is more superior in relation to a panel dataset. However, with the -xtreg- command it would not be a pooled OLS regression anymore right? Subsequently, it would be different from the approach utilized within the mentioned study, because the researcher state that they use a “pooled (panel) regression” (p.24)?

      I would be grateful for your clarifying.

      Best Regards
      Alex Weis

      Comment


      • #4
        Dear Alex:
        - you interpretation of pooled OLS is correct;
        - you're also correct in stating that a panel data regression is not a pooled OLS regression (however, you should correct -reg- in -xtreg- after -xtset-);
        - at page 24 of the reference you quoted, authors describe exactly a pooled OLS. Actually, they underscore the need for standard errors clustered in -panelid-;
        - from Example #2 under -xtreg- entry, you can read that, whenever the F-test appearing at the feet of -xtreg- outcome table fais to reach statistical significance, pooled OLS outperforms -xtreg-. I would also add that, in my experience, that rarely occurs.

        As a non-technical aside, please call me Carlo as all on (and many more off) the list do.
        Last edited by Carlo Lazzaro; 01 Sep 2017, 06:38.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Hello Carlo,

          I hope it is okay to use a old thread to ask a question based on post #3.

          I do have a similar problem to understand pooled OLS in Stata. In my case I have to do a pooled OLS, Fixed Effect and Free regression.

          Therefore I would do the pooled OLS similar to post #3 but I do not understand why firmID comes after X3. What is the methodology of using firmID after X3?

          For the fixed effect I would use the following command:
          Code:
          xtset firmID Time
          xtreg Y X1 X2 X3, fe
          Should I use firmID here as well? I mean with xtset I hold firmID and Time fix or?

          The free regression I do not know how to do it in panel data format because I need for each single company the correlation. I know how to do it in wide format by simply running the reg command for each one, but I do not know how to do it in long format. To make it more understandable my dataset looks like this

          Code:
          * Example generated by -dataex-. To install: ssc install dataex
          clear
          input double zfund float modate double(mktminusrf smb_5 hml rmw cma rf) byte company double return
          -.4309383413670224 601   3.4  1.53  2.74  -.55  1.43   0 2  -14.9038461538462
          -.0141456717752401 602  6.31  1.85  2.01   -.9  1.67 .01 2  8.772742681047772
          -.3451440767419464 603     2  5.03  3.12   .49  1.69 .01 2  5.619839471199241
          -.4262781423107988 604 -7.89  -.08 -2.32  1.38  -.18 .01 2 -12.43110815111477
           -.371163521472528 605 -5.56 -2.59 -4.27  -.34 -1.48 .01 2 -6.662716462092019
           -.024398109698932 606  6.93   .13   .04   .32  2.03 .01 2 -18.01929469655549
          -.4337655287944647 607 -4.77 -3.07 -1.51   .34 -2.13 .01 2 -13.03805396069644
          -.2048099491622005 608  9.54  3.71 -2.94  -.01   .39 .01 2  12.93086977856836
          -.0729573838647816 609  3.88   .72 -2.23  1.46  -.16 .01 2 -6.991575267138257
          -.3881111120403277 610    .6  3.54  -.58   -.1  1.76 .01 2 -2.587763505524829
           .1058078519319547 611  6.82  1.03  3.47 -3.44  3.44 .01 2    25.826417302189
          -.3926004371311564 612  1.99 -2.38   .68 -1.07    .8 .01 2 -1.953753199899981
          -.4062703543627456 613  3.49  1.76  1.73 -1.76   .72 .01 2  1.908535113442489
          -.3648256507560639 614   .45  2.66 -1.16  1.21  -.03 .01 2 -2.394001810935897
          -.4321655271184945 615   2.9  -.41 -2.15   .96 -1.28   0 2 -12.29777807612272
          -.3267984264572796 616 -1.27  -.69 -2.12  2.02 -1.46   0 2 -5.240232404411508
          -.2500915499918396 617 -1.75   .09  -.26  2.16  -1.4   0 2 -3.270575104270688
          -.3658353605515791 618 -2.36 -1.38 -1.18  2.41 -1.75   0 2  9.105746602899874
          -.3068993764872049 619 -5.99 -3.39 -1.58  2.79  -.23 .01 2 -16.62784658201427
            -.26837506428909 620 -7.59  -3.9  -.98  1.71   .24   0 2 -22.14350681319415
          -.3872412082164993 621 11.35  3.72  -.96 -1.42  -.86   0 2  11.27604389951129
          -.4345422286371686 622  -.28  -.34  -.18  1.46  1.52   0 2  .3072477726944403
          -.4031635549919299 623   .74  -.36  1.57   .59  2.44   0 2  12.55089107389768
          -.2686391422356094 624  5.05  2.35 -2.14 -1.05 -1.41   0 2   1.90504628247238
          -.4327092170083873 625  4.42 -1.54   .01  -.17  -.03   0 2  5.432489451476787
          -.4036606428912604 626  3.11   -.3  -.06   .25   .77   0 2   13.8513701295092
          -.4073266661488228 627  -.85  -.66   -.2   .96   .72   0 2                  0
           -.392320825187783 628 -6.19   -.2   .08  1.98  2.37 .01 2  .1385552479059296
          -.3499596157667108 629  3.89   .99   .54 -1.48   .37   0 2  7.709235761939909
          -.3997460756840325 630   .79 -2.74   .01   .68   .12   0 2 -.2069001189675686
          -.2152798630418495 631  2.55   .61    .6  -.77  -.69 .01 2  1.715366713315706
          -.3207090996904808 632  2.73   .69  1.56 -1.14  1.57 .01 2  .0581498277146874
          -.3458741745940881 633 -1.76   -.8  4.16 -1.35  2.28 .01 2  -4.01282597349695
          -.4301461075274643 634   .78   .41 -1.12   .94   .93 .01 2 -6.511574672633841
           -.348421750078157 635  1.18  1.91  3.26 -1.75   .88 .01 2  9.966669810451075
          -.3217032754891418 636  5.57   .57  1.34 -1.88  1.47   0 2 -.2746827607551854
          -.3033110232139128 637  1.29  -.35   .28  -.96   .49   0 2    5.5171923290789
          -.3892140258169673 638  4.03    .9  -.07   .13  1.21   0 2  6.601305187046155
           .0938156063606059 639  1.56 -2.32   .35   .04   .39   0 2 -1.840568380391795
          -.1475205687643588 640   2.8  2.27  1.33  -.71  -.83   0 2  7.249686705784522
          -.3079867562669904 641  -1.2  1.33   -.4  -.47   .01   0 2  3.205639216799729
          -.2844372170362073 642  5.65  1.81   .71 -1.43   .53   0 2  11.01646941809467
          -.3654470106302271 643 -2.71  -.03 -2.48   .85 -2.13   0 2 -1.373903926801387
          -.0458660933512685 644  3.77  2.72 -1.57   -.1 -1.32   0 2   3.14751373473718
           .1428253664352239 645  4.18 -1.57  1.36  2.83   .89   0 2  10.83285317443587
           -.311854721483656 646  3.12  1.47  -.38   .77   .12   0 2  8.189910226715579
          -.3969188882565902 647  2.81  -.44   -.2  -.57   .07   0 2  6.524516257574033
          -.4001033576116764 648 -3.32   .56 -1.88  -4.5 -1.42   0 2 -7.277921620689898
          -.2543478651298571 649  4.65   .16  -.49  -.49   -.4   0 2  1.527514644285263
          -.0462855112663287 650   .43 -1.23   4.6  1.76  1.91   0 2   4.51320848802646
           .3741421135893079 651  -.19 -4.21  1.62  2.85  1.09   0 2 -6.410189506329302
           -.214192483262064 652  2.06 -1.83  -.38   .45 -1.09   0 2   .599014652758684
           5.119203394626711 653  2.61  3.04   -.6  -1.9  -1.9   0 2  4.765958120696964
           .6428957931617213 654 -2.04 -4.16   .04  1.48   .44   0 2 -15.05889555250717
          -.0663865031955063 655  4.23    .3  -.76  -.91  -.65   0 2  1.437456622711015
          -.2642274871290511 656 -1.97  -3.8 -1.68  1.28  -.62   0 2 -4.510905558260204
          -.2376954205022849 657  2.52  3.79 -1.81  -.78  -.18   0 2  14.34929587815432
          -.2130740354885704 658  2.55 -2.27 -3.37  1.69   .15   0 2 -4.950212685622941
             2.6553250856076 659  -.06  2.85  1.56 -1.52   .81   0 2  3.174931857079471
          -.2924061574223497 660 -3.11  -.91 -3.06  1.09 -1.67   0 2 -11.81660304405524
          -.2044215992408486 661  6.13   .35 -2.16   .06 -1.62   0 2  12.79575286347295
          -.1474428987800883 662 -1.12  3.07  -.73   .16  -.54   0 2  4.042051168019372
           1.668465799464843 663   .59 -2.99  2.13   .41  -.49   0 2  4.263386407982165
           .1219010726727801 664  1.36   .85  -1.9 -1.54  -.68   0 2 -.0823732609562099
           .1296991390935276 665 -1.53  2.88 -1.04  1.03 -1.51   0 2  6.800066864728094
           .3822663939439909 666  1.54  -4.5 -4.49   .31  -2.6   0 2 -1.902055016238781
           .2912371723790906 667 -6.04   .38  2.88   .75  1.14   0 2 -5.975631867135669
           .4157110891708222 668 -3.07 -2.81   .73  1.66   -.5   0 2  .4631861499242194
            5.63291267059109 669  7.75 -2.05  -.32  1.19   .45   0 2  4.879996314666095
           .1172253396197023 670   .56  3.35 -1.23 -2.11    -1   0 2  7.902153701995575
           -.382441203188589 671 -2.17    -3 -2.07   .45   .17 .01 2 -10.45597395460543
          -.1641108774045147 672 -5.77 -3.56  3.13  2.27     3 .01 2 -12.97368546850556
          -.3199323998477768 673  -.07   .87  -.03  2.44  2.09 .02 2 -4.617976281144597
          -.0534622178129129 674  6.96  1.01   1.3   .58   .07 .02 2  7.460041968888286
          -.4309383413670224 601   3.4  1.53  2.74  -.55  1.43   0 3   9.74967061923584
          -.0141456717752401 602  6.31  1.85  2.01   -.9  1.67 .01 3   7.19288115246098
          -.3451440767419464 603     2  5.03  3.12   .49  1.69 .01 3 -.1219820828667389
          -.4262781423107988 604 -7.89  -.08 -2.32  1.38  -.18 .01 3 -11.73197309417041
           -.371163521472528 605 -5.56 -2.59 -4.27  -.34 -1.48 .01 3 -8.650023366859694
           -.024398109698932 606  6.93   .13   .04   .32  2.03 .01 3  -2.30703713485449
          -.4337655287944647 607 -4.77 -3.07 -1.51   .34 -2.13 .01 3 -11.26298770771683
          -.2048099491622005 608  9.54  3.71 -2.94  -.01   .39 .01 3  5.226579911347658
          -.0729573838647816 609  3.88   .72 -2.23  1.46  -.16 .01 3 -12.63015385787189
          -.3881111120403277 610    .6  3.54  -.58   -.1  1.76 .01 3 -4.368399944212481
           .1058078519319547 611  6.82  1.03  3.47 -3.44  3.44 .01 3  21.90832010280622
          -.3926004371311564 612  1.99 -2.38   .68 -1.07    .8 .01 3  2.913674964491289
          -.4062703543627456 613  3.49  1.76  1.73 -1.76   .72 .01 3  4.068267880099642
          -.3648256507560639 614   .45  2.66 -1.16  1.21  -.03 .01 3 -6.657778025904411
          -.4321655271184945 615   2.9  -.41 -2.15   .96 -1.28   0 3 -7.876952978993803
          -.3267984264572796 616 -1.27  -.69 -2.12  2.02 -1.46   0 3 -4.316214001119832
          -.2500915499918396 617 -1.75   .09  -.26  2.16  -1.4   0 3  -6.63788863069695
          -.3658353605515791 618 -2.36 -1.38 -1.18  2.41 -1.75   0 3 -11.40552472135674
          -.3068993764872049 619 -5.99 -3.39 -1.58  2.79  -.23 .01 3 -15.76704135095508
            -.26837506428909 620 -7.59  -3.9  -.98  1.71   .24   0 3 -25.09158623711403
          -.3872412082164993 621 11.35  3.72  -.96 -1.42  -.86   0 3  11.60089037646026
          -.4345422286371686 622  -.28  -.34  -.18  1.46  1.52   0 3 -20.20469666749166
          -.4031635549919299 623   .74  -.36  1.57   .59  2.44   0 3  2.205842106223427
          -.2686391422356094 624  5.05  2.35 -2.14 -1.05 -1.41   0 3  28.23735227962441
          -.4327092170083873 625  4.42 -1.54   .01  -.17  -.03   0 3   11.9215991981736
          -.4036606428912604 626  3.11   -.3  -.06   .25   .77   0 3  20.07462686567165
          end
          format %tm modate

          Comment


          • #6
            Marius:
            I do hope everything is Ok for you, too.
            As far as your three regressions are concerned, I hope that that the following codes will be helpful (admittedly, I have never heard about -free regression-, so I give it a temptative shot): Please also note thyat if your original, dataset show T>N features, -xtreg- should be replaced by -xtregar,fe-

            Code:
            *xtreg with fixed effect specification*
            . xtset company modate
                   panel variable:  company (unbalanced)
                    time variable:  modate, 2010m2 to 2016m3
                            delta:  1 month
            . xtreg return smb_5 hml i.modate , fe vce(cluster company)
            note: 673.modate omitted because of collinearity
            note: 674.modate omitted because of collinearity
            
            Fixed-effects (within) regression               Number of obs     =        100
            Group variable: company                         Number of groups  =          2
            
            R-sq:                                           Obs per group:
                 within  = 0.8581                                         min =         26
                 between = 1.0000                                         avg =       50.0
                 overall = 0.8585                                         max =         74
            
                                                            F(1,1)            =          .
            corr(u_i, Xb)  = -0.0732                        Prob > F          =          .
            
                                            (Std. Err. adjusted for 2 clusters in company)
            ------------------------------------------------------------------------------
                         |               Robust
                  return |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                   smb_5 |  -63.00674   64.76433    -0.97   0.509    -885.9156    759.9021
                     hml |   15.71351   6.817298     2.30   0.261    -70.90848    102.3355
                         |
                  modate |
                    602  |   42.19292   51.29621     0.82   0.562    -609.5873    693.9731
                    603  |   219.8785   253.7403     0.87   0.545    -3004.197    3443.954
                    604  |  -31.43497   46.40358    -0.68   0.621    -621.0484    558.1784
                    605  |  -154.5154   193.0472    -0.80   0.570    -2607.413    2298.382
                    606  |  -53.36905   63.53968    -0.84   0.555    -860.7172    753.9791
                    607  |   -232.622   246.6207    -0.94   0.519    -3366.235    2900.991
                    608  |   238.2632   211.4789     1.13   0.462    -2448.831    2925.357
                    609  |   19.82688   10.97781     1.81   0.322    -119.6595    159.3132
                    610  |   177.9114   178.6006     1.00   0.501    -2091.425    2447.247
                    611  |  -16.52977   9.482456    -1.74   0.332    -137.0158    103.9562
                    612  |  -210.9295   219.8803    -0.96   0.513    -3004.774    2582.915
                    613  |   35.92768   43.72767     0.82   0.562    -519.6851    591.5405
                    614  |   130.5315   127.9848     1.02   0.494    -1495.669    1756.732
                    615  |  -52.90432   72.56587    -0.73   0.599    -974.9412    869.1325
                    616  |  -65.70847   87.49269    -0.75   0.590    -1177.409    1045.992
                    617  |  -45.96634   45.46979    -1.01   0.497    -623.7147    531.7821
                    618  |  -120.3255   117.6747    -1.02   0.493    -1615.524    1374.873
                    619  |  -255.7312    265.976    -0.96   0.512    -3635.277    3123.815
                    620  |  -304.7128     299.38    -1.02   0.494    -4108.697    3499.271
                    621  |   210.1403   190.7945     1.10   0.469    -2214.134    2634.415
                    622  |  -79.31081   57.13641    -1.39   0.397    -805.2977    646.6761
                    623  |  -90.74249   80.28145    -1.13   0.461    -1110.815    929.3301
                    624  |   145.9957   84.73723     1.72   0.335    -930.6928    1222.684
                    625  |  -139.2787   162.4929    -0.86   0.549    -2203.947    1925.389
                    626  |  -51.76444   81.44852    -0.64   0.640    -1086.666    983.1372
                    627  |  -89.11104   97.93048    -0.91   0.530    -1333.436    1155.214
                    628  |  -64.38917   70.04774    -0.92   0.527      -954.43    825.6517
                    629  |   10.93132    3.88586     2.81   0.217    -38.44321    60.30585
                    630  |  -223.6718   234.0719    -0.96   0.514    -3197.838    2750.494
                    631  |  -19.94792   21.13362    -0.94   0.518    -288.4761    248.5802
                    632  |  -31.64956   22.49708    -1.41   0.393    -317.5021     254.203
                    633  |  -170.4557   136.7209    -1.25   0.430     -1907.66    1566.748
                    634  |  -13.74898   22.36074    -0.61   0.649    -297.8691    270.3711
                    635  |   28.41423   44.92599     0.63   0.641    -542.4246    599.2531
                    636  |  -36.08623     28.769    -1.25   0.428     -401.631    329.4585
                    637  |  -71.60424   81.12584    -0.88   0.540    -1102.406    959.1973
                    638  |   13.73802   2.215622     6.20   0.102    -14.41412    41.89017
                    639  |  -204.1852   209.1888    -0.98   0.508    -2862.181     2453.81
                    640  |   78.70673   81.39854     0.97   0.511    -955.5597    1112.973
                    641  |   42.62071   32.31399     1.32   0.413    -367.9675    453.2089
                    642  |   63.23279   55.83367     1.13   0.460    -646.2012    772.6668
                    643  |  -14.96391   41.58552    -0.36   0.780     -543.358    513.4302
                    644  |   148.5268   130.3126     1.14   0.458    -1507.252    1804.306
                    645  |  -160.1274    167.501    -0.96   0.514     -2288.43    1968.175
                    646  |   56.11166   41.24465     1.36   0.404    -467.9513    580.1747
                    647  |  -68.72504   83.68233    -0.82   0.562     -1132.01    994.5598
                    648  |    6.87795   7.464941     0.92   0.526    -87.97312     101.729
                    649  |  -31.36108   42.84672    -0.73   0.598    -575.7802    513.0581
                    650  |  -195.9365   167.5692    -1.17   0.450    -2325.105    1933.232
                    651  |  -347.7937   340.2513    -1.02   0.493    -4671.097    3975.509
                    652  |  -159.4015   172.4776    -0.92   0.525    -2350.938    2032.135
                    653  |   155.0653   144.4245     1.07   0.477    -1680.021    1990.152
                    654  |  -328.4648   326.2418    -1.01   0.498     -4473.76     3816.83
                    655  |  -18.38755   31.93904    -0.58   0.667    -424.2115    387.4364
                    656  |  -268.2071   291.2009    -0.92   0.526    -3968.265    3431.851
                    657  |    230.917   201.2466     1.15   0.456    -2326.164    2787.998
                    658  |  -145.6903   180.5902    -0.81   0.568    -2440.307    2148.926
                    659  |   107.5618   117.3939     0.92   0.528    -1384.069    1599.192
                    660  |  -71.73871   94.62409    -0.76   0.587    -1274.052    1130.574
                    661  |   18.11999   19.15661     0.95   0.518    -225.2878    261.5278
                    662  |   158.2743   147.2536     1.07   0.477    -1712.761    2029.309
                    663  |  -268.2658   264.7157    -1.01   0.496    -3631.797    3095.266
                    664  |   32.65972   11.45306     2.85   0.215    -112.8652    178.1847
                    665  |   153.9322   137.0618     1.12   0.463    -1587.603    1895.467
                    666  |   -265.548   317.3793    -0.84   0.556    -4298.234    3767.138
                    667  |  -77.95726   51.57286    -1.51   0.372    -733.2526     577.338
                    668  |  -238.7259   243.5139    -0.98   0.506    -3332.863    2855.411
                    669  |  -169.9248   187.1348    -0.91   0.531    -2547.698    2207.849
                    670  |   187.6331   168.7963     1.11   0.466    -1957.127    2332.393
                    671  |  -217.6185   236.7307    -0.92   0.527    -3225.567     2790.33
                    672  |  -337.1303   308.4486    -1.09   0.472    -4256.342    3582.081
                    673  |          0  (omitted)
                    674  |          0  (omitted)
                         |
                   _cons |   50.72074   56.54949     0.90   0.535    -667.8086    769.2501
            -------------+----------------------------------------------------------------
                 sigma_u |  .13990593
                 sigma_e |   7.505849
                     rho |  .00034731   (fraction of variance due to u_i)
            ------------------------------------------------------------------------------
            *regress with fixed effect specification*
            . reg return smb_5 hml i.modate i.company, vce(cluster company)
            note: 673.modate omitted because of collinearity
            note: 674.modate omitted because of collinearity
            
            Linear regression                               Number of obs     =        100
                                                            F(0, 1)           =          .
                                                            Prob > F          =          .
                                                            R-squared         =     0.8586
                                                            Root MSE          =     7.5058
            
                                            (Std. Err. adjusted for 2 clusters in company)
            ------------------------------------------------------------------------------
                         |               Robust
                  return |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                   smb_5 |  -63.00674   66.04692    -0.95   0.515    -902.2124    776.1989
                     hml |   15.71351   6.952307     2.26   0.265    -72.62393    104.0509
                         |
                  modate |
                    602  |   42.19292   52.31208     0.81   0.568    -622.4951    706.8809
                    603  |   219.8785   258.7653     0.85   0.552    -3068.047    3507.803
                    604  |  -31.43497   47.32255    -0.66   0.627     -632.725    569.8551
                    605  |  -154.5154   196.8703    -0.78   0.576     -2655.99    2346.959
                    606  |  -53.36905   64.79801    -0.82   0.561    -876.7059    769.9678
                    607  |   -232.622   251.5047    -0.92   0.525    -3428.293    2963.049
                    608  |   238.2632    215.667     1.10   0.468    -2502.046    2978.572
                    609  |   19.82688   11.19522     1.77   0.327    -122.4218    162.0756
                    610  |   177.9114   182.1376     0.98   0.507    -2136.366    2492.189
                    611  |  -16.52977   9.670245    -1.71   0.337    -139.4019    106.3423
                    612  |  -210.9295   224.2348    -0.94   0.519    -3060.103    2638.244
                    613  |   35.92768   44.59365     0.81   0.568    -530.6884    602.5438
                    614  |   130.5315   130.5194     1.00   0.500    -1527.874    1788.937
                    615  |  -52.90432   74.00296    -0.71   0.605    -993.2011    887.3925
                    616  |  -65.70847   89.22539    -0.74   0.596    -1199.425    1068.008
                    617  |  -45.96634   46.37026    -0.99   0.503    -635.1564    543.2237
                    618  |  -120.3255   120.0051    -1.00   0.499    -1645.135    1404.484
                    619  |  -255.7312   271.2434    -0.94   0.519    -3702.206    3190.743
                    620  |  -304.7128   305.3089    -1.00   0.501    -4184.031    3574.605
                    621  |   210.1403    194.573     1.08   0.476    -2262.144    2682.425
                    622  |  -79.31081   58.26793    -1.36   0.403    -819.6751    661.0534
                    623  |  -90.74249   81.87134    -1.11   0.467    -1131.016    949.5315
                    624  |   145.9957   86.41536     1.69   0.340    -952.0155    1244.007
                    625  |  -139.2787   165.7109    -0.84   0.555    -2244.835    1966.278
                    626  |  -51.76444   83.06152    -0.62   0.645    -1107.161    1003.632
                    627  |  -89.11104   99.86989    -0.89   0.536    -1358.078    1179.856
                    628  |  -64.38917   71.43495    -0.90   0.533    -972.0563     843.278
                    629  |   10.93132   3.962815     2.76   0.221    -39.42102    61.28366
                    630  |  -223.6718   238.7075    -0.94   0.521    -3256.738    2809.394
                    631  |  -19.94792   21.55215    -0.93   0.525     -293.794    253.8981
                    632  |  -31.64956   22.94261    -1.38   0.399    -323.1631     259.864
                    633  |  -170.4557   139.4285    -1.22   0.436    -1942.063    1601.152
                    634  |  -13.74898   22.80357    -0.60   0.655    -303.4958    275.9978
                    635  |   28.41423    45.8157     0.62   0.647    -553.7295    610.5579
                    636  |  -36.08623   29.33874    -1.23   0.435    -408.8702    336.6977
                    637  |  -71.60424   82.73245    -0.87   0.546     -1122.82    979.6112
                    638  |   13.73802     2.2595     6.08   0.104    -14.97164    42.44769
                    639  |  -204.1852   213.3315    -0.96   0.514    -2914.819    2506.449
                    640  |   78.70673   83.01055     0.95   0.517    -976.0422    1133.456
                    641  |   42.62071   32.95394     1.29   0.419    -376.0987    461.3402
                    642  |   63.23279   56.93939     1.11   0.467    -660.2508    786.7164
                    643  |  -14.96391   42.40907    -0.35   0.784    -553.8223    523.8945
                    644  |   148.5268   132.8933     1.12   0.465    -1540.043    1837.097
                    645  |  -160.1274   170.8182    -0.94   0.521    -2330.578    2010.323
                    646  |   56.11166   42.06146     1.33   0.410    -478.3298    590.5531
                    647  |  -68.72504   85.33957    -0.81   0.568    -1153.067    1015.617
                    648  |    6.87795   7.612776     0.90   0.532    -89.85154    103.6074
                    649  |  -31.36108   43.69525    -0.72   0.604    -586.5619    523.8397
                    650  |  -195.9365   170.8877    -1.15   0.457    -2367.271    1975.398
                    651  |  -347.7937   346.9896    -1.00   0.499    -4756.715    4061.128
                    652  |  -159.4015   175.8934    -0.91   0.531    -2394.339    2075.536
                    653  |   155.0653   147.2846     1.05   0.484    -1716.363    2026.494
                    654  |  -328.4648   332.7026    -0.99   0.504    -4555.853    3898.923
                    655  |  -18.38755   32.57156    -0.56   0.673    -432.2484    395.4733
                    656  |  -268.2071   296.9678    -0.90   0.532    -4041.541    3505.126
                    657  |    230.917   205.2321     1.13   0.463    -2376.804    2838.638
                    658  |  -145.6903   184.1666    -0.79   0.574    -2485.749    2194.368
                    659  |   107.5618   119.7187     0.90   0.534    -1413.609    1628.732
                    660  |  -71.73871   96.49802    -0.74   0.593    -1297.862    1154.385
                    661  |   18.11999   19.53598     0.93   0.524    -230.1082    266.3482
                    662  |   158.2743   150.1698     1.05   0.483    -1749.814    2066.363
                    663  |  -268.2658   269.9581    -0.99   0.502    -3698.408    3161.877
                    664  |   32.65972   11.67988     2.80   0.219    -115.7472    181.0666
                    665  |   153.9322   139.7761     1.10   0.469    -1622.092    1929.956
                    666  |   -265.548   323.6647    -0.82   0.563    -4378.097    3847.001
                    667  |  -77.95726    52.5942    -1.48   0.378      -746.23    590.3154
                    668  |  -238.7259   248.3364    -0.96   0.513    -3394.139    2916.687
                    669  |  -169.9248   190.8408    -0.89   0.537    -2594.787    2254.938
                    670  |   187.6331   172.1391     1.09   0.473    -1999.602    2374.868
                    671  |  -217.6185   241.4189    -0.90   0.533    -3285.136    2849.899
                    672  |  -337.1303   314.5571    -1.07   0.478    -4333.958    3659.697
                    673  |          0  (omitted)
                    674  |          0  (omitted)
                         |
               3.company |   .1978569          .        .       .            .           .
                   _cons |   50.66929   57.66939     0.88   0.541    -682.0897    783.4283
            ------------------------------------------------------------------------------
            *regress for each company*
            . bysort company:  reg return smb_5 hml i.modate
            
            ---------------------------------------------------------------------------------------------------------------------------------------
            -> company = 2
            note: 673.modate omitted because of collinearity
            note: 674.modate omitted because of collinearity
            
                  Source |       SS           df       MS      Number of obs   =        74
            -------------+----------------------------------   F(73, 0)        =         .
                   Model |  5677.52697        73  77.7743421   Prob > F        =         .
                Residual |           0         0           .   R-squared       =    1.0000
            -------------+----------------------------------   Adj R-squared   =         .
                   Total |  5677.52697        73  77.7743421   Root MSE        =         0
            
            ------------------------------------------------------------------------------
                  return |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                   smb_5 |  -96.19657          .        .       .            .           .
                     hml |   19.20717          .        .       .            .           .
                         |
                  modate |
                    602  |   68.48072          .        .       .            .           .
                    603  |   349.9129          .        .       .            .           .
                    604  |  -55.21545          .        .       .            .           .
                    605  |  -253.4465          .        .       .            .           .
                    606  |  -85.93128          .        .       .            .           .
                    607  |  -359.0079          .        .       .            .           .
                    608  |     346.64          .        .       .            .           .
                    609  |   25.45269          .        .       .            .           .
                    610  |    269.439          .        .       .            .           .
                    611  |  -21.38925          .        .       .            .           .
                    612  |  -323.6117          .        .       .            .           .
                    613  |   58.33683          .        .       .            .           .
                    614  |   196.1199          .        .       .            .           .
                    615  |   -90.0922          .        .       .            .           .
                    616  |  -110.5459          .        .       .            .           .
                    617  |  -69.26827          .        .       .            .           .
                    618  |  -180.6303          .        .       .            .           .
                    619  |  -392.0361          .        .       .            .           .
                    620  |  -458.1363          .        .       .            .           .
                    621  |   307.9169          .        .       .            .           .
                    622  |  -108.5915          .        .       .            .           .
                    623  |  -131.8844          .        .       .            .           .
                    624  |   189.4211          .        .       .            .           .
                    625  |  -222.5515          .        .       .            .           .
                    626  |  -93.50442          .        .       .            .           .
                    627  |  -139.2976          .        .       .            .           .
                    628  |  -100.2866          .        .       .            .           .
                    629  |   12.92271          .        .       .            .           .
                    630  |  -343.6268          .        .       .            .           .
                    631  |  -30.77828          .        .       .            .           .
                    632  |  -43.17866          .        .       .            .           .
                    633  |  -240.5212          .        .       .            .           .
                    634  |   -25.2082          .        .       .            .           .
                    635  |   51.43748          .        .       .            .           .
                    636  |   -50.8295          .        .       .            .           .
                    637  |  -113.1789          .        .       .            .           .
                    638  |   14.87347          .        .       .            .           .
                    639  |  -311.3884          .        .       .            .           .
                    640  |   120.4211          .        .       .            .           .
                    641  |   59.18069          .        .       .            .           .
                    642  |   91.84591          .        .       .            .           .
                    643  |  -36.27527          .        .       .            .           .
                    644  |   215.3082          .        .       .            .           .
                    645  |  -245.9668          .        .       .            .           .
                    646  |   77.24834          .        .       .            .           .
                    647  |  -111.6098          .        .       .            .           .
                    648  |   3.052386          .        .       .            .           .
                    649  |  -53.31877          .        .       .            .           .
                    650  |  -281.8108          .        .       .            .           .
                    651  |  -522.1626          .        .       .            .           .
                    652  |  -247.7912          .        .       .            .           .
                    653  |   229.0786          .        .       .            .           .
                    654  |  -495.6541          .        .       .            .           .
                    655  |  -34.75537          .        .       .            .           .
                    656  |  -417.4391          .        .       .            .           .
                    657  |     334.05          .        .       .            .           .
                    658  |  -238.2375          .        .       .            .           .
                    659  |   167.7227          .        .       .            .           .
                    660  |  -120.2308          .        .       .            .           .
                    661  |   8.302789          .        .       .            .           .
                    662  |   233.7375          .        .       .            .           .
                    663  |  -403.9249          .        .       .            .           .
                    664  |   38.52908          .        .       .            .           .
                    665  |   224.1724          .        .       .            .           .
                    666  |  -428.1957          .        .       .            .           .
                    667  |  -104.3868          .        .       .            .           .
                    668  |  -363.5197          .        .       .            .           .
                    669  |  -265.8259          .        .       .            .           .
                    670  |   274.1362          .        .       .            .           .
                    671  |  -338.9361          .        .       .            .           .
                    672  |  -495.2012          .        .       .            .           .
                    673  |          0  (omitted)
                    674  |          0  (omitted)
                         |
                   _cons |   79.64925          .        .       .            .           .
            ------------------------------------------------------------------------------
            
            ---------------------------------------------------------------------------------------------------------------------------------------
            -> company = 3
            note: 625.modate omitted because of collinearity
            note: 626.modate omitted because of collinearity
            
                  Source |       SS           df       MS      Number of obs   =        26
            -------------+----------------------------------   F(25, 0)        =         .
                   Model |  4247.83411        25  169.913364   Prob > F        =         .
                Residual |           0         0           .   R-squared       =    1.0000
            -------------+----------------------------------   Adj R-squared   =         .
                   Total |  4247.83411        25  169.913364   Root MSE        =         0
            
            ------------------------------------------------------------------------------
                  return |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                   smb_5 |    6.14031          .        .       .            .           .
                     hml |  -7.700616          .        .       .            .           .
                         |
                  modate |
                    602  |  -10.14314          .        .       .            .           .
                    603  |   -28.4365          .        .       .            .           .
                    604  |  -50.56086          .        .       .            .           .
                    605  |  -47.08293          .        .       .            .           .
                    606  |  -24.25194          .        .       .            .           .
                    607  |  -25.49485          .        .       .            .           .
                    608  |  -61.64846          .        .       .            .           .
                    609  |  -55.67823          .        .       .            .           .
                    610  |  -52.02614          .        .       .            .           .
                    611  |   20.85025          .        .       .            .           .
                    612  |   1.309349          .        .       .            .           .
                    613  |   -14.8713          .        .       .            .           .
                    614  |   -53.3784          .        .       .            .           .
                    615  |  -43.37043          .        .       .            .           .
                    616  |  -37.85939          .        .       .            .           .
                    617  |  -30.64736          .        .       .            .           .
                    618  |  -33.47331          .        .       .            .           .
                    619  |  -28.57305          .        .       .            .           .
                    620  |  -30.14566          .        .       .            .           .
                    621  |  -40.08834          .        .       .            .           .
                    622  |  -40.95779          .        .       .            .           .
                    623  |  -4.948363          .        .       .            .           .
                    624  |  -24.12638          .        .       .            .           .
                    625  |          0  (omitted)
                    626  |          0  (omitted)
                         |
                   _cons |   21.45468          .        .       .            .           .
            ------------------------------------------------------------------------------
            
            .
            Last edited by Carlo Lazzaro; 06 Jan 2021, 04:02.
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              Thank you very much Carolo and with free I meant just an linear regression without holding anything fix.

              I tested your codes on my full data. However, I do have an question regarding this code
              Code:
              bysort company: reg return smb_5 hml i.modate
              . i modified the code because I did not want to have an pooled OLS and just the linear regression (not sure if I did this right).
              Code:
              bysort company: reg return smb_5 hml, vce(robust)
              The problem that I have is, that the results are totally different compared to when I run each company one by one. As en example I provide you with my full data for company 1


              Code:
              * Example generated by -dataex-. To install: ssc install dataex
              clear
              input double zdeals float modate double(mktminusrf smb_5 hml rmw cma rf) byte company double return
              -1.387618507695037 601   3.4  1.53  2.74  -.55  1.43   0 1  1.079242090318634
              -.5345743431284158 602  6.31  1.85  2.01   -.9  1.67 .01 1   7.86393930364869
              -.3639655102150915 603     2  5.03  3.12   .49  1.69 .01 1  7.512007394694056
              -1.046400841868388 604 -7.89  -.08 -2.32  1.38  -.18 .01 1 -7.985979824222703
              -.8757920089550641 605 -5.56 -2.59 -4.27  -.34 -1.48 .01 1 -6.335626764257626
              -.1933566773017673 606  6.93   .13   .04   .32  2.03 .01 1  2.881855746293185
              -1.387618507695037 607 -4.77 -3.07 -1.51   .34 -2.13 .01 1  -9.47372995462771
              -.0227478443884431 608  9.54  3.71 -2.94  -.01   .39 .01 1  6.938139934459893
              -1.046400841868388 609  3.88   .72 -2.23  1.46  -.16 .01 1  -1.05813682753868
                -.70518317604174 610    .6  3.54  -.58   -.1  1.76 .01 1 -.2466604777739863
              -.1933566773017673 611  6.82  1.03  3.47 -3.44  3.44 .01 1  14.13006373515285
              -.3639655102150915 612  1.99 -2.38   .68 -1.07    .8 .01 1 -.7969297791341908
                -.70518317604174 613  3.49  1.76  1.73 -1.76   .72 .01 1  .5468279827189715
               .1478609885248811 614   .45  2.66 -1.16  1.21  -.03 .01 1  .9523648032545907
              -1.387618507695037 615   2.9  -.41 -2.15   .96 -1.28   0 1  .5892439640544306
               .3184698214382052 616 -1.27  -.69 -2.12  2.02 -1.46   0 1  -1.49001583687659
               .1478609885248811 617 -1.75   .09  -.26  2.16  -1.4   0 1 -2.242232233723338
              -1.046400841868388 618 -2.36 -1.38 -1.18  2.41 -1.75   0 1 -3.803201280158997
              -.0227478443884431 619 -5.99 -3.39 -1.58  2.79  -.23 .01 1 -10.01027367894514
              -.0227478443884431 620 -7.59  -3.9  -.98  1.71   .24   0 1 -9.691976652945483
              -1.387618507695037 621 11.35  3.72  -.96 -1.42  -.86   0 1  14.10180765195524
              -1.558227340608361 622  -.28  -.34  -.18  1.46  1.52   0 1 -.7010521563359489
                -.70518317604174 623   .74  -.36  1.57   .59  2.44   0 1   2.80698102953636
              -.5345743431284158 624  5.05  2.35 -2.14 -1.05 -1.41   0 1  4.812300227465119
              -1.558227340608361 625  4.42 -1.54   .01  -.17  -.03   0 1  4.929256079524911
              -1.217009674781713 626  3.11   -.3  -.06   .25   .77   0 1  6.134441796438536
              -.1933566773017673 627  -.85  -.66   -.2   .96   .72   0 1 -.6589440873023984
              -1.046400841868388 628 -6.19   -.2   .08  1.98  2.37 .01 1 -5.232003502156303
              -.3639655102150915 629  3.89   .99   .54 -1.48   .37   0 1  3.161005632020767
              -1.046400841868388 630   .79 -2.74   .01   .68   .12   0 1 -2.194379715301951
              -.0227478443884431 631  2.55   .61    .6  -.77  -.69 .01 1  3.209782285250071
              -.5345743431284158 632  2.73   .69  1.56 -1.14  1.57 .01 1  3.744035044489593
              -.5345743431284158 633 -1.76   -.8  4.16 -1.35  2.28 .01 1 -.0112728353654932
              -1.387618507695037 634   .78   .41 -1.12   .94   .93 .01 1 -1.707135468131021
                -.70518317604174 635  1.18  1.91  3.26 -1.75   .88 .01 1  3.042648155235065
               1.171513986004826 636  5.57   .57  1.34 -1.88  1.47   0 1  4.353588346029981
              -.1933566773017673 637  1.29  -.35   .28  -.96   .49   0 1  1.795811335142117
              -.5345743431284158 638  4.03    .9  -.07   .13  1.21   0 1  4.731694854308732
              -.8757920089550641 639  1.56 -2.32   .35   .04   .39   0 1 -1.228710327935455
               .3184698214382052 640   2.8  2.27  1.33  -.71  -.83   0 1  4.940060638818191
              -.3639655102150915 641  -1.2  1.33   -.4  -.47   .01   0 1  2.524169010641897
                1.34212281891815 642  5.65  1.81   .71 -1.43   .53   0 1  7.810874448103843
               .1478609885248811 643 -2.71  -.03 -2.48   .85 -2.13   0 1 -3.497821482444668
               .3184698214382052 644  3.77  2.72 -1.57   -.1 -1.32   0 1  1.662269053409684
               .1478609885248811 645  4.18 -1.57  1.36  2.83   .89   0 1  3.530331927754367
              -.3639655102150915 646  3.12  1.47  -.38   .77   .12   0 1  5.958017535781948
              -.5345743431284158 647  2.81  -.44   -.2  -.57   .07   0 1  1.758179600545098
              -.1933566773017673 648 -3.32   .56 -1.88  -4.5 -1.42   0 1 -3.509387301462624
               1.000905153091502 649  4.65   .16  -.49  -.49   -.4   0 1  2.497577726394331
               1.000905153091502 650   .43 -1.23   4.6  1.76  1.91   0 1  4.418488481502361
               1.853949317658123 651  -.19 -4.21  1.62  2.85  1.09   0 1 -5.144931450627418
                -.70518317604174 652  2.06 -1.83  -.38   .45 -1.09   0 1 -.1524946883270472
              -.0227478443884431 653  2.61  3.04   -.6  -1.9  -1.9   0 1  5.056250663074426
               1.853949317658123 654 -2.04 -4.16   .04  1.48   .44   0 1 -3.606526297369947
                -.70518317604174 655  4.23    .3  -.76  -.91  -.65   0 1  2.334665259623833
              -.1933566773017673 656 -1.97  -3.8 -1.68  1.28  -.62   0 1 -2.045957417917509
               1.512731651831475 657  2.52  3.79 -1.81  -.78  -.18   0 1  3.921821214508064
              -.0227478443884431 658  2.55 -2.27 -3.37  1.69   .15   0 1  .2556962153253985
               1.512731651831475 659  -.06  2.85  1.56 -1.52   .81   0 1  1.699910054766814
               .3184698214382052 660 -3.11  -.91 -3.06  1.09 -1.67   0 1 -9.063475876310159
               1.000905153091502 661  6.13   .35 -2.16   .06 -1.62   0 1  7.821358748819074
               .4890786543515295 662 -1.12  3.07  -.73   .16  -.54   0 1  1.178161237891585
               1.171513986004826 663   .59 -2.99  2.13   .41  -.49   0 1  1.169923120498791
               1.683340484744799 664  1.36   .85  -1.9 -1.54  -.68   0 1  2.282959490396854
               .4890786543515295 665 -1.53  2.88 -1.04  1.03 -1.51   0 1  4.042932941219418
               2.024558150571447 666  1.54  -4.5 -4.49   .31  -2.6   0 1 -.4668957188768061
              -.3639655102150915 667 -6.04   .38  2.88   .75  1.14   0 1 -5.438906417704657
               2.024558150571447 668 -3.07 -2.81   .73  1.66   -.5   0 1  -1.03380138198852
                2.53638464931142 669  7.75 -2.05  -.32  1.19   .45   0 1  4.103701862358857
               .6596874872648536 670   .56  3.35 -1.23 -2.11    -1   0 1  4.884271693531828
              -.0227478443884431 671 -2.17    -3 -2.07   .45   .17 .01 1 -5.998214832502895
               2.024558150571447 672 -5.77 -3.56  3.13  2.27     3 .01 1 -9.570953046717952
               1.000905153091502 673  -.07   .87  -.03  2.44  2.09 .02 1 -3.224477640041395
               1.683340484744799 674  6.96  1.01   1.3   .58   .07 .02 1  7.358411454974729
              end
              format %tm modate
              Now if I run the code
              Code:
              xtreg company modate
              bys company : reg return smb_5 hml cma rmw zdeals, vce(robust)
              I get a correlation of .5677 for zdelas

              Leaving my data in long format, drop every company except 1 and run the regression without bys company
              Code:
              drop if company != 1
              reg return mktminusrf smb_5 hml rmw cma zdeals, vce(robust)
              This provides me with a correlation of .1911 of zdeals.

              Thanks

              //
              EDIT:: Never mind I just saw that I forgot one independet variable. Now the results are the same. However, is my method correct to do a linear regression?

              If I want to do a pooled OLS I use the following code
              Code:
               xtset company modate
              reg return mktminusrf smb_5 hml rmw cma zdeals i.company, vce(cluster company)
              Is this correct? I used the methodology of post #3
              Last edited by Marius Bauer; 07 Jan 2021, 09:10.

              Comment


              • #8
                Marius:
                some comments about your last post:
                1) -xtset-ting the data before going -regress- is redundant, as it is mandatory before -xt- commands only;
                2)
                Code:
                 reg return smb_5 hml i.modate if company==1
                and
                Code:
                bysort company: reg return smb_5 hml i.modate
                should give you the same results for -company==1- (ie, the only panel identifier reported in your data example);
                3) -robust- and -cluster- options behave differently under -regress- (where -robust- takes heteroskedasticity only into account) and -xtreg- (where both options do the very same job, that is taking autocorrelation and/or heteroskedasticity into account).
                Kind regards,
                Carlo
                (Stata 19.0)

                Comment

                Working...
                X