Announcement

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

  • Xtabond2 for system GMM. Please help me for coding

    Dear all,

    I am working with the xtabond2 command in Stata to solve the endogeneity problem of my estimation. I read the construction of doing xtabond2 from David Roodman. However, I am still confused that my coding is right or wrong. I appreciate receiving your advice :

    Code:
    *************:
    xtabond2 ltotalfertility l.ltotalfertility l(0/2).(pand_res_pt) i.year, ///
    iv(i.year, eq(both)) ///
    iv(l(0/2).(pand_res_pt), eq(both)) ///
    gmm(ltotalfertility, lag(2 .) collapse eq(both))  ///
    h(1) ar(3) two cluster(ifscode)
    here, by choosing
    Code:
    . xtabond2 ltotalfertility l.ltotalfertility l(0/2).(pand_res_pt) i.year, ///
    > iv(i.year, eq(both)) ///
    > iv(l(0/2).(pand_res_pt), eq(both)) ///
    > gmm(ltotalfertility, lag(2 .) collapse eq(both))  ///
    > h(1) ar(3) two cluster(ifscode)
    Favoring speed over space. To switch, type or click on mata: mata set matafavor space, perm.
    1996b.year dropped due to collinearity
    1997.year dropped due to collinearity
    2009.year dropped due to collinearity
    2018.year dropped due to collinearity
    2019.year dropped due to collinearity
    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: ifscode                         Number of obs      =      3622
    Time variable : year                            Number of groups   =       183
    Number of instruments = 44                      Obs per group: min =         1
    Wald chi2(23) =  69569.39                                      avg =     19.79
    Prob > chi2   =     0.000                                      max =        20
                                       (Std. err. adjusted for clustering on ifscode)
    ---------------------------------------------------------------------------------
                    |              Corrected
    ltotalfertility | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
    ----------------+----------------------------------------------------------------
    ltotalfertility |
                L1. |   .8861639   .0218916    40.48   0.000     .8432571    .9290708
                    |
        pand_res_pt |
                --. |  -.0253932   .0059697    -4.25   0.000    -.0370936   -.0136929
                L1. |  -.0309516    .008387    -3.69   0.000    -.0473897   -.0145134
                L2. |  -.0282224   .0065436    -4.31   0.000    -.0410476   -.0153972
                    |
               year |
              1998  |  -.0060163   .0048398    -1.24   0.214    -.0155022    .0034696
              1999  |  -.0054971    .004538    -1.21   0.226    -.0143914    .0033972
              2000  |  -.0053192   .0040945    -1.30   0.194    -.0133442    .0027059
              2001  |  -.0116792    .004663    -2.50   0.012    -.0208184   -.0025399
              2002  |  -.0085614   .0040365    -2.12   0.034    -.0164728     -.00065
              2003  |  -.0082516   .0035831    -2.30   0.021    -.0152744   -.0012288
              2004  |  -.0066783   .0034789    -1.92   0.055    -.0134968    .0001401
              2005  |  -.0094819   .0034326    -2.76   0.006    -.0162097   -.0027541
              2006  |   -.006441   .0031204    -2.06   0.039    -.0125569   -.0003251
              2007  |  -.0062036   .0032063    -1.93   0.053    -.0124879    .0000806
              2008  |   -.006044   .0029945    -2.02   0.044    -.0119131   -.0001749
              2010  |   .0023753   .0019727     1.20   0.229    -.0014911    .0062418
              2011  |  -.0024552   .0013919    -1.76   0.078    -.0051833    .0002729
              2012  |  -.0121593   .0034885    -3.49   0.000    -.0189966    -.005322
              2013  |  -.0177037   .0037538    -4.72   0.000    -.0250609   -.0103465
              2014  |  -.0139368   .0039577    -3.52   0.000    -.0216938   -.0061797
              2015  |  -.0176519   .0041448    -4.26   0.000    -.0257756   -.0095281
              2016  |   -.018251   .0041753    -4.37   0.000    -.0264344   -.0100676
              2017  |  -.0233959   .0044382    -5.27   0.000    -.0320946   -.0146973
                    |
              _cons |   .1172786   .0240108     4.88   0.000     .0702183    .1643389
    ---------------------------------------------------------------------------------
    Instruments for first differences equation
      Standard
        D.(pand_res_pt L.pand_res_pt L2.pand_res_pt)
        D.(1996b.year 1997.year 1998.year 1999.year 2000.year 2001.year 2002.year
        2003.year 2004.year 2005.year 2006.year 2007.year 2008.year 2009.year
        2010.year 2011.year 2012.year 2013.year 2014.year 2015.year 2016.year
        2017.year 2018.year 2019.year)
      GMM-type (missing=0, separate instruments for each period unless collapsed)
        L(2/23).ltotalfertility collapsed
    Instruments for levels equation
      Standard
        pand_res_pt L.pand_res_pt L2.pand_res_pt
        1996b.year 1997.year 1998.year 1999.year 2000.year 2001.year 2002.year
        2003.year 2004.year 2005.year 2006.year 2007.year 2008.year 2009.year
        2010.year 2011.year 2012.year 2013.year 2014.year 2015.year 2016.year
        2017.year 2018.year 2019.year
        _cons
      GMM-type (missing=0, separate instruments for each period unless collapsed)
        DL.ltotalfertility collapsed
    ------------------------------------------------------------------------------
    Arellano-Bond test for AR(1) in first differences: z =  -4.49  Pr > z =  0.000
    Arellano-Bond test for AR(2) in first differences: z =   0.67  Pr > z =  0.501
    Arellano-Bond test for AR(3) in first differences: z =  -1.82  Pr > z =  0.069
    ------------------------------------------------------------------------------
    Sargan test of overid. restrictions: chi2(20)   =  17.39  Prob > chi2 =  0.628
      (Not robust, but not weakened by many instruments.)
    Hansen test of overid. restrictions: chi2(20)   =  96.22  Prob > chi2 =  0.000
      (Robust, but weakened by many instruments.)
    
    Difference-in-Hansen tests of exogeneity of instrument subsets:
      GMM instruments for levels
        Hansen test excluding group:     chi2(19)   =  70.91  Prob > chi2 =  0.000
        Difference (null H = exogenous): chi2(1)    =  25.31  Prob > chi2 =  0.000
      iv(1996b.year 1997.year 1998.year 1999.year 2000.year 2001.year 2002.year 2003.year 2004.year 2005.year 2006.year 2007.year 2008.year 2009
    > .year 2010.year 2011.year 2012.year 2013.year 2014.year 2015.year 2016.year 2017.year 2018.year 2019.year)
        Hansen test excluding group:     chi2(1)    =   0.10  Prob > chi2 =  0.757
        Difference (null H = exogenous): chi2(19)   =  96.12  Prob > chi2 =  0.000
      iv(pand_res_pt L.pand_res_pt L2.pand_res_pt)
        Hansen test excluding group:     chi2(17)   =  90.00  Prob > chi2 =  0.000
        Difference (null H = exogenous): chi2(3)    =   6.21  Prob > chi2 =  0.102
    
    
    .
    end of do-file
    the lag(2 .) , but when I use the collapse the Hansen test is not significant.


    ***also I used the "xtdpdgmm" to get te better results, I did this :
    Code:
    xtdpdgmm L(0/1).ltotalfertility l(0/2).(pand_res_pt) i.year, noserial gmmiv(L.ltotalfertility, collapse model(difference)) iv(l(0/2).(pand_res_pt) i.year, difference model(difference)) twostep vce(robust)
    and the results :
    Code:
    . xtdpdgmm L(0/1).ltotalfertility l(0/2).(pand_res_pt) i.year, noserial gmmiv(L.ltotalfertility, collapse model(difference)) iv(l(0/2).(pand
    > _res_pt) i.year, difference model(difference)) twostep vce(robust)
    note: 1996.year identifies no observations in the sample.
    note: 1997.year identifies no observations in the sample.
    note: 2017.year omitted because of collinearity.
    note: 2018.year identifies no observations in the sample.
    note: 2019.year identifies no observations in the sample.
    
    Generalized method of moments estimation
    
    Fitting full model:
    
    Step 1:
    initial:       f(b) =  19.115759
    alternative:   f(b) =  4.6514905
    rescale:       f(b) =  .08442007
    Iteration 0:   f(b) =  .08442007  
    Iteration 1:   f(b) =  .00083005  
    Iteration 2:   f(b) =  .00082701  
    Iteration 3:   f(b) =  .00082701  
    
    Step 2:
    Iteration 0:   f(b) =  .97149141  
    Iteration 1:   f(b) =  .57064682  
    Iteration 2:   f(b) =  .56335002  
    Iteration 3:   f(b) =   .5633197  
    Iteration 4:   f(b) =  .56331884  
    Iteration 5:   f(b) =  .56331881  
    
    Group variable: ifscode                      Number of obs         =      3622
    Time variable: year                          Number of groups      =       183
    
    Moment conditions:     linear =      43      Obs per group:    min =         1
                        nonlinear =      18                        avg =  19.79235
                            total =      61                        max =        20
    
                                     (Std. err. adjusted for 183 clusters in ifscode)
    ---------------------------------------------------------------------------------
                    |              WC-Robust
    ltotalfertility | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
    ----------------+----------------------------------------------------------------
    ltotalfertility |
                L1. |   1.025479   .0123817    82.82   0.000     1.001211    1.049746
                    |
        pand_res_pt |
                --. |   .0027941   .0027985     1.00   0.318    -.0026909    .0082791
                L1. |   .0014515   .0040002     0.36   0.717    -.0063887    .0092917
                L2. |   .0011745   .0039944     0.29   0.769    -.0066543    .0090033
                    |
               year |
              1996  |          0  (empty)
              1997  |          0  (empty)
              1998  |  -.0134633   .0039956    -3.37   0.001    -.0212946    -.005632
              1999  |  -.0099362   .0039732    -2.50   0.012    -.0177235   -.0021489
              2000  |  -.0072415   .0039882    -1.82   0.069    -.0150582    .0005752
              2001  |  -.0112745   .0031739    -3.55   0.000    -.0174952   -.0050537
              2002  |  -.0051081   .0031922    -1.60   0.110    -.0113647    .0011486
              2003  |  -.0028348   .0032195    -0.88   0.379    -.0091448    .0034752
              2004  |   .0006642   .0032341     0.21   0.837    -.0056745     .007003
              2005  |  -.0004954    .002737    -0.18   0.856    -.0058598    .0048691
              2006  |    .004047   .0031755     1.27   0.202    -.0021767    .0102708
              2007  |   .0055304   .0032534     1.70   0.089    -.0008462    .0119071
              2008  |   .0068074   .0032675     2.08   0.037     .0004032    .0132115
              2009  |   .0009863   .0024508     0.40   0.687    -.0038171    .0057897
              2010  |   .0030281   .0027427     1.10   0.270    -.0023475    .0084037
              2011  |   .0013373   .0022822     0.59   0.558    -.0031357    .0058103
              2012  |   .0048407   .0023568     2.05   0.040     .0002214    .0094599
              2013  |     .00075   .0015893     0.47   0.637    -.0023651     .003865
              2014  |   .0057334   .0019981     2.87   0.004     .0018172    .0096496
              2015  |   .0034253   .0013914     2.46   0.014     .0006982    .0061525
              2016  |    .003241   .0012295     2.64   0.008     .0008312    .0056508
              2017  |          0  (omitted)
              2018  |          0  (empty)
              2019  |          0  (empty)
                    |
              _cons |   -.037772   .0117266    -3.22   0.001    -.0607558   -.0147882
    ---------------------------------------------------------------------------------
    Instruments corresponding to the linear moment conditions:
     1, model(diff):
       L1.L.ltotalfertility L2.L.ltotalfertility L3.L.ltotalfertility
       L4.L.ltotalfertility L5.L.ltotalfertility L6.L.ltotalfertility
       L7.L.ltotalfertility L8.L.ltotalfertility L9.L.ltotalfertility
       L10.L.ltotalfertility L11.L.ltotalfertility L12.L.ltotalfertility
       L13.L.ltotalfertility L14.L.ltotalfertility L15.L.ltotalfertility
       L16.L.ltotalfertility L17.L.ltotalfertility L18.L.ltotalfertility
       L19.L.ltotalfertility L20.L.ltotalfertility
     2, model(diff):
       D.pand_res_pt D.L.pand_res_pt D.L2.pand_res_pt D.1999bn.year D.2000.year
       D.2001.year D.2002.year D.2003.year D.2004.year D.2005.year D.2006.year
       D.2007.year D.2008.year D.2009.year D.2010.year D.2011.year D.2012.year
       D.2013.year D.2014.year D.2015.year D.2016.year D.2017.year
     3, model(level):
       _cons
    
    .
    end of do-file

    the results are not the same, Please guide me if is it the right command.

    Many thanks in advance for your valuable time and advice.

    Regards,
    Last edited by Khati Zolfaghari; 27 Sep 2022, 15:42.

  • #2
    You have specified two very different estimators with the two commands. With xtabond2, you have specified a system GMM estimator. With xtdpdgmm, you have specified a difference GMM estimator with the nonlinear Ahn-Schmidt moment conditions.

    xtdpdgmm cannot replicate xtabond2 if you specify the eq(both) suboption in the iv() option. However, notice that iv(, eq(both)) is not the same as jointly specifying iv(, eq(level)) iv(, eq(diff)). Unless you know what eq(both) is really doing, you probably want to specify the instruments separately for the two equations.

    The following commands should be equivalent:

    Code:
    xtabond2 L(0/1).ltotalfertility l(0/2).(pand_res_pt) i.year, gmmiv(L.ltotalfertility, lag(1 .) collapse eq(diff)) gmmiv(L.ltotalfertility, lag(0 0) collapse eq(level)) iv(L(0/2).(pand_res_pt), eq(difference) mz) iv(L(0/2).(pand_res_pt) i.year, eq(level) mz) twostep robust
    
    xtdpdgmm L(0/1).ltotalfertility l(0/2).(pand_res_pt) i.year, gmmiv(L.ltotalfertility, lag(1 .) collapse model(difference)) gmmiv(L.ltotalfertility, diff lag(0 0) collapse model(level)) iv(L(0/2).(pand_res_pt), diff model(difference)) iv(L(0/2).(pand_res_pt) i.year, model(level)) twostep vce(robust)
    You can then adjust the models as needed from this starting point.

    If the Hansen test rejects this system GMM estimator, you might have to go back to a difference GMM estimator by removing the instruments for the level model (aside from the time dummies).

    More information:
    https://www.kripfganz.de/stata/

    Comment


    • #3
      @Sebastian Kripfganz many thanks for your reply. by using both" I wanted to specify the level and diff for IV(and I did wrong).

      I follow your assistance , but I receive this error.

      Code:
       xtabond2 L(0/1).ltotalfertility l(0/2).(pand_res_pt) i.year, gmmiv(L.ltotalfertility, lag(1 .) collapse eq(diff)) gmmiv(L.ltotalfertility,
      >  lag(0 0) collapse eq(level)) iv(L(0/2).(pand_res_pt), eq(difference) mz) iv(L(0/2).(pand_res_pt) i.year, eq(level) mz) twostep robust
      Favoring speed over space. To switch, type or click on mata: mata set matafavor space, perm.
      equation(difference) invalid.
      r(198);
      Many thanks in advance for your valuable time and advice.

      regards,

      Comment


      • #4
        Sorry, my mistake. Replace eq(difference) in that command line with eq(diff).
        https://www.kripfganz.de/stata/

        Comment


        • #5
          @Sebastian Kripfganz thanks for your reply, but error is still the same.
          Code:
          . xtabond2 L(0/1).ltotalfertility l(0/2).(pand_res_pt) i.year, gmmiv(L.ltotalfertility, lag(1 .) collapse eq(difference)) gmmiv(L.ltotalfert
          > ility, lag(0 0) collapse eq(level)) iv(L(0/2).(pand_res_pt), eq(difference) mz) iv(L(0/2).(pand_res_pt) i.year, eq(level) mz) twostep robu
          > st
          Favoring speed over space. To switch, type or click on mata: mata set matafavor space, perm.
          equation(difference) invalid.
          r(198);

          for the second one :
          Code:
          xtdpdgmm L(0/1).ltotalfertility l(0/2).(pand_res_pt) i.year, gmmiv(L.ltotalfertility, lag(1 .) collapse model(difference)) gmmiv(L.ltotalfertility, diff lag(0 0) collapse model(level)) iv(L(0/2).(pand_res_pt), diff model(difference)) iv(L(0/2).(pand_res_pt) i.year, model(level)) twostep vce(robust)
          Code:
          . xtdpdgmm L(0/1).ltotalfertility l(0/2).(pand_res_pt) i.year, gmmiv(L.ltotalfertility, lag(1 .) collapse model(difference)) gmmiv(L.ltotalf
          > ertility, diff lag(0 0) collapse model(level)) iv(L(0/2).(pand_res_pt), diff model(difference)) iv(L(0/2).(pand_res_pt) i.year, model(leve
          > l)) twostep vce(robust)
          note: 1996.year identifies no observations in the sample.
          note: 1997.year identifies no observations in the sample.
          note: 2017.year omitted because of collinearity.
          note: 2018.year identifies no observations in the sample.
          note: 2019.year identifies no observations in the sample.
          
          Generalized method of moments estimation
          
          Fitting full model:
          Step 1         f(b) =  .00198467
          Step 2         f(b) =  .60731996
          
          Group variable: ifscode                      Number of obs         =      3622
          Time variable: year                          Number of groups      =       183
          
          Moment conditions:     linear =      47      Obs per group:    min =         1
                              nonlinear =       0                        avg =  19.79235
                                  total =      47                        max =        20
          
                                           (Std. err. adjusted for 183 clusters in ifscode)
          ---------------------------------------------------------------------------------
                          |              WC-Robust
          ltotalfertility | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
          ----------------+----------------------------------------------------------------
          ltotalfertility |
                      L1. |   .9620578   .0074356   129.39   0.000     .9474844    .9766313
                          |
              pand_res_pt |
                      --. |  -.0120369   .0036579    -3.29   0.001    -.0192062   -.0048677
                      L1. |  -.0141876   .0053543    -2.65   0.008    -.0246819   -.0036933
                      L2. |  -.0173138   .0050407    -3.43   0.001    -.0271935   -.0074341
                          |
                     year |
                    1996  |          0  (empty)
                    1997  |          0  (empty)
                    1998  |   .0029904   .0027018     1.11   0.268    -.0023051    .0082858
                    1999  |   .0051589   .0025662     2.01   0.044     .0001292    .0101886
                    2000  |     .00722   .0024117     2.99   0.003     .0024932    .0119468
                    2001  |   .0011346    .002387     0.48   0.635    -.0035438     .005813
                    2002  |   .0058193   .0020605     2.82   0.005     .0017807    .0098579
                    2003  |   .0074605   .0020744     3.60   0.000     .0033948    .0115261
                    2004  |    .009511   .0022669     4.20   0.000      .005068     .013954
                    2005  |   .0075377   .0018379     4.10   0.000     .0039355    .0111399
                    2006  |   .0109501   .0023213     4.72   0.000     .0064004    .0154998
                    2007  |    .011599   .0024158     4.80   0.000     .0068641     .016334
                    2008  |   .0122399   .0025378     4.82   0.000      .007266    .0172139
                    2009  |   .0125501   .0025921     4.84   0.000     .0074697    .0176305
                    2010  |   .0132048   .0032966     4.01   0.000     .0067435    .0196661
                    2011  |   .0117341   .0027346     4.29   0.000     .0063744    .0170938
                    2012  |   .0085155   .0021526     3.96   0.000     .0042963    .0127346
                    2013  |   .0028293   .0015655     1.81   0.071    -.0002391    .0058977
                    2014  |   .0078911   .0019816     3.98   0.000     .0040072     .011775
                    2015  |    .004883   .0014904     3.28   0.001     .0019618    .0078042
                    2016  |   .0047944   .0013152     3.65   0.000     .0022166    .0073722
                    2017  |          0  (omitted)
                    2018  |          0  (empty)
                    2019  |          0  (empty)
                          |
                    _cons |   .0229254    .006648     3.45   0.001     .0098955    .0359552
          ---------------------------------------------------------------------------------
          Instruments corresponding to the linear moment conditions:
           1, model(diff):
             L1.L.ltotalfertility L2.L.ltotalfertility L3.L.ltotalfertility
             L4.L.ltotalfertility L5.L.ltotalfertility L6.L.ltotalfertility
             L7.L.ltotalfertility L8.L.ltotalfertility L9.L.ltotalfertility
             L10.L.ltotalfertility L11.L.ltotalfertility L12.L.ltotalfertility
             L13.L.ltotalfertility L14.L.ltotalfertility L15.L.ltotalfertility
             L16.L.ltotalfertility L17.L.ltotalfertility L18.L.ltotalfertility
             L19.L.ltotalfertility L20.L.ltotalfertility
           2, model(level):
             D.L.ltotalfertility
           3, model(diff):
             D.pand_res_pt D.L.pand_res_pt D.L2.pand_res_pt
           4, model(level):
             pand_res_pt L.pand_res_pt L2.pand_res_pt 1998bn.year 1999.year 2000.year
             2001.year 2002.year 2003.year 2004.year 2005.year 2006.year 2007.year
             2008.year 2009.year 2010.year 2012.year 2013.year 2014.year 2015.year
             2016.year 2017.year
           5, model(level):
             _cons
          
          .
          end of do-file
          but the "Hansen test" and "serial correlation":
          Code:
          . estat serial
          
          Arellano-Bond test for autocorrelation of the first-differenced residuals
          H0: no autocorrelation of order 1      z =   -4.6661   Prob > |z|  =    0.0000
          H0: no autocorrelation of order 2      z =    0.7144   Prob > |z|  =    0.4750
          
          .
          Code:
          .  estat overid
          
          Sargan-Hansen test of the overidentifying restrictions
          H0: overidentifying restrictions are valid
          
          2-step moment functions, 2-step weighting matrix       chi2(23)    =  111.1396
                                                                 Prob > chi2 =    0.0000
          
          2-step moment functions, 3-step weighting matrix       chi2(23)    =  147.1723
                                                                 Prob > chi2 =    0.0000
          also in terms of the number of observation in this model I have doubt.

          Many thanks in advance for your valuable time and advice.

          regards,
          Last edited by Khati Zolfaghari; 28 Sep 2022, 04:17.

          Comment


          • #6
            Originally posted by Khati Zolfaghari View Post
            @Sebastian Kripfganz thanks for your reply, but error is still the same.
            Code:
            . xtabond2 L(0/1).ltotalfertility l(0/2).(pand_res_pt) i.year, gmmiv(L.ltotalfertility, lag(1 .) collapse eq(difference)) gmmiv(L.ltotalfert
            > ility, lag(0 0) collapse eq(level)) iv(L(0/2).(pand_res_pt), eq(difference) mz) iv(L(0/2).(pand_res_pt) i.year, eq(level) mz) twostep robu
            > st
            Favoring speed over space. To switch, type or click on mata: mata set matafavor space, perm.
            equation(difference) invalid.
            r(198);
            You have not replaced eq(difference) by eq(diff).

            The serial correlation test is fine, but the Hansen test rejects your model. A likely explanation could be that your level instruments are invalid. You should try a difference GMM estimator first.
            https://www.kripfganz.de/stata/

            Comment


            • #7
              @Sebastian Kripfganz thanks for your reply. I am trying several specifications and following your advice. also, I tried to do a model in terms of the difference-GMM.
              • I tried even replacing the eq(difference) by eq(diff) and vs,
              Code:
              mata: mata set matafavor speed, perm
              . xtabond2 L(0/1).ltotalfertility l(0/2).(pand_res_pt) i.year, gmmiv(L.ltotalfertility, lag(1 .) collapse eq(diff)) gmmiv(L.ltotalfertility,
              >  lag(0 0) collapse eq(level)) iv(L(0/2).(pand_res_pt), eq(diff) mz) iv(L(0/2).(pand_res_pt) i.year, eq(level) mz) twostep robust
              Favoring speed over space. To switch, type or click on mata: mata set matafavor space, perm.
              gmmiv(L.ltotalfertility, lag(1 .) collapse eq(diff)) gmmiv(L.ltotalfertility, lag(0 0) collapse eq(level)) invalid.r(198);
              • for the diff-GMM , I estimate:
              Code:
              xi: xtabond2 ltotalfertility l.ltotalfertility l(0/2).(pand_res_pt) i.year, ///
              
              iv(i.year, eq(diff)) ///
              iv(l(0/2).(pand_res_pt), eq(diff)) ///
              gmm(ltotalfertility, lag(2 2) eq(diff)) ///
              h(1) nolev ar(3) cluster(ifscode)
              Code:
              . xi: xtabond2 ltotalfertility l.ltotalfertility l(0/2).(pand_res_pt) i.year, ///
              > iv(i.year, eq(diff)) ///
              > iv(l(0/2).(pand_res_pt), eq(diff)) ///
              > gmm(ltotalfertility, lag(2 2) eq(diff)) ///
              > h(1) nolev ar(3) cluster(ifscode)
              i.year            _Iyear_1996-2019    (naturally coded; _Iyear_1996 omitted)
              Favoring speed over space. To switch, type or click on mata: mata set matafavor space, perm.
              _Iyear_1997 dropped due to collinearity
              _Iyear_1999 dropped due to collinearity
              _Iyear_2018 dropped due to collinearity
              _Iyear_2019 dropped due to collinearity
              Warning: Two-step estimated covariance matrix of moments is singular.
                Using a generalized inverse to calculate robust weighting matrix for Hansen test.
                Difference-in-Sargan/Hansen statistics may be negative.
              
              Dynamic panel-data estimation, one-step difference GMM
              ------------------------------------------------------------------------------
              Group variable: ifscode                         Number of obs      =      3439
              Time variable : year                            Number of groups   =       182
              Number of instruments = 41                      Obs per group: min =         0
              Wald chi2(0)  =         .                                      avg =     18.90
              Prob > chi2   =         .                                      max =        19
                                                 (Std. err. adjusted for clustering on ifscode)
              ---------------------------------------------------------------------------------
                              |               Robust
              ltotalfertility | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
              ----------------+----------------------------------------------------------------
              ltotalfertility |
                          L1. |   .6417241   .0590909    10.86   0.000     .5259081      .75754
                              |
                  pand_res_pt |
                          --. |   -.002099   .0022695    -0.92   0.355    -.0065472    .0023492
                          L1. |  -.0052392   .0034211    -1.53   0.126    -.0119444    .0014659
                          L2. |  -.0062662   .0030356    -2.06   0.039    -.0122158   -.0003166
                              |
                  _Iyear_1998 |   .0028761   .0015311     1.88   0.060    -.0001248    .0058769
                  _Iyear_2000 |  -.0015303   .0015071    -1.02   0.310    -.0044842    .0014236
                  _Iyear_2001 |  -.0162301   .0031707    -5.12   0.000    -.0224447   -.0100156
                  _Iyear_2002 |  -.0156015   .0039573    -3.94   0.000    -.0233576   -.0078454
                  _Iyear_2003 |  -.0171492   .0048845    -3.51   0.000    -.0267227   -.0075758
                  _Iyear_2004 |  -.0170734    .005531    -3.09   0.002    -.0279139   -.0062328
                  _Iyear_2005 |  -.0219861    .006054    -3.63   0.000    -.0338517   -.0101204
                  _Iyear_2006 |  -.0194425   .0068225    -2.85   0.004    -.0328143   -.0060707
                  _Iyear_2007 |  -.0191756   .0072006    -2.66   0.008    -.0332885   -.0050628
                  _Iyear_2008 |  -.0178043   .0079219    -2.25   0.025    -.0333309   -.0022777
                  _Iyear_2009 |  -.0251675   .0083649    -3.01   0.003    -.0415623   -.0087726
                  _Iyear_2010 |  -.0270057   .0085315    -3.17   0.002    -.0437272   -.0102842
                  _Iyear_2011 |  -.0330654   .0086077    -3.84   0.000    -.0499362   -.0161946
                  _Iyear_2012 |  -.0328824   .0092524    -3.55   0.000    -.0510168   -.0147481
                  _Iyear_2013 |  -.0438404   .0101814    -4.31   0.000    -.0637955   -.0238853
                  _Iyear_2014 |  -.0393237   .0105193    -3.74   0.000    -.0599412   -.0187063
                  _Iyear_2015 |  -.0451708   .0110972    -4.07   0.000     -.066921   -.0234206
                  _Iyear_2016 |  -.0479582    .011823    -4.06   0.000     -.071131   -.0247855
                  _Iyear_2017 |  -.0582286   .0125072    -4.66   0.000    -.0827423   -.0337149
              ---------------------------------------------------------------------------------
              Instruments for first differences equation
                Standard
                  D.(pand_res_pt L.pand_res_pt L2.pand_res_pt)
                  D.(_Iyear_1997 _Iyear_1998 _Iyear_1999 _Iyear_2000 _Iyear_2001 _Iyear_2002
                  _Iyear_2003 _Iyear_2004 _Iyear_2005 _Iyear_2006 _Iyear_2007 _Iyear_2008
                  _Iyear_2009 _Iyear_2010 _Iyear_2011 _Iyear_2012 _Iyear_2013 _Iyear_2014
                  _Iyear_2015 _Iyear_2016 _Iyear_2017 _Iyear_2018 _Iyear_2019)
                GMM-type (missing=0, separate instruments for each period unless collapsed)
                  L2.ltotalfertility
              ------------------------------------------------------------------------------
              Arellano-Bond test for AR(1) in first differences: z =  -4.84  Pr > z =  0.000
              Arellano-Bond test for AR(2) in first differences: z =   1.68  Pr > z =  0.092
              Arellano-Bond test for AR(3) in first differences: z =  -0.37  Pr > z =  0.712
              ------------------------------------------------------------------------------
              Sargan test of overid. restrictions: chi2(18)   = 292.67  Prob > chi2 =  0.000
                (Not robust, but not weakened by many instruments.)
              Hansen test of overid. restrictions: chi2(18)   =  56.32  Prob > chi2 =  0.000
                (Robust, but weakened by many instruments.)
              
              Difference-in-Hansen tests of exogeneity of instrument subsets:
                iv(pand_res_pt L.pand_res_pt L2.pand_res_pt, eq(diff))
                  Hansen test excluding group:     chi2(15)   =  51.89  Prob > chi2 =  0.000
                  Difference (null H = exogenous): chi2(3)    =   4.42  Prob > chi2 =  0.219
              
              
              .
              end of do-file
              • also , for xtabond2 and diff-GMM , I estimate based on this.
              Code:
               xtabond2 L(0/1).ltotalfertility l(0/2).(pand_res_pt) i.year, gmm(L.ltotalfertility l(0/2).pand_res_pt , lag(1 3) e(d)) nol r
              Code:
              Favoring speed over space. To switch, type or click on mata: mata set matafavor space, perm.
              1996b.year dropped due to collinearity
              1997.year dropped due to collinearity
              1999.year dropped due to collinearity
              2018.year dropped due to collinearity
              2019.year dropped due to collinearity
              Warning: Two-step estimated covariance matrix of moments is singular.
                Using a generalized inverse to calculate robust weighting matrix for Hansen test.
                Difference-in-Sargan/Hansen statistics may be negative.
              
              Dynamic panel-data estimation, one-step difference GMM
              ------------------------------------------------------------------------------
              Group variable: ifscode                         Number of obs      =      3439
              Time variable : year                            Number of groups   =       182
              Number of instruments = 75                      Obs per group: min =         0
              Wald chi2(0)  =         .                                      avg =     18.90
              Prob > chi2   =         .                                      max =        19
              ---------------------------------------------------------------------------------
                              |               Robust
              ltotalfertility | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
              ----------------+----------------------------------------------------------------
              ltotalfertility |
                          L1. |   .7995318   .0285769    27.98   0.000     .7435221    .8555414
                              |
                  pand_res_pt |
                          --. |  -.0051798   .0036244    -1.43   0.153    -.0122835     .001924
                          L1. |  -.0078922   .0038674    -2.04   0.041    -.0154722   -.0003122
                          L2. |  -.0098069   .0034846    -2.81   0.005    -.0166366   -.0029773
                              |
                         year |
                        1998  |    .002119   .0010274     2.06   0.039     .0001054    .0041327
                        2000  |  -.0010319   .0011563    -0.89   0.372    -.0032981    .0012343
                        2001  |  -.0099869   .0022407    -4.46   0.000    -.0143786   -.0055952
                        2002  |  -.0088589   .0022561    -3.93   0.000    -.0132807   -.0044372
                        2003  |  -.0097598   .0026306    -3.71   0.000    -.0149156   -.0046039
                        2004  |  -.0094847   .0028779    -3.30   0.001    -.0151253    -.003844
                        2005  |  -.0154503   .0032033    -4.82   0.000    -.0217286   -.0091719
                        2006  |  -.0139113   .0036764    -3.78   0.000    -.0211169   -.0067056
                        2007  |  -.0146629   .0039578    -3.70   0.000      -.02242   -.0069059
                        2008  |  -.0145618   .0044231    -3.29   0.001    -.0232309   -.0058926
                        2009  |  -.0190504    .004204    -4.53   0.000    -.0272901   -.0108107
                        2010  |  -.0214091   .0047103    -4.55   0.000    -.0306412    -.012177
                        2011  |  -.0255258   .0048231    -5.29   0.000    -.0349788   -.0160727
                        2012  |  -.0271835    .005434    -5.00   0.000     -.037834    -.016533
                        2013  |  -.0350847   .0055091    -6.37   0.000    -.0458824    -.024287
                        2014  |  -.0302499   .0058633    -5.16   0.000    -.0417418    -.018758
                        2015  |    -.03638   .0062337    -5.84   0.000    -.0485978   -.0241621
                        2016  |  -.0377174   .0064983    -5.80   0.000    -.0504539   -.0249809
                        2017  |   -.045109   .0070333    -6.41   0.000    -.0588939    -.031324
              ---------------------------------------------------------------------------------
              Instruments for first differences equation
                GMM-type (missing=0, separate instruments for each period unless collapsed)
                  L(1/3).(L.ltotalfertility pand_res_pt L.pand_res_pt L2.pand_res_pt)
              ------------------------------------------------------------------------------
              Arellano-Bond test for AR(1) in first differences: z =  -4.40  Pr > z =  0.000
              Arellano-Bond test for AR(2) in first differences: z =   0.97  Pr > z =  0.332
              ------------------------------------------------------------------------------
              Sargan test of overid. restrictions: chi2(52)   = 286.87  Prob > chi2 =  0.000
                (Not robust, but not weakened by many instruments.)
              Hansen test of overid. restrictions: chi2(52)   =  75.58  Prob > chi2 =  0.018
                (Robust, but weakened by many instruments.)

              I do not know if my code is correct. because Hansen test in one is not good and for the second is good but the "Wald chi2(0) = " is not computed.


              Many thanks in advance for your valuable time and advice.



              regards,

              Comment

              Working...
              X