Hello all
I m trying to run a difference gmm model with both these commands but I have different results in terms of instrument counts.
I want to run a model like

pc_npl=l.pc_npl+l.gdp+avg_roa;
where pc_npl and avg_roa are considered as endogenous and l.gdp as strictly exogenous.

The first (silly) question concern with how to instrument l.pc_npl in the gmm option: as gmm( l.pc_npl) or gmm( pc_npl) ??

Secondly, I consider gdp as exogenous.
Reading the slide of Kripfganz I have read that an exogenous variable is also called with gmm specifying the correct lag to consider it as exogenous.
In xtabond2, I specifify it with with the iv() option, where I cannot specifiy the lag limit.

As far as I understand, in the first two comamnd I am instrumenting the exogenous l.gdp with its own values (lag (0)) and up to two lags, while with xtabond the variable is instrumented only by itself and not with deeper lags, am I correct?

However, here are some of the results of the very basic model.


Code:
xtdpdgmm L(0/1).pc_npl l.gdp avg_roa, model(diff) gmm(l.pc_npl, lag( 2 4)) ///
 gmm(avg_roa, lag(2 4)) gmm(l.gdp, lag (0 2)) nocons  vce(r)
estat ser, ar(1/3)
estat overid

Generalized method of moments estimation

Fitting full model:
Step 1         f(b) =  19.958954

Group variable: bank_id                      Number of obs         =      1362
Time variable: year                          Number of groups      =       125

Moment conditions:     linear =      90      Obs per group:    min =         5
                    nonlinear =       0                        avg =    10.896
                        total =      90                        max =        12

                              (Std. Err. adjusted for 125 clusters in bank_id)
------------------------------------------------------------------------------
             |               Robust
      pc_npl |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      pc_npl |
         L1. |   .8485664    .031261    27.14   0.000     .7872958    .9098369
             |
         gdp |
         L1. |  -.1846946   .0442948    -4.17   0.000    -.2715108   -.0978784
             |
     avg_roa |  -1.427724   .2082991    -6.85   0.000    -1.835983   -1.019465
------------------------------------------------------------------------------
Instruments corresponding to the linear moment conditions:
 1, model(diff):
   2009:L2.L.pc_npl 2010:L2.L.pc_npl 2011:L2.L.pc_npl 2012:L2.L.pc_npl
   2013:L2.L.pc_npl 2014:L2.L.pc_npl 2015:L2.L.pc_npl 2016:L2.L.pc_npl
   2017:L2.L.pc_npl 2018:L2.L.pc_npl 2010:L3.L.pc_npl 2011:L3.L.pc_npl
   2012:L3.L.pc_npl 2013:L3.L.pc_npl 2014:L3.L.pc_npl 2015:L3.L.pc_npl
   2016:L3.L.pc_npl 2017:L3.L.pc_npl 2018:L3.L.pc_npl 2011:L4.L.pc_npl
   2012:L4.L.pc_npl 2013:L4.L.pc_npl 2014:L4.L.pc_npl 2015:L4.L.pc_npl
   2016:L4.L.pc_npl 2017:L4.L.pc_npl 2018:L4.L.pc_npl
 2, model(diff):
   2008:L2.avg_roa 2009:L2.avg_roa 2010:L2.avg_roa 2011:L2.avg_roa
   2012:L2.avg_roa 2013:L2.avg_roa 2014:L2.avg_roa 2015:L2.avg_roa
   2016:L2.avg_roa 2017:L2.avg_roa 2018:L2.avg_roa 2009:L3.avg_roa
   2010:L3.avg_roa 2011:L3.avg_roa 2012:L3.avg_roa 2013:L3.avg_roa
   2014:L3.avg_roa 2015:L3.avg_roa 2016:L3.avg_roa 2017:L3.avg_roa
   2018:L3.avg_roa 2010:L4.avg_roa 2011:L4.avg_roa 2012:L4.avg_roa
   2013:L4.avg_roa 2014:L4.avg_roa 2015:L4.avg_roa 2016:L4.avg_roa
   2017:L4.avg_roa 2018:L4.avg_roa
 3, model(diff):
   2008:L.gdp 2009:L.gdp 2010:L.gdp 2011:L.gdp 2012:L.gdp 2013:L.gdp
   2014:L.gdp 2015:L.gdp 2016:L.gdp 2017:L.gdp 2018:L.gdp 2008:L1.L.gdp
   2009:L1.L.gdp 2010:L1.L.gdp 2011:L1.L.gdp 2012:L1.L.gdp 2013:L1.L.gdp
   2014:L1.L.gdp 2015:L1.L.gdp 2016:L1.L.gdp 2017:L1.L.gdp 2018:L1.L.gdp
   2009:L2.L.gdp 2010:L2.L.gdp 2011:L2.L.gdp 2012:L2.L.gdp 2013:L2.L.gdp
   2014:L2.L.gdp 2015:L2.L.gdp 2016:L2.L.gdp 2017:L2.L.gdp 2018:L2.L.gdp
   2019:L2.L.gdp

. estat ser, ar(1/3)

Arellano-Bond test for autocorrelation of the first-differenced residuals
H0: no autocorrelation of order 1:     z =   -3.5568   Prob > |z|  =    0.0004
H0: no autocorrelation of order 2:     z =   -0.8404   Prob > |z|  =    0.4007
H0: no autocorrelation of order 3:     z =    1.0810   Prob > |z|  =    0.2797

. estat overid

Sargan-Hansen test of the overidentifying restrictions
H0: overidentifying restrictions are valid

1-step moment functions, 1-step weighting matrix       chi2(87)    =  356.0197
note: *                                                Prob > chi2 =    0.0000

1-step moment functions, 2-step weighting matrix       chi2(87)    =  109.0580
note: *                                                Prob > chi2 =    0.0550

* asymptotically invalid if the one-step weighting matrix is not optimal




xtdpdgmm L(0/1).pc_npl l.gdp avg_roa, model(diff) gmm(pc_npl, lag( 2 4)) ///
 gmm(avg_roa, lag(2 4)) gmm(l.gdp, lag (0 2)) nocons  vce(r)
estat ser, ar(1/3)
estat overid

Generalized method of moments estimation

Fitting full model:
Step 1         f(b) =  25.160125

Group variable: bank_id                      Number of obs         =      1362
Time variable: year                          Number of groups      =       125

Moment conditions:     linear =      93      Obs per group:    min =         5
                    nonlinear =       0                        avg =    10.896
                        total =      93                        max =        12

                              (Std. Err. adjusted for 125 clusters in bank_id)
------------------------------------------------------------------------------
             |               Robust
      pc_npl |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      pc_npl |
         L1. |   .8158465   .0369234    22.10   0.000     .7434779    .8882151
             |
         gdp |
         L1. |  -.1962848   .0417855    -4.70   0.000    -.2781829   -.1143867
             |
     avg_roa |  -1.279425   .2019118    -6.34   0.000    -1.675165   -.8836851
------------------------------------------------------------------------------
Instruments corresponding to the linear moment conditions:
 1, model(diff):
   2008:L2.pc_npl 2009:L2.pc_npl 2010:L2.pc_npl 2011:L2.pc_npl 2012:L2.pc_npl
   2013:L2.pc_npl 2014:L2.pc_npl 2015:L2.pc_npl 2016:L2.pc_npl 2017:L2.pc_npl
   2018:L2.pc_npl 2009:L3.pc_npl 2010:L3.pc_npl 2011:L3.pc_npl 2012:L3.pc_npl
   2013:L3.pc_npl 2014:L3.pc_npl 2015:L3.pc_npl 2016:L3.pc_npl 2017:L3.pc_npl
   2018:L3.pc_npl 2010:L4.pc_npl 2011:L4.pc_npl 2012:L4.pc_npl 2013:L4.pc_npl
   2014:L4.pc_npl 2015:L4.pc_npl 2016:L4.pc_npl 2017:L4.pc_npl 2018:L4.pc_npl
 2, model(diff):
   2008:L2.avg_roa 2009:L2.avg_roa 2010:L2.avg_roa 2011:L2.avg_roa
   2012:L2.avg_roa 2013:L2.avg_roa 2014:L2.avg_roa 2015:L2.avg_roa
   2016:L2.avg_roa 2017:L2.avg_roa 2018:L2.avg_roa 2009:L3.avg_roa
   2010:L3.avg_roa 2011:L3.avg_roa 2012:L3.avg_roa 2013:L3.avg_roa
   2014:L3.avg_roa 2015:L3.avg_roa 2016:L3.avg_roa 2017:L3.avg_roa
   2018:L3.avg_roa 2010:L4.avg_roa 2011:L4.avg_roa 2012:L4.avg_roa
   2013:L4.avg_roa 2014:L4.avg_roa 2015:L4.avg_roa 2016:L4.avg_roa
   2017:L4.avg_roa 2018:L4.avg_roa
 3, model(diff):
   2008:L.gdp 2009:L.gdp 2010:L.gdp 2011:L.gdp 2012:L.gdp 2013:L.gdp
   2014:L.gdp 2015:L.gdp 2016:L.gdp 2017:L.gdp 2018:L.gdp 2008:L1.L.gdp
   2009:L1.L.gdp 2010:L1.L.gdp 2011:L1.L.gdp 2012:L1.L.gdp 2013:L1.L.gdp
   2014:L1.L.gdp 2015:L1.L.gdp 2016:L1.L.gdp 2017:L1.L.gdp 2018:L1.L.gdp
   2009:L2.L.gdp 2010:L2.L.gdp 2011:L2.L.gdp 2012:L2.L.gdp 2013:L2.L.gdp
   2014:L2.L.gdp 2015:L2.L.gdp 2016:L2.L.gdp 2017:L2.L.gdp 2018:L2.L.gdp
   2019:L2.L.gdp

. estat ser, ar(1/3)

Arellano-Bond test for autocorrelation of the first-differenced residuals
H0: no autocorrelation of order 1:     z =   -3.4427   Prob > |z|  =    0.0006
H0: no autocorrelation of order 2:     z =   -0.8221   Prob > |z|  =    0.4110
H0: no autocorrelation of order 3:     z =    0.9634   Prob > |z|  =    0.3354

. estat overid

Sargan-Hansen test of the overidentifying restrictions
H0: overidentifying restrictions are valid

1-step moment functions, 1-step weighting matrix       chi2(90)    =  482.2268
note: *                                                Prob > chi2 =    0.0000

1-step moment functions, 2-step weighting matrix       chi2(90)    =  109.3207
note: *                                                Prob > chi2 =    0.0812

* asymptotically invalid if the one-step weighting matrix is not optimal



xtabond2 pc_npl l.pc_npl l.gdp avg_roa, noleveleq iv(l.gdp) gmm(l.pc_npl, lag(2 4)) gmm(avg_roa, lag(2 4)) ///
nocons cluster(bank_id) ar(3) small

 xtabond2 pc_npl l.pc_npl l.gdp avg_roa, noleveleq iv(l.gdp) gmm(l.pc_npl, lag(2 4)) gmm(avg_roa, lag(2 4)) ///
> nocons cluster(bank_id) ar(3) small
Favoring speed over space. To switch, type or click on mata: mata set matafavor space, perm.
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: bank_id                         Number of obs      =      1232
Time variable : year                            Number of groups   =       125
Number of instruments = 59                      Obs per group: min =         4
F(3, 125)     =    120.46                                      avg =      9.86
Prob > F      =     0.000                                      max =        11
                                (Std. Err. adjusted for clustering on bank_id)
------------------------------------------------------------------------------
             |               Robust
      pc_npl |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      pc_npl |
         L1. |   .8271255   .0443198    18.66   0.000     .7394111    .9148399
             |
         gdp |
         L1. |  -.1652723   .0434872    -3.80   0.000    -.2513389   -.0792057
             |
     avg_roa |  -1.554786   .2433993    -6.39   0.000    -2.036504   -1.073069
------------------------------------------------------------------------------
Instruments for first differences equation
  Standard
    D.L.gdp
  GMM-type (missing=0, separate instruments for each period unless collapsed)
    L(2/4).avg_roa
    L(2/4).L.pc_npl
------------------------------------------------------------------------------
Arellano-Bond test for AR(1) in first differences: z =  -3.74  Pr > z =  0.000
Arellano-Bond test for AR(2) in first differences: z =  -0.87  Pr > z =  0.384
Arellano-Bond test for AR(3) in first differences: z =   1.08  Pr > z =  0.281
------------------------------------------------------------------------------
Sargan test of overid. restrictions: chi2(56)   = 276.04  Prob > chi2 =  0.000
  (Not robust, but not weakened by many instruments.)
Hansen test of overid. restrictions: chi2(56)   =  82.41  Prob > chi2 =  0.012
  (Robust, but weakened by many instruments.)

Difference-in-Hansen tests of exogeneity of instrument subsets:
  gmm(L.pc_npl, lag(2 4))
    Hansen test excluding group:     chi2(28)   =  51.61  Prob > chi2 =  0.004
    Difference (null H = exogenous): chi2(28)   =  30.80  Prob > chi2 =  0.326
  gmm(avg_roa, lag(2 4))
    Hansen test excluding group:     chi2(26)   =  41.14  Prob > chi2 =  0.030
    Difference (null H = exogenous): chi2(30)   =  41.28  Prob > chi2 =  0.082
  iv(L.gdp)
    Hansen test excluding group:     chi2(55)   =  79.60  Prob > chi2 =  0.017
    Difference (null H = exogenous): chi2(1)    =   2.82  Prob > chi2 =  0.093