Announcement

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

  • Capturing summary stat with outreg2

    Dear all,

    I want to apply Lewbel (2012)'s heteroscedasticity-based identification approach. I am interested in capturing the summary statistic (specifically the Kleibergen-Paap rk Wald F statistic, p-value of Hansen J statistic, and p-value of Anderson-Rubin Wald test) using outreg2 in Stata. Could anyone help me in this regard? Thank you, and here is an example data and code.

    Code:
    ----------------------- copy starting from the next line -----------------------
    
    
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input int depth long(northing easting) byte collection
    7620 60840 29240 3
    7627 60840 29840 3
    7633 60840 30200 3
    7636 60840 30350 3
    7642 60840 30650 3
    7645 60840 30800 3
    7657 60840 31280 3
    7666 60840 31640 3
    7669 60840 31730 3
    7677 60840 32000 3
    7685 60840 32270 3
    7698 60840 32720 3
    7710 60840 33080 3
    7723 60840 33500 3
    7724 60840 33530 3
    7732 60840 33770 3
    7733 60840 33800 3
    7746 60840 34190 3
    7756 60840 34520 3
    7768 60840 34880 3
    7772 60840 35030 3
    7777 60840 35195 3
    7778 60840 35240 3
    7791 60840 35720 3
    7795 60840 35840 3
    7796 60840 35900 3
    7813 60840 36680 3
    7814 60840 36740 3
    7820 60840 37040 3
    7821 60840 37100 3
    7824 60840 37280 3
    7835 60840 37940 3
    7837 60840 38024 3
    7840 60840 38210 3
    7842 60840 38300 3
    7847 60840 38600 3
    7849 60840 38660 3
    7852 60840 38840 3
    7866 60840 39476 3
    7869 60840 39650 3
    7870 60840 39680 3
    7872 60840 39800 3
    7872 60840 39830 3
    7875 60840 40040 3
    7875 60840 40100 2
    7871 60840 40784 3
    7863 60840 41240 3
    7859 60840 41420 3
    7858 60840 41450 3
    7850 60840 41780 3
    7833 60840 42320 3
    7829 60840 42440 3
    7819 60840 42740 3
    7817 60840 42800 3
    7809 60840 43010 3
    7782 60840 43700 3
    7781 60840 43730 3
    7770 60840 44000 3
    7762 60840 44180 3
    7761 60840 44198 3
    7759 60840 44240 3
    7742 60840 44660 3
    7740 60840 44690 3
    7723 60840 45080 3
    7705 60840 45500 3
    7698 60840 45680 3
    7674 60840 46250 3
    7663 60840 46520 3
    7654 60840 46760 3
    7646 60840 46940 3
    7646 60840 46955 3
    7622 60840 47600 3
    7611 60840 47900 3
    7607 60840 48020 3
    7600 60840 48200 3
    7590 60840 48500 3
    7580 60840 48800 3
    7562 60840 49400 3
    7558 60840 49520 3
    7556 60840 49610 3
    7638 61410 29240 3
    7644 61410 29840 3
    7649 61410 30200 3
    7651 61410 30350 3
    7657 61410 30650 3
    7661 61410 30800 3
    7673 61410 31280 3
    7682 61410 31640 3
    7685 61410 31730 3
    7693 61410 32000 3
    7701 61410 32270 3
    7714 61410 32720 3
    7725 61410 33080 3
    7739 61410 33500 3
    7740 61410 33530 3
    7748 61410 33770 3
    7749 61410 33800 3
    7762 61410 34190 3
    7773 61410 34520 3
    7784 61410 34880 3
    end
    label values collection type
    label def type 2 "Estimated", modify
    label def type 3 "Interpolated", modify
    xi: ivreg2h depth (northing=) easting collection , cluster (depth) first outreg2 using Table1.doc,replace dec(3) keep(northing) addtext(Other controls, Yes)
    Last edited by Bahre Gebkir; 19 Dec 2024, 05:18.

  • #2
    outreg2 and ivreg2h are from SSC (FAQ Advice #12). See example 9 of the documentation:


    Example 9. Adding r( ) e( ) scalars


    Additional statistics may be added with addstat( ) or addtext( ). Values stored in macros r( ), e( ), or s( ) can be included directly. You can see what values
    are available by typing ereturn list or return list.

    To test the equality of two of the estimated coefficients and report the results in the table, note that test will sometimes return chi-squared, then you would
    instead use addstat(chi-square test, r(chi2)):

    reg mpg foreign weight length
    test foreign length
    outreg2 using myfile, adds(F-test, r(F), Prob > F, `r(p)') replace
    seeout
    To see how these statistics are stored in e(), run

    Code:
    ereturn list
    immediately after executing the ivreg2h command.

    Comment


    • #3
      Excuse me ,
      I have problem actually. I am using the command:
      ivreg2h income $covlist (depression = death)
      and it generates three sets of results:
      – With IV
      – With generated instruments
      – With both combined

      However, outreg2 only shows the last table.
      How can I export or display all three results/tables from my regression, since the command outputs them at the same time?

      Thank you for your help!

      Comment


      • #4
        You should see that the command saves these under different names. Using the data example in #1:

        Code:
        * Example generated by -dataex-. For more info, type help dataex
        clear
        input int depth long(northing easting) byte collection
        7620 60840 29240 3
        7627 60840 29840 3
        7633 60840 30200 3
        7636 60840 30350 3
        7642 60840 30650 3
        7645 60840 30800 3
        7657 60840 31280 3
        7666 60840 31640 3
        7669 60840 31730 3
        7677 60840 32000 3
        7685 60840 32270 3
        7698 60840 32720 3
        7710 60840 33080 3
        7723 60840 33500 3
        7724 60840 33530 3
        7732 60840 33770 3
        7733 60840 33800 3
        7746 60840 34190 3
        7756 60840 34520 3
        7768 60840 34880 3
        7772 60840 35030 3
        7777 60840 35195 3
        7778 60840 35240 3
        7791 60840 35720 3
        7795 60840 35840 3
        7796 60840 35900 3
        7813 60840 36680 3
        7814 60840 36740 3
        7820 60840 37040 3
        7821 60840 37100 3
        7824 60840 37280 3
        7835 60840 37940 3
        7837 60840 38024 3
        7840 60840 38210 3
        7842 60840 38300 3
        7847 60840 38600 3
        7849 60840 38660 3
        7852 60840 38840 3
        7866 60840 39476 3
        7869 60840 39650 3
        7870 60840 39680 3
        7872 60840 39800 3
        7872 60840 39830 3
        7875 60840 40040 3
        7875 60840 40100 2
        7871 60840 40784 3
        7863 60840 41240 3
        7859 60840 41420 3
        7858 60840 41450 3
        7850 60840 41780 3
        7833 60840 42320 3
        7829 60840 42440 3
        7819 60840 42740 3
        7817 60840 42800 3
        7809 60840 43010 3
        7782 60840 43700 3
        7781 60840 43730 3
        7770 60840 44000 3
        7762 60840 44180 3
        7761 60840 44198 3
        7759 60840 44240 3
        7742 60840 44660 3
        7740 60840 44690 3
        7723 60840 45080 3
        7705 60840 45500 3
        7698 60840 45680 3
        7674 60840 46250 3
        7663 60840 46520 3
        7654 60840 46760 3
        7646 60840 46940 3
        7646 60840 46955 3
        7622 60840 47600 3
        7611 60840 47900 3
        7607 60840 48020 3
        7600 60840 48200 3
        7590 60840 48500 3
        7580 60840 48800 3
        7562 60840 49400 3
        7558 60840 49520 3
        7556 60840 49610 3
        7638 61410 29240 3
        7644 61410 29840 3
        7649 61410 30200 3
        7651 61410 30350 3
        7657 61410 30650 3
        7661 61410 30800 3
        7673 61410 31280 3
        7682 61410 31640 3
        7685 61410 31730 3
        7693 61410 32000 3
        7701 61410 32270 3
        7714 61410 32720 3
        7725 61410 33080 3
        7739 61410 33500 3
        7740 61410 33530 3
        7748 61410 33770 3
        7749 61410 33800 3
        7762 61410 34190 3
        7773 61410 34520 3
        7784 61410 34880 3
        end
        label values collection type
        label def type 2 "Estimated", modify
        label def type 3 "Interpolated", modify
        
        xi: ivreg2h depth (northing=collection) easting, cluster (depth) 
        outreg2 [StdIV GenInst GenExtInst] using Table1.doc,replace dec(3)
        Res.:

        Code:
        . xi: ivreg2h depth (northing=collection) easting, cluster (depth) 
        
        Standard IV Results
        
        
        IV (2SLS) estimation
        --------------------
        
        Estimates efficient for homoskedasticity only
        Statistics robust to heteroskedasticity and clustering on depth
        
        Number of clusters (depth) =        91                Number of obs =      100
                                                              F(  2,    90) =    76.80
                                                              Prob > F      =   0.0000
        Total (centered) SS     =    768350.11                Centered R2   = -14.3997
        Total (uncentered) SS   =   5988695845                Uncentered R2 =   0.9980
        Residual SS             =  11832382.57                Root MSE      =      344
        
        ------------------------------------------------------------------------------
                     |               Robust
               depth | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
            northing |  -1.786314    .301995    -5.92   0.000    -2.378213   -1.194415
             easting |   -.034002   .0027277   -12.47   0.000    -.0393482   -.0286557
               _cons |   117917.8   18410.98     6.40   0.000     81832.97    154002.7
        ------------------------------------------------------------------------------
        Underidentification test (Kleibergen-Paap rk LM statistic):              1.009
                                                           Chi-sq(1) P-val =    0.3150
        ------------------------------------------------------------------------------
        Weak identification test (Cragg-Donald Wald F statistic):                0.147
                                 (Kleibergen-Paap rk Wald F statistic):         27.792
        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.
        NB: Critical values are for Cragg-Donald F statistic and i.i.d. errors.
        ------------------------------------------------------------------------------
        Warning: estimated covariance matrix of moment conditions not of full rank.
                 overidentification statistic not reported, and standard errors and
                 model tests should be interpreted with caution.
        Possible causes:
                 number of clusters insufficient to calculate robust covariance matrix
                 singleton dummy variable (dummy with one 1 and N-1 0s or vice versa)
        partial option may address problem.
        ------------------------------------------------------------------------------
        Instrumented:         northing
        Included instruments: easting
        Excluded instruments: collection
        ------------------------------------------------------------------------------
        
        IV with Generated Instruments only
        
        Instruments created from Z:
        easting
        
        IV (2SLS) estimation
        --------------------
        
        Estimates efficient for homoskedasticity only
        Statistics robust to heteroskedasticity and clustering on depth
        
        Number of clusters (depth) =        91                Number of obs =      100
                                                              F(  2,    90) =     2.18
                                                              Prob > F      =   0.1190
        Total (centered) SS     =    768350.11                Centered R2   =  -0.1366
        Total (uncentered) SS   =   5988695845                Uncentered R2 =   0.9999
        Residual SS             =  873339.8416                Root MSE      =    93.45
        
        ------------------------------------------------------------------------------
                     |               Robust
               depth | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
            northing |   .0914778   .0455883     2.01   0.045     .0021263    .1808293
             easting |   .0017621   .0018002     0.98   0.328    -.0017662    .0052904
               _cons |   2095.034   2788.969     0.75   0.453    -3371.244    7561.312
        ------------------------------------------------------------------------------
        Underidentification test (Kleibergen-Paap rk LM statistic):             32.324
                                                           Chi-sq(1) P-val =    0.0000
        ------------------------------------------------------------------------------
        Weak identification test (Cragg-Donald Wald F statistic):              298.369
                                 (Kleibergen-Paap rk Wald F statistic):        334.381
        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.
        NB: Critical values are for Cragg-Donald F statistic and i.i.d. errors.
        ------------------------------------------------------------------------------
        Hansen J statistic (overidentification test of all instruments):         0.000
                                                         (equation exactly identified)
        ------------------------------------------------------------------------------
        Instrumented:         northing
        Included instruments: easting
        Excluded instruments: northing_easting_g
        ------------------------------------------------------------------------------
        
        IV with Generated Instruments and External Instruments
        
        Testing Orthogonality of Instruments created from Z:
        easting
        
        IV (2SLS) estimation
        --------------------
        
        Estimates efficient for homoskedasticity only
        Statistics robust to heteroskedasticity and clustering on depth
        
        Number of clusters (depth) =        91                Number of obs =      100
                                                              F(  2,    90) =     9.07
                                                              Prob > F      =   0.0003
        Total (centered) SS     =    768350.11                Centered R2   =   0.0437
        Total (uncentered) SS   =   5988695845                Uncentered R2 =   0.9999
        Residual SS             =  734739.4144                Root MSE      =    85.72
        
        ------------------------------------------------------------------------------
                     |               Robust
               depth | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
            northing |  -.1412037   .0383198    -3.68   0.000     -.216309   -.0660983
             easting |  -.0026695   .0022011    -1.21   0.225    -.0069835    .0016445
               _cons |    16446.9   2401.288     6.85   0.000     11740.46    21153.34
        ------------------------------------------------------------------------------
        Underidentification test (Kleibergen-Paap rk LM statistic):             39.588
                                                           Chi-sq(2) P-val =    0.0000
        ------------------------------------------------------------------------------
        Weak identification test (Cragg-Donald Wald F statistic):              368.367
                                 (Kleibergen-Paap rk Wald F statistic):        158.769
        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.
        NB: Critical values are for Cragg-Donald F statistic and i.i.d. errors.
        ------------------------------------------------------------------------------
        Hansen J statistic (overidentification test of all instruments):         1.045
                                                           Chi-sq(1) P-val =    0.3067
        -orthog- option:
        Hansen J statistic (eqn. excluding suspect orthog. conditions):          0.000
                                                           Chi-sq(0) P-val =         .
        C statistic (exogeneity/orthogonality of suspect instruments):           1.045
                                                           Chi-sq(1) P-val =    0.3067
        Instruments tested:   collection
        ------------------------------------------------------------------------------
        Instrumented:         northing
        Included instruments: easting
        Excluded instruments: collection northing_easting_g
        ------------------------------------------------------------------------------
        
        -----------------------------------------------------------
            Variable |    StdIV         GenInst       GenExtInst   
        -------------+---------------------------------------------
            northing |       -1.786         .09148         -.1412  
                     |         .302          .0456          .0383  
             easting |        -.034        .001762        -.00267  
                     |       .00273          .0018          .0022  
               _cons |       117918           2095          16447  
                     |        18411           2789           2401  
        -------------+---------------------------------------------
                   N |          100            100            100  
                rmse |          344           93.5           85.7  
                   j |            .              0           1.04  
                 jdf |            0              0              1  
                  jp |                                       .307  
        -----------------------------------------------------------
                                                       Legend: b/se
        
        . 
        . outreg2 [StdIV GenInst GenExtInst] using Table1.doc,replace dec(3)
        Table1.doc
        dir : seeout
        Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	21.1 KB
ID:	1782295

        Comment

        Working...
        X