Announcement

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

  • Export multiple xtabond2 results

    Hello Statalist users,

    I need help with exporting multiple xtbond2 estimations along with their post estimations results (AR1, AR2, Sargan, Hansen) into Word. publication quality level.
    example of my multiple commands
    xtabond2 L(0/1).ZS3 c.OBSR##c.EA_w Size AssetG ROA LoanAsset LiqR DepFL l.GDPG l.T10Y3M y*,gmm(L.ZS3 OBSR LiqR,laglimits(1 1)) iv(l.GDPG l.T10Y3M y*,eq(level)) iv(l.GDPG l.T10Y3M,eq(diff)) twostep robust small

    xtabond2 L(0/1).ZS3 c.OBSR##c.EA_w Size AssetG ROA LoanAsset LiqR LLPLR DepFL l.GDPG l.T10Y3M y*,gmm(L.ZS3 OBSR LiqR,laglimits(1 1)) iv(l.GDPG l.T10Y3M y*,eq(level)) iv(l.GDPG l.T10Y3M,eq(diff)) twostep robust small

    xtabond2 L(0/1).ZS3 c.OBSR##c.EA_w Size AssetG ROA LoanAsset LiqR LLPAR DepFL l.GDPG l.T10Y3M y*,gmm(L.ZS3 OBSR LiqR,laglimits(1 1)) iv(l.GDPG l.T10Y3M y*,eq(level)) iv(l.GDPG l.T10Y3M,eq(diff)) twostep robust small
    and here is sample of the results i get with each regression
    Code:
    xtabond2 L(0/1).ZS3 c.OBSR##c.EA_w Size AssetG  ROA LoanAsset LiqR DepFL  l.GDPG l.T10Y3M y*,gmm(L.ZS3 OBSR LiqR,laglimits(1 1)) iv(l.GDPG  l.T10Y3M y*,eq(level)) iv(l.GDPG l.T10Y3M,eq(diff)) twostep robust small
    Favoring space over speed. To switch, type or click on mata: mata set matafavor speed, perm.
    Warning: Two-step estimated covariance matrix of moments is singular.
      Using a generalized inverse to calculate optimal weighting matrix for two-step estimation.
      Difference-in-Sargan/Hansen statistics may be negative.
    
    Dynamic panel-data estimation, two-step system GMM
    ------------------------------------------------------------------------------
    Group variable: id                              Number of obs      =      2766
    Time variable : Year                            Number of groups   =       336
    Number of instruments = 61                      Obs per group: min =         1
    F(22, 335)    =  11490.11                                      avg =      8.23
    Prob > F      =     0.000                                      max =         9
    -------------------------------------------------------------------------------
                  |              Corrected
              ZS3 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    --------------+----------------------------------------------------------------
              ZS3 |
              L1. |   .9606215   .0519257    18.50   0.000     .8584799    1.062763
                  |
             OBSR |   .0166858   .0074719     2.23   0.026     .0019881    .0313835
             EA_w |   .0234135   .0110084     2.13   0.034     .0017592    .0450677
                  |
    c.OBSR#c.EA_w |  -.0015945   .0006956    -2.29   0.023    -.0029629   -.0002261
                  |
             Size |   .0499903   .0244027     2.05   0.041     .0019885    .0979921
           AssetG |  -.0023591   .0018319    -1.29   0.199    -.0059625    .0012443
              ROA |   .0040595   .0352507     0.12   0.908     -.065281    .0734001
        LoanAsset |   .0031209   .0038364     0.81   0.417    -.0044255    .0106672
             LiqR |  -.0025142   .0032188    -0.78   0.435    -.0088458    .0038174
            DepFL |   .0066999   .0037298     1.80   0.073    -.0006368    .0140366
                  |
             GDPG |
              L1. |  -.4352625   .2448995    -1.78   0.076     -.916997    .0464721
                  |
           T10Y3M |
              L1. |   -.019525   .0240011    -0.81   0.417    -.0667369     .027687
                  |
           yearD1 |          0  (omitted)
           yearD2 |          0  (omitted)
           yearD3 |  -.4798001   .2566407    -1.87   0.062    -.9846305    .0250302
           yearD4 |  -.2549777   .1369852    -1.86   0.064    -.5244372    .0144819
           yearD5 |  -.4169946   .2253129    -1.85   0.065     -.860201    .0262117
           yearD6 |  -.1418621    .053773    -2.64   0.009    -.2476374   -.0360869
           yearD7 |   .0177436   .0359721     0.49   0.622     -.053016    .0885032
           yearD8 |  -.5419371   .3025044    -1.79   0.074    -1.136985    .0531103
           yearD9 |  -.1840684   .1093741    -1.68   0.093    -.3992151    .0310783
          yearD10 |          0  (omitted)
            _cons |          0  (omitted)
    -------------------------------------------------------------------------------
    Instruments for first differences equation
      Standard
        D.(L.GDPG L.T10Y3M)
      GMM-type (missing=0, separate instruments for each period unless collapsed)
        L.(L.ZS3 OBSR LiqR)
    Instruments for levels equation
      Standard
        L.GDPG L.T10Y3M yearD1 yearD2 yearD3 yearD4 yearD5 yearD6 yearD7 yearD8
        yearD9 yearD10
        _cons
      GMM-type (missing=0, separate instruments for each period unless collapsed)
        D.(L.ZS3 OBSR LiqR)
    ------------------------------------------------------------------------------
    Arellano-Bond test for AR(1) in first differences: z =  -5.60  Pr > z =  0.000
    Arellano-Bond test for AR(2) in first differences: z =   0.19  Pr > z =  0.848
    ------------------------------------------------------------------------------
    Sargan test of overid. restrictions: chi2(38)   = 210.17  Prob > chi2 =  0.000
      (Not robust, but not weakened by many instruments.)
    Hansen test of overid. restrictions: chi2(38)   =  44.19  Prob > chi2 =  0.227
      (Robust, but weakened by many instruments.)
    
    Difference-in-Hansen tests of exogeneity of instrument subsets:
      GMM instruments for levels
        Hansen test excluding group:     chi2(12)   =  16.51  Prob > chi2 =  0.169
        Difference (null H = exogenous): chi2(26)   =  27.68  Prob > chi2 =  0.374
      iv(L.GDPG L.T10Y3M yearD1 yearD2 yearD3 yearD4 yearD5 yearD6 yearD7 yearD8 yearD9 yearD10, eq(level))
        Hansen test excluding group:     chi2(29)   =  38.98  Prob > chi2 =  0.102
        Difference (null H = exogenous): chi2(9)    =   5.20  Prob > chi2 =  0.816
      iv(L.GDPG L.T10Y3M, eq(diff))
        Hansen test excluding group:     chi2(36)   =  42.25  Prob > chi2 =  0.219
        Difference (null H = exogenous): chi2(2)    =   1.94  Prob > chi2 =  0.380
    what is the best command to do so?

    Thank you,
    Sad

  • #2
    It’s always helpful to share what you’ve tried and where you’ve hit a snag.

    The best command for this sort of thing is a matter of preference, but I tend to use esttab

    Since this is a user-generated command, start with:
    Code:
    ssc install esttab
    help esttab
    And the extensive web documentation.

    I’m not sure about the integration with word, but I’ve found the integration with LaTeX to be satisfactory.

    Comment


    • #3

      Thank you Arthur for the timely respond. I will try your advice using esttab. does it work with excel ?
      I did try
      outreg2 using myfile.doc, se bdec(3) e(ar1p ar2p hansenp sarganp) word replace
      it works ok for single regression results. I had issues for multiple estimations.

      Best,
      Sad

      Comment


      • #4
        sad Abu alim for multiple equations, you simply replace the word "replace" with append in the 2nd, 3rd.....equation

        Comment


        • #5
          You can also use asdoc, which can be used with almost all Stata commands. For nested tables, just add nest after comma. The orange colors in the following code show addition of asdoc to generate the following table. Here is a YouTube video on changing different options of asdoc when creating regression tables.https://www.youtube.com/watch?v=61ks3cMPz3c

          Code:
          * Install asdoc
          ssc install asdoc, replace
          use http://www.stata-press.com/data/r7/abdata.dta, clear
          asdoc xtabond2 n l.n l(0/1).(w k) yr1980-yr1984, gmm(l.n w k) iv(yr1980-yr1984, passthru) noleveleq small nest replace
          asdoc xtabond2 n l.n l(0/1).(w k) yr1980-yr1984, gmm(l.n w k) iv(yr1980-yr1984, mz) robust twostep small h(2) nest
          asdoc xtabond2 n l(1/2).n l(0/1).w l(0/2).(k ys) yr1980-yr1984, gmm(l.n w k) iv(yr1980-yr1984) robust twostep small nest
          Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	34.4 KB
ID:	1569005

          Regards
          --------------------------------------------------
          Attaullah Shah, PhD.
          Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
          FinTechProfessor.com
          https://asdocx.com
          Check out my asdoc program, which sends outputs to MS Word.
          For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

          Comment


          • #6
            Originally posted by arshad hayat View Post
            sad Abu alim for multiple equations, you simply replace the word "replace" with append in the 2nd, 3rd.....equation
            arshad,
            Thank you for your reply i will try this.

            Best wishes,
            Sad

            Comment


            • #7
              Originally posted by Attaullah Shah View Post
              You can also use asdoc, which can be used with almost all Stata commands. For nested tables, just add nest after comma. The orange colors in the following code show addition of asdoc to generate the following table. Here is a YouTube video on changing different options of asdoc when creating regression tables.https://www.youtube.com/watch?v=61ks3cMPz3c

              Code:
              * Install asdoc
              ssc install asdoc, replace
              use http://www.stata-press.com/data/r7/abdata.dta, clear
              asdoc xtabond2 n l.n l(0/1).(w k) yr1980-yr1984, gmm(l.n w k) iv(yr1980-yr1984, passthru) noleveleq small nest replace
              asdoc xtabond2 n l.n l(0/1).(w k) yr1980-yr1984, gmm(l.n w k) iv(yr1980-yr1984, mz) robust twostep small h(2) nest
              asdoc xtabond2 n l(1/2).n l(0/1).w l(0/2).(k ys) yr1980-yr1984, gmm(l.n w k) iv(yr1980-yr1984) robust twostep small nest
              [ATTACH=CONFIG]n1569005[/ATTACH]
              Dr Attallah,
              Thank you for Asdoc i use it for OLS FE and RE estimations and for Descriptive statistics tables it works great. i will try it for the xtabond2 now after your clarification.

              kind regards,
              Sad

              Comment


              • #8
                I know this comment is late but I came across this formula that makes this really easy as I was struggling to export results. It follows three simple stages:

                1. Run your dynamic GMM models y= f(y_1, x), starting with eststo: It could be just one model or many. Check the following example

                Code:
                eststo: xtabond2 FDI FDI GDP  TRADE  RENTS EXR  yr*, gmm(l.FDI  l(0/1).BIT l(0/1).GDP l(0/1).TRADE  l(0/2).RENTS l(0/1).EXR, collapse lag(1 1)) iv(BIT GDP TRADE  RENTS EXR  yr*, eq(level)) twostep robust small orthog
                You may write down your codes for multiple models and run them at the same time following the normal ways. In step 2, simply run the following code to display the results on your screen in tabular form.

                2. esttab

                Take note that at this stage, post estimation results would not be displayed on the table.

                3. The third stage depends on where you wish to export your results. It could be Latex (tex), word (rtf), excel or any other. Run the following code
                Code:
                esttab using results.rtf ,label se starlevels( * 0.10 ** 0.05 *** 0.010)  stats(N j ar1p ar2p hansenp, labels("Observations" "No. of instruments" "AR1 (p-value)" "AR2 (p-value)" "Hansen-J (p-value)" "F Statistic"))
                If you are using recent versions of Stata, you can open the results directly from your results window, otherwise, go to the folder where the results were sent or where you saved your data. Take note of the dot(.) between results and rtf (rich text format) in the esttab command. Recall that esttab should be installed from
                Code:
                 ssc install esttab
                Should you not be interested in exporting results at 10 per cent level of significance, adjust the formula by removing it.

                I hope this helps someone in future
                Last edited by Beri Parfait; 08 Dec 2020, 06:25.

                Comment


                • #9
                  Thank you beri for your contribution to my question.

                  Comment

                  Working...
                  X