Announcement

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

  • xtabond vs. xtabond2: How to get the same results?

    Hello,

    I am currently working with the Arellano Bond difference estimator and I'm not able to generate the same results for the commands xtabond and xtabond2.

    I tried to replicate the results from the following xtabond command with the xtabond2 command (x1 and x2 are exogenous):

    xtabond y x1 x2 i.year, twostep vce(robust)

    xtabond2 y l.y x1 x2 i.year, gmm(l.y) iv(x1 x2 i.year) noleveleq twostep robust small

    Why do the two options not generate the same results?



    Also, I am wondering how variables are treated if they are listed before the comma, but not after the comma. For example, how is x2 being estimated in the following case?

    xtabond2 y l.y x1 x2, gmm(l.y) iv(x1) noleveleq twostep robust


    I also asked another question yesterday about the interaction of an endogenous and exogenous variable. Any responses would be really appreciated!

    Thank you so much in advance.
    Sofie

  • #2
    Have you looked at the documentation for xtabond2 (from SSC) for equivalent syntax?

    Code:
    help xtabond2
    Also, xtabond does not support factor variables, so you probably want

    Code:
    xi: xtabond y x1 x2 i.year, twostep vce(robust)

    Comment


    • #3
      The Stata Journal article by David Roodman gives a detailed description of xtabond2. Also on page 42 there is an example with xtabond and xtabond2

      Comment


      • #4
        Thank you for your help.

        I actually did type xi before the commands. Sorry that I forgot to mention it.

        I read the paper and the syntax in Stata, but apparently I do not understand it. Does anyone see my mistake in that particular case?
        Last edited by Sofie Laub; 24 Apr 2020, 06:16.

        Comment


        • #5
          You will a brief introduction to xtabond2 posted by me here:
          https://www.statalist.org/forums/for...-me-for-coding
          Note that your xtabond command does not contain a lagged y as dependent variable, but your xtabond2 does

          Comment


          • #6
            Thank you Eric. I did not list l.y in the xtabond command, because this command automatically includes the lagged dependent variable in the estimation. This is because the command tells Stata that I have a dynamic panel data model.

            Comment


            • #7
              I read the paper and the syntax in Stata, but apparently I do not understand it. Does anyone see my mistake in that particular case?
              In addition to the fact that you need to explicitly specify the lagged dependent variable in xtabond2, you need to look at the instrument set for the level and differenced equations when translating the syntax. So here is your xtabond command:

              xtabond y x1 x2 i.year, twostep vce(robust)
              We can make a reproducible example using Stata's abdata dataset and see the results

              Code:
              webuse abdata, clear
              xi: xtabond wage emp cap i.year, twostep vce(robust)
              Res.:

              Code:
              . xi: xtabond wage emp cap i.year, twostep vce(robust)
              i.year            _Iyear_1976-1984    (naturally coded; _Iyear_1976 omitted)
              note: _Iyear_1984 dropped because of collinearity
              
              Arellano-Bond dynamic panel-data estimation     Number of obs     =        751
              Group variable: id                              Number of groups  =        140
              Time variable: year
                                                              Obs per group:
                                                                            min =          5
                                                                            avg =   5.364286
                                                                            max =          7
              
              Number of instruments =     38                  Wald chi2(10)     =     189.18
                                                              Prob > chi2       =     0.0000
              Two-step results
                                                   (Std. Err. adjusted for clustering on id)
              ------------------------------------------------------------------------------
                           |              WC-Robust
                      wage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
                      wage |
                       L1. |     .22362   .7350978     0.30   0.761    -1.217145    1.664385
                           |
                       emp |  -.0652363   .0399532    -1.63   0.103    -.1435432    .0130707
                       cap |    .174836    .062315     2.81   0.005     .0527008    .2969711
               _Iyear_1977 |  -2.580239   .5124058    -5.04   0.000    -3.584536   -1.575942
               _Iyear_1978 |  -2.369046    1.49994    -1.58   0.114    -5.308874    .5707818
               _Iyear_1979 |  -2.086565   1.735373    -1.20   0.229    -5.487834    1.314704
               _Iyear_1980 |   -2.07073   1.629248    -1.27   0.204    -5.263998    1.122538
               _Iyear_1981 |  -1.396799   1.890739    -0.74   0.460     -5.10258    2.308981
               _Iyear_1982 |  -.4331267   1.487038    -0.29   0.771    -3.347668    2.481414
               _Iyear_1983 |   .0409424   .3901312     0.10   0.916    -.7237007    .8055855
                     _cons |   19.89907    19.4321     1.02   0.306    -18.18714    57.98528
              ------------------------------------------------------------------------------
              Instruments for differenced equation
                      GMM-type: L(2/.).wage
                      Standard: D.emp D.cap D._Iyear_1977 D._Iyear_1978 D._Iyear_1979
                                D._Iyear_1980 D._Iyear_1981 D._Iyear_1982 D._Iyear_1983
                                D._Iyear_1984
              Instruments for level equation
                      Standard: _cons
              GMM type instruments for the differenced equation are the lags of the dependent variable (starting from the second). Standard instruments are the differenced independent variables. No instruments for the level equation. So let's explicitly include the lagged dependent variable and these instruments and see how we fair.

              Code:
               xtabond2 wage L.wage emp cap i.year, gmm(L.wage, eq(d)) iv(emp cap i.year, eq(d)) robust twostep
              Res.:

              Code:
              . xtabond2 wage L.wage emp cap i.year, gmm(L.wage, eq(d)) iv(emp cap i.year, eq(d)) robust twostep
              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      =       891
              Time variable : year                            Number of groups   =       140
              Number of instruments = 38                      Obs per group: min =         6
              Wald chi2(12) =    202.48                                      avg =      6.36
              Prob > chi2   =     0.000                                      max =         8
              ------------------------------------------------------------------------------
                           |              Corrected
                      wage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
                      wage |
                       L1. |     .22362   .1058023     2.11   0.035     .0162514    .4309887
                           |
                       emp |  -.0652363   .0331144    -1.97   0.049    -.1301393   -.0003332
                       cap |    .174836   .0401353     4.36   0.000     .0961722    .2534997
                           |
                      year |
                     1976  |          0  (empty)
                     1977  |  -2.580239   .4375939    -5.90   0.000    -3.437907   -1.722571
                     1978  |  -2.369046   .5340449    -4.44   0.000    -3.415755   -1.322338
                     1979  |  -2.086565   .5805174    -3.59   0.000    -3.224358   -.9487722
                     1980  |   -2.07073   .5552539    -3.73   0.000    -3.159008   -.9824523
                     1981  |  -1.396799    .602433    -2.32   0.020    -2.577546   -.2160524
                     1982  |  -.4331267   .4871627    -0.89   0.374    -1.387948    .5216946
                     1983  |   .0409424   .3763874     0.11   0.913    -.6967635    .7786482
                     1984  |          0  (omitted)
                           |
                     _cons |   19.89907   2.964961     6.71   0.000     14.08785    25.71028
              ------------------------------------------------------------------------------
              Instruments for first differences equation
                Standard
                  D.(emp cap 1976b.year 1977.year 1978.year 1979.year 1980.year 1981.year
                  1982.year 1983.year 1984.year)
                GMM-type (missing=0, separate instruments for each period unless collapsed)
                  L(1/8).L.wage
              Instruments for levels equation
                Standard
                  _cons
              ------------------------------------------------------------------------------
              Arellano-Bond test for AR(1) in first differences: z =  -2.87  Pr > z =  0.004
              Arellano-Bond test for AR(2) in first differences: z =  -0.43  Pr > z =  0.668
              ------------------------------------------------------------------------------
              Sargan test of overid. restrictions: chi2(25)   =  80.43  Prob > chi2 =  0.000
                (Not robust, but not weakened by many instruments.)
              Hansen test of overid. restrictions: chi2(25)   =  53.74  Prob > chi2 =  0.001
                (Robust, but weakened by many instruments.)
              
              Difference-in-Hansen tests of exogeneity of instrument subsets:
                iv(emp cap 1976b.year 1977.year 1978.year 1979.year 1980.year 1981.year 1982.year 1983.year 1984.year, eq(diff))
                  Hansen test excluding group:     chi2(16)   =  25.60  Prob > chi2 =  0.060
                  Difference (null H = exogenous): chi2(9)    =  28.14  Prob > chi2 =  0.001
              So, we got it right!

              Comment


              • #8
                Thank you so much Andew!

                So I shall use "eq(d)" instead of "noleveleq".

                This solves my problem.

                Comment


                • #9
                  As an aside, there are several problems with xtabond2. For example, in your case with omitted time dummy coefficients, the degrees of freedoms for the Sargan/Hansen test are computed incorrectly, and therefore also the respective p-values. For more information about this and other issues and the xtdpdgmm command as a potential alternative, see my presentation at last year's London Stata Conference:
                  https://www.kripfganz.de/stata/

                  Comment


                  • #10
                    Originally posted by Andrew Musau View Post

                    In addition to the fact that you need to explicitly specify the lagged dependent variable in xtabond2, you need to look at the instrument set for the level and differenced equations when translating the syntax. So here is your xtabond command:



                    We can make a reproducible example using Stata's abdata dataset and see the results

                    Code:
                    webuse abdata, clear
                    xi: xtabond wage emp cap i.year, twostep vce(robust)
                    Res.:

                    Code:
                    . xi: xtabond wage emp cap i.year, twostep vce(robust)
                    i.year _Iyear_1976-1984 (naturally coded; _Iyear_1976 omitted)
                    note: _Iyear_1984 dropped because of collinearity
                    
                    Arellano-Bond dynamic panel-data estimation Number of obs = 751
                    Group variable: id Number of groups = 140
                    Time variable: year
                    Obs per group:
                    min = 5
                    avg = 5.364286
                    max = 7
                    
                    Number of instruments = 38 Wald chi2(10) = 189.18
                    Prob > chi2 = 0.0000
                    Two-step results
                    (Std. Err. adjusted for clustering on id)
                    ------------------------------------------------------------------------------
                    | WC-Robust
                    wage | Coef. Std. Err. z P>|z| [95% Conf. Interval]
                    -------------+----------------------------------------------------------------
                    wage |
                    L1. | .22362 .7350978 0.30 0.761 -1.217145 1.664385
                    |
                    emp | -.0652363 .0399532 -1.63 0.103 -.1435432 .0130707
                    cap | .174836 .062315 2.81 0.005 .0527008 .2969711
                    _Iyear_1977 | -2.580239 .5124058 -5.04 0.000 -3.584536 -1.575942
                    _Iyear_1978 | -2.369046 1.49994 -1.58 0.114 -5.308874 .5707818
                    _Iyear_1979 | -2.086565 1.735373 -1.20 0.229 -5.487834 1.314704
                    _Iyear_1980 | -2.07073 1.629248 -1.27 0.204 -5.263998 1.122538
                    _Iyear_1981 | -1.396799 1.890739 -0.74 0.460 -5.10258 2.308981
                    _Iyear_1982 | -.4331267 1.487038 -0.29 0.771 -3.347668 2.481414
                    _Iyear_1983 | .0409424 .3901312 0.10 0.916 -.7237007 .8055855
                    _cons | 19.89907 19.4321 1.02 0.306 -18.18714 57.98528
                    ------------------------------------------------------------------------------
                    Instruments for differenced equation
                     GMM-type: L(2/.).wage
                    Standard: D.emp D.cap D._Iyear_1977 D._Iyear_1978 D._Iyear_1979
                    D._Iyear_1980 D._Iyear_1981 D._Iyear_1982 D._Iyear_1983
                    D._Iyear_1984
                    Instruments for level equation
                     Standard: _cons
                    GMM type instruments for the differenced equation are the lags of the dependent variable (starting from the second). Standard instruments are the differenced independent variables. No instruments for the level equation. So let's explicitly include the lagged dependent variable and these instruments and see how we fair.

                    Code:
                    xtabond2 wage L.wage emp cap i.year, gmm(L.wage, eq(d)) iv(emp cap i.year, eq(d)) robust twostep
                    Res.:

                    Code:
                    . xtabond2 wage L.wage emp cap i.year, gmm(L.wage, eq(d)) iv(emp cap i.year, eq(d)) robust twostep
                    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 = 891
                    Time variable : year Number of groups = 140
                    Number of instruments = 38 Obs per group: min = 6
                    Wald chi2(12) = 202.48 avg = 6.36
                    Prob > chi2 = 0.000 max = 8
                    ------------------------------------------------------------------------------
                    | Corrected
                    wage | Coef. Std. Err. z P>|z| [95% Conf. Interval]
                    -------------+----------------------------------------------------------------
                    wage |
                    L1. | .22362 .1058023 2.11 0.035 .0162514 .4309887
                    |
                    emp | -.0652363 .0331144 -1.97 0.049 -.1301393 -.0003332
                    cap | .174836 .0401353 4.36 0.000 .0961722 .2534997
                    |
                    year |
                    1976 | 0 (empty)
                    1977 | -2.580239 .4375939 -5.90 0.000 -3.437907 -1.722571
                    1978 | -2.369046 .5340449 -4.44 0.000 -3.415755 -1.322338
                    1979 | -2.086565 .5805174 -3.59 0.000 -3.224358 -.9487722
                    1980 | -2.07073 .5552539 -3.73 0.000 -3.159008 -.9824523
                    1981 | -1.396799 .602433 -2.32 0.020 -2.577546 -.2160524
                    1982 | -.4331267 .4871627 -0.89 0.374 -1.387948 .5216946
                    1983 | .0409424 .3763874 0.11 0.913 -.6967635 .7786482
                    1984 | 0 (omitted)
                    |
                    _cons | 19.89907 2.964961 6.71 0.000 14.08785 25.71028
                    ------------------------------------------------------------------------------
                    Instruments for first differences equation
                    Standard
                    D.(emp cap 1976b.year 1977.year 1978.year 1979.year 1980.year 1981.year
                    1982.year 1983.year 1984.year)
                    GMM-type (missing=0, separate instruments for each period unless collapsed)
                    L(1/8).L.wage
                    Instruments for levels equation
                    Standard
                    _cons
                    ------------------------------------------------------------------------------
                    Arellano-Bond test for AR(1) in first differences: z = -2.87 Pr > z = 0.004
                    Arellano-Bond test for AR(2) in first differences: z = -0.43 Pr > z = 0.668
                    ------------------------------------------------------------------------------
                    Sargan test of overid. restrictions: chi2(25) = 80.43 Prob > chi2 = 0.000
                    (Not robust, but not weakened by many instruments.)
                    Hansen test of overid. restrictions: chi2(25) = 53.74 Prob > chi2 = 0.001
                    (Robust, but weakened by many instruments.)
                    
                    Difference-in-Hansen tests of exogeneity of instrument subsets:
                    iv(emp cap 1976b.year 1977.year 1978.year 1979.year 1980.year 1981.year 1982.year 1983.year 1984.year, eq(diff))
                    Hansen test excluding group: chi2(16) = 25.60 Prob > chi2 = 0.060
                    Difference (null H = exogenous): chi2(9) = 28.14 Prob > chi2 = 0.001
                    So, we got it right!
                    Hi, I wanted to thank you for this, because it was the clearest explanation I have seen on Statalist for how to use xtabond to help you set up xtabond2. Your analysis with the colors really made everything click!

                    (next, I have to figure out how to translate xtabond2 syntax to xtdpdgmm)

                    Comment

                    Working...
                    X