Announcement

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

  • Differences in estimation of SEs between xtivreg & xtivreg2

    This post discusses the following well known external ado programs: xtoverid , xtivreg2, ivreg2 .
    I have that latest versions of each of these. I'm running Stata 12 but on my work station with Stata 14.1 it's the same.

    Iv'e noticed through xtoverid undocumented noi option, that the estimation of SEs between Stata's built in xtivreg command and xtoverid differs.
    xtoverid utilizees xtivreg2 for estimation so these can be traced back to differences in SEs between xtivreg & xtivreg. The question is which one is preferable and why is there a difference?

    Here's a silly do that will replicate this:
    Code:
    sysuse nlswide1, clear
    gen id = _n
    reshape long age count collgrad c_city union ttl_exp tenure hours wage, i(id) j(year)
    xtset i year
    xtivreg wage (tenure = hours) collgrad, fe
    estimates store xtivreg
    xtivreg2 wage (tenure = hours) collgrad, fe
    estimates store xtivreg2
    
    estimates table xtivreg xtivreg2, se
    and the output clearly shows the differnce between the SEs (in red):

    Code:
    ----------------------------------------
        Variable |   xtivreg        xtivreg2      
    -------------+--------------------------
          tenure | -.23157191   -.23157191  
                 |  .86449019    .76240868 
        collgrad |  30.426044    30.426044  
                 |  27.655421    24.389789  
           _cons |  1.4035523              
                 |  2.6004731              
    ----------------------------------------
    Last edited by Ariel Karlinsky; 02 May 2016, 05:32.

  • #2
    use small option in xtivreg2 to get the same SEs as in xtivreg

    HTML Code:
    sysuse nlswide1, clear
    gen id = _n
    reshape long age count collgrad c_city union ttl_exp tenure hours wage, i(id) j(year)
    xtset i year
    xtivreg wage (tenure = hours) collgrad, fe
    estimates store xtivreg
    xtivreg2 wage (tenure = hours) collgrad, fe small
    estimates store xtivreg2
    
    estimates table xtivreg xtivreg2, se
    With large-sample statistics, the covariance matrix has the adjustment (N-N_g);
    with small-sample statistics, the covariance matrix has the adjustment (N-N_g-K),
    where K is the number of regressors.
    Last edited by Emad Shehata; 02 May 2016, 09:53.
    Emad A. Shehata
    Professor (PhD Economics)
    Agricultural Research Center - Agricultural Economics Research Institute - Egypt
    Email: [email protected]
    IDEAS: http://ideas.repec.org/f/psh494.html
    EconPapers: http://econpapers.repec.org/RAS/psh494.htm
    Google Scholar: http://scholar.google.com/citations?...r=cOXvc94AAAAJ

    Comment


    • #3
      Thanks. this issue arose in my research which has about 1.3 Million observations and 150K panel groups - so I probably don't need to adjust for small sample, am I right?

      Also, as I said in the original post - the issue first came about while looking at the output of xtoverid after running xtivreg Random Effects model. and I noticed that xtoverid's estimation (which relies on xtivreg2) returns different SEs:

      Code:
      . xtivreg wage (tenure = hours age) collgrad, first
      
      First-stage G2SLS regression
                                                       Number of obs    =         18
                                                       Wald chi(3)      =        124
                                                       Prob > chi2      =     0.0000
      ------------------------------------------------------------------------------
            tenure |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
          collgrad |    .765833   1.656756     0.46   0.644     -2.48135    4.013016
             hours |     .20045   .0874043     2.29   0.022     .0291407    .3717593
               age |   .2684181    .026844    10.00   0.000      .215805    .3210313
             _cons |  -12.53995   3.324454    -3.77   0.000    -19.05577   -6.024144
      ------------------------------------------------------------------------------
      
      G2SLS random-effects IV regression              Number of obs      =        18
      Group variable: id                              Number of groups   =         9
      
      R-sq:  within  = 0.7942                         Obs per group: min =         2
             between = 0.5361                                        avg =       2.0
             overall = 0.6614                                        max =         2
      
                                                      Wald chi2(2)       =     40.14
      corr(u_i, X)       = 0 (assumed)                Prob > chi2        =    0.0000
      
      ------------------------------------------------------------------------------
              wage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
            tenure |   .6361275   .1322349     4.81   0.000      .376952    .8953031
          collgrad |   3.301938    2.08222     1.59   0.113    -.7791381    7.383014
             _cons |   3.634081   .6243019     5.82   0.000     2.410472    4.857691
      -------------+----------------------------------------------------------------
           sigma_u |  1.0911996
           sigma_e |  1.2966394
               rho |  .41459632   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      Instrumented:   tenure
      Instruments:    collgrad hours age
      ------------------------------------------------------------------------------
      
      . xtoverid, noi
      
      First-stage regressions
      -----------------------
      
      
      First-stage regression of __00000H:
      
      Statistics consistent for homoskedasticity only
      Number of obs =                     18
      ------------------------------------------------------------------------------
          __00000H |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
          __00000K |     .20045   .0874043     2.29   0.038     .0129864    .3879136
          __00000N |   .2684181    .026844    10.00   0.000     .2108436    .3259927
          __00000Q |    .765833   1.656756     0.46   0.651    -2.787556    4.319222
          __00000D |  -12.53995   3.324454    -3.77   0.002     -19.6702   -5.409709
      ------------------------------------------------------------------------------
      F test of excluded instruments:
        F(  2,    14) =    50.09
        Prob > F      =   0.0000
      Sanderson-Windmeijer multivariate F test of excluded instruments:
        F(  2,    14) =    50.09
        Prob > F      =   0.0000
      
      
      
      Summary results for first-stage regressions
      -------------------------------------------
      
                                                 (Underid)            (Weak id)
      Variable     | F(  2,    14)  P-val | SW Chi-sq(  2) P-val | SW F(  2,    14)
      __00000H     |      50.09    0.0000 |      128.81   0.0000 |       50.09
      
      Stock-Yogo weak ID F test critical values for single endogenous regressor:
                                         10% maximal IV size             19.93
                                         15% maximal IV size             11.59
                                         20% maximal IV size              8.75
                                         25% maximal IV size              7.25
      Source: Stock-Yogo (2005).  Reproduced by permission.
      NB: Critical values are for Sanderson-Windmeijer F statistic.
      
      Underidentification test
      Ho: matrix of reduced form coefficients has rank=K1-1 (underidentified)
      Ha: matrix has rank=K1 (identified)
      Anderson canon. corr. LM statistic       Chi-sq(2)=15.79    P-val=0.0004
      
      Weak identification test
      Ho: equation is weakly identified
      Cragg-Donald Wald F statistic                                      50.09
      
      Stock-Yogo weak ID test critical values for K1=1 and L1=2:
                                         10% maximal IV size             19.93
                                         15% maximal IV size             11.59
                                         20% maximal IV size              8.75
                                         25% maximal IV size              7.25
      Source: Stock-Yogo (2005).  Reproduced by permission.
      
      Weak-instrument-robust inference
      Tests of joint significance of endogenous regressors B1 in main equation
      Ho: B1=0 and orthogonality conditions are valid
      Anderson-Rubin Wald test           F(2,14)=       20.19     P-val=0.0001
      Anderson-Rubin Wald test           Chi-sq(2)=     51.91     P-val=0.0000
      Stock-Wright LM S statistic        Chi-sq(2)=     13.37     P-val=0.0013
      
      Number of observations               N  =         18
      Number of regressors                 K  =          3
      Number of endogenous regressors      K1 =          1
      Number of instruments                L  =          4
      Number of excluded instruments       L1 =          2
      
      IV (2SLS) estimation
      --------------------
      
      Estimates efficient for homoskedasticity only
      Statistics consistent for homoskedasticity only
      
                                                            Number of obs =       18
                                                            F(  3,    15) =    71.22
                                                            Prob > F      =   0.0000
      Total (centered) SS     =  85.16833116                Centered R2   =   0.7121
      Total (uncentered) SS   =    368.81094                Uncentered R2 =   0.9335
      Residual SS             =  24.52038882                Root MSE      =    1.167
      
      ------------------------------------------------------------------------------
          __00000F |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
          __00000H |   .6361275   .1207134     5.27   0.000     .3995337    .8727214
          __00000Q |   3.301938   1.900798     1.74   0.082    -.4235578    7.027434
          __00000D |   3.634081   .5699071     6.38   0.000     2.517084    4.751079
      ------------------------------------------------------------------------------
      Underidentification test (Anderson canon. corr. LM statistic):          15.793
                                                         Chi-sq(2) P-val =    0.0004
      ------------------------------------------------------------------------------
      Weak identification test (Cragg-Donald Wald F statistic):               50.093
      Stock-Yogo weak ID test critical values: 10% maximal IV size             19.93
                                               15% maximal IV size             11.59
                                               20% maximal IV size              8.75
                                               25% maximal IV size              7.25
      Source: Stock-Yogo (2005).  Reproduced by permission.
      ------------------------------------------------------------------------------
      Sargan statistic (overidentification test of all instruments):           3.509
                                                         Chi-sq(1) P-val =    0.0610
      ------------------------------------------------------------------------------
      Instrumented:         __00000H
      Included instruments: __00000Q __00000D
      Excluded instruments: __00000K __00000N
      ------------------------------------------------------------------------------
      
      Test of overidentifying restrictions: 
      Cross-section time-series model: xtivreg g2sls   
      Sargan-Hansen statistic   3.509  Chi-sq(1)    P-value = 0.0610
      What's intreseting here also is that the First Stage estimation is identical, but the second stage is not. Since Random Effects is not documented on xtivreg2, I don't know what causes this.

      Comment


      • #4
        Mark Schaffer - Can you shed some light on this? Iv'e also encountered this old thread where you question what the "small" adjustment in xtreg\xtivreg does - and I don't see you quite got an answer there...

        Comment


        • #5
          small option is just to correct degrees of freedom
          So, se. will differ between xtivreg and xtivreg2
          Emad A. Shehata
          Professor (PhD Economics)
          Agricultural Research Center - Agricultural Economics Research Institute - Egypt
          Email: [email protected]
          IDEAS: http://ideas.repec.org/f/psh494.html
          EconPapers: http://econpapers.repec.org/RAS/psh494.htm
          Google Scholar: http://scholar.google.com/citations?...r=cOXvc94AAAAJ

          Comment


          • #6
            but xtivreg (built in) also has "small" option, and the only thing it does is report t stats instead of Z stats. SE's remain the same:

            Code:
            ----------------------------------------------------------------------------------------------------------------------------------------
                  name:  <unnamed>
                   log:  C:\Users\karli_000\Desktop\statalist.log
              log type:  text
             opened on:   9 May 2016, 12:15:55
            
            . sysuse nlswide1, clear
            (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
            
            . gen id = _n
            
            . reshape long age count collgrad c_city union ttl_exp tenure hours wage, i(id) j(year)
            (note: j = 68 88)
            
            Data                               wide   ->   long
            -----------------------------------------------------------------------------
            Number of obs.                        9   ->      18
            Number of variables                  20   ->      12
            j variable (2 values)                     ->   year
            xij variables:
                                        age68 age88   ->   age
                                    count68 count88   ->   count
                              collgrad68 collgrad88   ->   collgrad
                                  c_city68 c_city88   ->   c_city
                                    union68 union88   ->   union
                                ttl_exp68 ttl_exp88   ->   ttl_exp
                                  tenure68 tenure88   ->   tenure
                                    hours68 hours88   ->   hours
                                      wage68 wage88   ->   wage
            -----------------------------------------------------------------------------
            
            . xtset i year
                   panel variable:  id (strongly balanced)
                    time variable:  year, 68 to 88, but with gaps
                            delta:  1 unit
            
            . xtivreg wage (tenure = hours) collgrad, fe
            
            Fixed-effects (within) IV regression         Number of obs      =           18
            Group variable: id                           Number of groups   =            9
            
            R-sq:  within  = 0.4748                      Obs per group: min =            2
                   between = 0.3393                                     avg =          2.0
                   overall = 0.2588                                     max =            2
            
                                                         Wald chi2(2)       =       158.46
            corr(u_i, Xb)  = -0.9454                     Prob > chi2        =       0.0000
            
            ------------------------------------------------------------------------------
                    wage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                  tenure |  -.2315719   .8644902    -0.27   0.789    -1.925942    1.462798
                collgrad |   30.42604   27.65542     1.10   0.271    -23.77759    84.62967
                   _cons |   1.403552   2.600473     0.54   0.589    -3.693281    6.500386
            -------------+----------------------------------------------------------------
                 sigma_u |   6.350528
                 sigma_e |  2.1424307
                     rho |  .89781635   (fraction of variance due to u_i)
            ------------------------------------------------------------------------------
            F  test that all u_i=0:     F(8,7) =     0.87             Prob > F    = 0.5811
            ------------------------------------------------------------------------------
            Instrumented:   tenure
            Instruments:    collgrad hours
            ------------------------------------------------------------------------------
            
            . xtivreg wage (tenure = hours) collgrad, fe small
            
            Fixed-effects (within) IV regression         Number of obs      =           18
            Group variable: id                           Number of groups   =            9
            
            R-sq:  within  = 0.4748                      Obs per group: min =            2
                   between = 0.3393                                     avg =          2.0
                   overall = 0.2588                                     max =            2
            
                                                            F(11,7)         =        4.57
            corr(u_i, Xb)  = -0.9454                        Prob > F        =       0.0538
            
            ------------------------------------------------------------------------------
                    wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                  tenure |  -.2315719   .8644902    -0.27   0.797    -2.275766    1.812623
                collgrad |   30.42604   27.65542     1.10   0.308    -34.96864    95.82072
                   _cons |   1.403552   2.600473     0.54   0.606    -4.745589    7.552694
            -------------+----------------------------------------------------------------
                 sigma_u |   6.350528
                 sigma_e |  2.1424307
                     rho |  .89781635   (fraction of variance due to u_i)
            ------------------------------------------------------------------------------
            F  test that all u_i=0:     F(8,7) =     0.87             Prob > F    = 0.5811
            ------------------------------------------------------------------------------
            Instrumented:   tenure
            Instruments:    collgrad hours
            ------------------------------------------------------------------------------
            
            . xtivreg2 wage (tenure = hours) collgrad, fe
            
            FIXED EFFECTS ESTIMATION
            ------------------------
            Number of groups =         9                    Obs per group: min =         2
                                                                           avg =       2.0
                                                                           max =         2
            
            IV (2SLS) estimation
            --------------------
            
            Estimates efficient for homoskedasticity only
            Statistics consistent for homoskedasticity only
            
                                                                  Number of obs =       18
                                                                  F(  2,     7) =     4.57
                                                                  Prob > F      =   0.0538
            Total (centered) SS     =  61.18027552                Centered R2   =   0.4748
            Total (uncentered) SS   =  61.18027552                Uncentered R2 =   0.4748
            Residual SS             =  32.13006463                Root MSE      =    1.889
            
            ------------------------------------------------------------------------------
                    wage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                  tenure |  -.2315719   .7624087    -0.30   0.761    -1.725865    1.262722
                collgrad |   30.42604   24.38979     1.25   0.212    -17.37706    78.22915
            ------------------------------------------------------------------------------
            Underidentification test (Anderson canon. corr. LM statistic):           1.084
                                                               Chi-sq(1) P-val =    0.2979
            ------------------------------------------------------------------------------
            Weak identification test (Cragg-Donald Wald F statistic):                0.958
            Stock-Yogo weak ID test critical values: 10% maximal IV size             16.38
                                                     15% maximal IV size              8.96
                                                     20% maximal IV size              6.66
                                                     25% maximal IV size              5.53
            Source: Stock-Yogo (2005).  Reproduced by permission.
            ------------------------------------------------------------------------------
            Sargan statistic (overidentification test of all instruments):           0.000
                                                             (equation exactly identified)
            ------------------------------------------------------------------------------
            Instrumented:         tenure
            Included instruments: collgrad
            Excluded instruments: hours
            ------------------------------------------------------------------------------
            
            . xtivreg2 wage (tenure = hours) collgrad, fe small
            
            FIXED EFFECTS ESTIMATION
            ------------------------
            Number of groups =         9                    Obs per group: min =         2
                                                                           avg =       2.0
                                                                           max =         2
            
            IV (2SLS) estimation
            --------------------
            
            Estimates efficient for homoskedasticity only
            Statistics consistent for homoskedasticity only
            
                                                                  Number of obs =       18
                                                                  F(  2,     7) =     4.57
                                                                  Prob > F      =   0.0538
            Total (centered) SS     =  61.18027552                Centered R2   =   0.4748
            Total (uncentered) SS   =  61.18027552                Uncentered R2 =   0.4748
            Residual SS             =  32.13006463                Root MSE      =    2.142
            
            ------------------------------------------------------------------------------
                    wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                  tenure |  -.2315719   .8644902    -0.27   0.797    -2.275766    1.812623
                collgrad |   30.42604   27.65542     1.10   0.308    -34.96864    95.82072
            ------------------------------------------------------------------------------
            Underidentification test (Anderson canon. corr. LM statistic):           1.084
                                                               Chi-sq(1) P-val =    0.2979
            ------------------------------------------------------------------------------
            Weak identification test (Cragg-Donald Wald F statistic):                0.958
            Stock-Yogo weak ID test critical values: 10% maximal IV size             16.38
                                                     15% maximal IV size              8.96
                                                     20% maximal IV size              6.66
                                                     25% maximal IV size              5.53
            Source: Stock-Yogo (2005).  Reproduced by permission.
            ------------------------------------------------------------------------------
            Sargan statistic (overidentification test of all instruments):           0.000
                                                             (equation exactly identified)
            ------------------------------------------------------------------------------
            Instrumented:         tenure
            Included instruments: collgrad
            Excluded instruments: hours
            ------------------------------------------------------------------------------
            
            . log close
                  name:  <unnamed>
                   log:  C:\Users\karli_000\Desktop\statalist.log
              log type:  text
             closed on:   9 May 2016, 12:16:22
            ----------------------------------------------------------------------------------------------------------------------------------------

            Comment


            • #7
              Sorry for the bump, but is there anyway to go the other way around? replicate the SEs reported by xtivreg2/xtoverid with xtivreg? from what I gather it seems that the corrections used by xtivreg2/xtoverid are more generally acceptable

              Comment

              Working...
              X