Announcement

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

  • reg i.id i.year,vce(cl id) vs. xtreg i.year,fe r

    Dear all,
    We know "reg i.id i.year,vce(cl id)" is the same as "xtreg i.year,fe r",but why are the results of the two codes are different in standard error and t statistics.Here is the example.
    Code:
    . reg invest mvalue kstock i.company i.year,vce(cl company)
    
    Linear regression                               Number of obs     =        200
                                                    F(8, 9)           =          .
                                                    Prob > F          =          .
                                                    R-squared         =     0.9517
                                                    Root MSE          =     51.725
    
                                   (Std. Err. adjusted for 10 clusters in company)
    ------------------------------------------------------------------------------
                 |               Robust
          invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          mvalue |      0.118      0.011    10.60   0.000        0.093       0.143
          kstock |      0.358      0.049     7.29   0.000        0.247       0.469
                 |
         company |
              2  |    207.054     39.027     5.31   0.000      118.769     295.339
              3  |   -135.231     35.132    -3.85   0.004     -214.704     -55.758
              4  |     95.354     59.423     1.60   0.143      -39.070     229.778
              5  |     -5.439     50.629    -0.11   0.917     -119.969     109.092
              6  |    102.889     62.961     1.63   0.137      -39.539     245.316
              7  |     51.467     57.614     0.89   0.395      -78.864     181.798
              8  |     67.490     61.119     1.10   0.298      -70.770     205.751
              9  |     30.218     56.268     0.54   0.604      -97.070     157.505
             10  |    126.837     70.615     1.80   0.106      -32.905     286.579
                 |
            year |
           1936  |    -19.197     21.243    -0.90   0.390      -67.251      28.857
           1937  |    -40.690     34.158    -1.19   0.264     -117.961      36.581
           1938  |    -39.226     16.150    -2.43   0.038      -75.760      -2.692
           1939  |    -69.470     27.708    -2.51   0.033     -132.151      -6.790
           1940  |    -44.235     17.829    -2.48   0.035      -84.567      -3.903
           1941  |    -18.804     18.317    -1.03   0.331      -60.239      22.630
           1942  |    -21.140     14.537    -1.45   0.180      -54.025      11.745
           1943  |    -42.978     12.874    -3.34   0.009      -72.100     -13.855
           1944  |    -43.099     11.285    -3.82   0.004      -68.627     -17.571
           1945  |    -55.683     15.601    -3.57   0.006      -90.976     -20.390
           1946  |    -31.169     21.467    -1.45   0.180      -79.730      17.392
           1947  |    -39.392     27.132    -1.45   0.180     -100.769      21.984
           1948  |    -43.717     39.900    -1.10   0.302     -133.978      46.544
           1949  |    -73.495     39.260    -1.87   0.094     -162.307      15.317
           1950  |    -75.896     37.766    -2.01   0.075     -161.328       9.536
           1951  |    -62.481     50.717    -1.23   0.249     -177.211      52.249
           1952  |    -64.632     52.917    -1.22   0.253     -184.339      55.075
           1953  |    -67.718     44.894    -1.51   0.166     -169.276      33.840
           1954  |    -93.526     32.560    -2.87   0.018     -167.182     -19.870
                 |
           _cons |    -86.900     62.010    -1.40   0.195     -227.178      53.377
    ------------------------------------------------------------------------------
    
    . xtreg invest mvalue kstock i.year,fe r
    
    Fixed-effects (within) regression               Number of obs     =        200
    Group variable: company                         Number of groups  =         10
    
    R-sq:                                           Obs per group:
         within  = 0.7985                                         min =         20
         between = 0.8143                                         avg =       20.0
         overall = 0.8068                                         max =         20
    
                                                    F(9,9)            =          .
    corr(u_i, Xb)  = -0.3250                        Prob > F          =          .
    
                                   (Std. Err. adjusted for 10 clusters in company)
    ------------------------------------------------------------------------------
                 |               Robust
          invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          mvalue |      0.118      0.011    10.88   0.000        0.093       0.142
          kstock |      0.358      0.048     7.48   0.000        0.250       0.466
                 |
            year |
           1936  |    -19.197     20.699    -0.93   0.378      -66.021      27.626
           1937  |    -40.690     33.283    -1.22   0.253     -115.982      34.602
           1938  |    -39.226     15.736    -2.49   0.034      -74.825      -3.628
           1939  |    -69.470     26.999    -2.57   0.030     -130.546      -8.395
           1940  |    -44.235     17.372    -2.55   0.031      -83.534      -4.936
           1941  |    -18.804     17.847    -1.05   0.320      -59.178      21.569
           1942  |    -21.140     14.165    -1.49   0.170      -53.183      10.903
           1943  |    -42.978     12.544    -3.43   0.008      -71.354     -14.601
           1944  |    -43.099     10.996    -3.92   0.004      -67.973     -18.224
           1945  |    -55.683     15.202    -3.66   0.005      -90.072     -21.294
           1946  |    -31.169     20.917    -1.49   0.170      -78.487      16.148
           1947  |    -39.392     26.437    -1.49   0.170      -99.197      20.413
           1948  |    -43.717     38.879    -1.12   0.290     -131.666      44.233
           1949  |    -73.495     38.254    -1.92   0.087     -160.033      13.043
           1950  |    -75.896     36.798    -2.06   0.069     -159.140       7.348
           1951  |    -62.481     49.418    -1.26   0.238     -174.272      49.311
           1952  |    -64.632     51.562    -1.25   0.242     -181.274      52.009
           1953  |    -67.718     43.745    -1.55   0.156     -166.675      31.239
           1954  |    -93.526     31.726    -2.95   0.016     -165.296     -21.756
                 |
           _cons |    -32.836     19.783    -1.66   0.131      -77.588      11.915
    -------------+----------------------------------------------------------------
         sigma_u |  91.798268
         sigma_e |  51.724523
             rho |  .75902159   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    I find that the standard error and t statistic of kstock are different in reg i.id and xtreg,fe command.I don't know why.



    Many thanks in advance.
    Raymond
    Last edited by Raymond Zhang; 02 Feb 2021, 07:53.
    Best regards.

    Raymond Zhang
    Stata 17.0,MP

  • #2
    Raymond:
    because -xtreg,fe- computes the standard errors using the within variation only.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Originally posted by Carlo Lazzaro View Post
      Raymond:
      because -xtreg,fe- computes the standard errors using the within variation only.
      Dear Carlo Lazzaro ,I tried to add the option "dfadj",and adjust the degree of freedom in -xtreg,fe-.Then I get the same results.
      Code:
      webuse grunfeld,clear
      . reg invest mvalue kstock i.company i.year,vce(cl company)
      
      Linear regression                               Number of obs     =        200
                                                      F(8, 9)           =          .
                                                      Prob > F          =          .
                                                      R-squared         =     0.9517
                                                      Root MSE          =     51.725
      
                                     (Std. Err. adjusted for 10 clusters in company)
      ------------------------------------------------------------------------------
                   |               Robust
            invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
            mvalue |      0.118      0.011    10.60   0.000        0.093       0.143
            kstock |      0.358      0.049     7.29   0.000        0.247       0.469
                   |
           company |
                2  |    207.054     39.027     5.31   0.000      118.769     295.339
                3  |   -135.231     35.132    -3.85   0.004     -214.704     -55.758
                4  |     95.354     59.423     1.60   0.143      -39.070     229.778
                5  |     -5.439     50.629    -0.11   0.917     -119.969     109.092
                6  |    102.889     62.961     1.63   0.137      -39.539     245.316
                7  |     51.467     57.614     0.89   0.395      -78.864     181.798
                8  |     67.490     61.119     1.10   0.298      -70.770     205.751
                9  |     30.218     56.268     0.54   0.604      -97.070     157.505
               10  |    126.837     70.615     1.80   0.106      -32.905     286.579
                   |
              year |
             1936  |    -19.197     21.243    -0.90   0.390      -67.251      28.857
             1937  |    -40.690     34.158    -1.19   0.264     -117.961      36.581
             1938  |    -39.226     16.150    -2.43   0.038      -75.760      -2.692
             1939  |    -69.470     27.708    -2.51   0.033     -132.151      -6.790
             1940  |    -44.235     17.829    -2.48   0.035      -84.567      -3.903
             1941  |    -18.804     18.317    -1.03   0.331      -60.239      22.630
             1942  |    -21.140     14.537    -1.45   0.180      -54.025      11.745
             1943  |    -42.978     12.874    -3.34   0.009      -72.100     -13.855
             1944  |    -43.099     11.285    -3.82   0.004      -68.627     -17.571
             1945  |    -55.683     15.601    -3.57   0.006      -90.976     -20.390
             1946  |    -31.169     21.467    -1.45   0.180      -79.730      17.392
             1947  |    -39.392     27.132    -1.45   0.180     -100.769      21.984
             1948  |    -43.717     39.900    -1.10   0.302     -133.978      46.544
             1949  |    -73.495     39.260    -1.87   0.094     -162.307      15.317
             1950  |    -75.896     37.766    -2.01   0.075     -161.328       9.536
             1951  |    -62.481     50.717    -1.23   0.249     -177.211      52.249
             1952  |    -64.632     52.917    -1.22   0.253     -184.339      55.075
             1953  |    -67.718     44.894    -1.51   0.166     -169.276      33.840
             1954  |    -93.526     32.560    -2.87   0.018     -167.182     -19.870
                   |
             _cons |    -86.900     62.010    -1.40   0.195     -227.178      53.377
      ------------------------------------------------------------------------------
      
      . xtreg invest mvalue kstock i.year,fe r dfadj   //dfadj
      
      Fixed-effects (within) regression               Number of obs      =       200
      Group variable: company                         Number of groups   =        10
      
      R-sq:  within  = 0.7985                         Obs per group: min =        20
             between = 0.8143                                        avg =      20.0
             overall = 0.8068                                        max =        20
      
                                                      F(9,9)             =         .
      corr(u_i, Xb)  = -0.3250                        Prob > F           =         .
      
                                     (Std. Err. adjusted for 10 clusters in company)
      ------------------------------------------------------------------------------
                   |               Robust
            invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
            mvalue |      0.118      0.011    10.60   0.000        0.093       0.143
            kstock |      0.358      0.049     7.29   0.000        0.247       0.469
                   |
              year |
             1936  |    -19.197     21.243    -0.90   0.390      -67.251      28.857
             1937  |    -40.690     34.158    -1.19   0.264     -117.961      36.581
             1938  |    -39.226     16.150    -2.43   0.038      -75.760      -2.692
             1939  |    -69.470     27.708    -2.51   0.033     -132.151      -6.790
             1940  |    -44.235     17.829    -2.48   0.035      -84.567      -3.903
             1941  |    -18.804     18.317    -1.03   0.331      -60.239      22.630
             1942  |    -21.140     14.537    -1.45   0.180      -54.025      11.745
             1943  |    -42.978     12.874    -3.34   0.009      -72.100     -13.855
             1944  |    -43.099     11.285    -3.82   0.004      -68.627     -17.571
             1945  |    -55.683     15.601    -3.57   0.006      -90.976     -20.390
             1946  |    -31.169     21.467    -1.45   0.180      -79.730      17.392
             1947  |    -39.392     27.132    -1.45   0.180     -100.769      21.984
             1948  |    -43.717     39.900    -1.10   0.302     -133.978      46.544
             1949  |    -73.495     39.260    -1.87   0.094     -162.307      15.317
             1950  |    -75.896     37.766    -2.01   0.075     -161.328       9.536
             1951  |    -62.481     50.717    -1.23   0.249     -177.211      52.249
             1952  |    -64.632     52.917    -1.22   0.253     -184.339      55.075
             1953  |    -67.718     44.894    -1.51   0.166     -169.276      33.840
             1954  |    -93.526     32.560    -2.87   0.018     -167.182     -19.870
                   |
             _cons |    -32.836     20.303    -1.62   0.140      -78.764      13.091
      -------------+----------------------------------------------------------------
           sigma_u |  91.798268
           sigma_e |  51.724523
               rho |  .75902159   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      Best regards.

      Raymond Zhang
      Stata 17.0,MP

      Comment


      • #4
        Raymond:
        see: https://www.stata.com/statalist/arch.../msg00596.html
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Dear Carlo Lazzaro, so which kind of the model get the right stand error?-xtreg, fe r- or- reg i.id,vce(cl id)?
          Best regards.

          Raymond Zhang
          Stata 17.0,MP

          Comment


          • #6
            Raymond:
            actually I have never read about the option you used with -xtreg,fe-.
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment

            Working...
            X