Dear all,
I am using an unbalanced panel data with T=11 and N=200,000 to estimate a dynamic panel data model with the xtabond2 command (with Stata 14.1).

So far, I have assumed that the lag of my dependent variable (L.y) is endogenous and all of my other control variables are exogenous. When I estimate the model using xtabond2 and a two-step system GMM with the underlying assumptions, the coefficients are alright but the AR(2)-test is pretty weak and the Hansen-test doesn’t show the desired result. I dropped the first two years manually and I used the suboption orthogonal since I have gaps in my data.
Do you think that my specification in xtabond2 is correct or did I make some mistakes that I didnt’t recognize so far?
Code:
xtabond2 y L.y x1 x2 x3 x4 x5 x6 x7 yr3-yr11, twostep robust orthogonal ///
> gmm(L.y, lag(2 6) equation(both)) ///
> iv(x1 x2 x2 x4 x5 x6 x7, equation(both)) ///
> iv(yr3-yr11, equation(level))
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 ------------------------------------------------------------------------------
             |              Corrected
           y |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
           y |
         L1. |   .9530541   .0045813   208.03   0.000     .9440749    .9620332
             |
          x1 |   .0009905   .0030752     0.32   0.747    -.0050369    .0070178
          x2 |   -.001352   .0025792    -0.52   0.600    -.0064072    .0037032
          x3 |   .0043922   .0084974     0.52   0.605    -.0122625    .0210468
          x4 |  -.0003227   .0000352    -9.18   0.000    -.0003917   -.0002538
          x5 |  -.0012368   .0007791    -1.59   0.112    -.0027639    .0002903
          x6 |   .0751949   .0200101     3.76   0.000     .0359758    .1144139
          x7 |  -.0035094   .0006449    -5.44   0.000    -.0047734   -.0022453
         yr3 |   .3537909   .0098877    35.78   0.000     .3344114    .3731705
         yr4 |   .3586882   .0052821    67.91   0.000     .3483354     .369041
         yr5 |   .1584298   .0051346    30.86   0.000     .1483661    .1684935
         yr6 |   .1583574   .0041391    38.26   0.000     .1502449    .1664698
         yr7 |   .1061737   .0038656    27.47   0.000     .0985972    .1137502
         yr8 |   .1504396   .0037814    39.78   0.000     .1430281     .157851
         yr9 |   .1798849   .0034038    52.85   0.000     .1732137    .1865561
       yr10 |   .1689228   .0034978    48.29   0.000     .1620672    .1757784
       yr11 |    .0115624   .0032083     3.60   0.000     .0052743    .0178506
    _cons |    .1823155   .0733113     2.49   0.013      .038628    .3260029
 ------------------------------------------------------------------------------
Instruments for orthogonal deviations equation
  Standard
    FOD.(x1 x2 x2 x4 x5 x6 x7)
  GMM-type (missing=0, separate instruments for each period unless collapsed)
    L(2/6).L.y
Instruments for levels equation
  Standard
    yr3 yr4 yr5 yr6 yr7 yr8 yr9 yr10 y11
    x1 x2 x2 x4 x5 x6 x7
    _cons
  GMM-type (missing=0, separate instruments for each period unless collapsed)
    DL.L.y
------------------------------------------------------------------------------
Arellano-Bond test for AR(1) in first differences: z = -58.80  Pr > z =  0.000
Arellano-Bond test for AR(2) in first differences: z =  -1.57  Pr > z =  0.117
------------------------------------------------------------------------------
Sargan test of overid. restrictions: chi2(36)   = 313.40  Prob > chi2 =  0.000
  (Not robust, but not weakened by many instruments.)
Hansen test of overid. restrictions: chi2(36)   = 292.69  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(28)   = 277.21  Prob > chi2 =  0.000
    Difference (null H = exogenous): chi2(8)    =  15.48  Prob > chi2 =  0.050
  iv(x1 x2 x2 x4 x5 x6 x7)
    Hansen test excluding group:     chi2(30)   = 275.27  Prob > chi2 =  0.000
    Difference (null H = exogenous): chi2(6)    =  17.42  Prob > chi2 =  0.008
  iv(yr3 yr4 yr5 yr6 yr7 yr8 yr9 yr10 yr11, eq(level))
    Hansen test excluding group:     chi2(27)   = 188.63  Prob > chi2 =  0.000
    Difference (null H = exogenous): chi2(9)    = 104.06  Prob > chi2 =  0.000
When I specify my iv’s separately, I get similar results for the coefficients but different results for the Difference-in-Hansen test:
Code:
Difference-in-Hansen tests of exogeneity of instrument subsets:
  GMM instruments for levels
    Hansen test excluding group:     chi2(29)   = 279.04  Prob > chi2 =  0.000
    Difference (null H = exogenous): chi2(8)    =  14.31  Prob > chi2 =  0.074
  iv(x1)
    Hansen test excluding group:     chi2(36)   = 292.79  Prob > chi2 =  0.000
    Difference (null H = exogenous): chi2(1)    =   0.56  Prob > chi2 =  0.454
  iv(x2)
    Hansen test excluding group:     chi2(36)   = 292.54  Prob > chi2 =  0.000
    Difference (null H = exogenous): chi2(1)    =   0.81  Prob > chi2 =  0.368
  iv(x3)
    Hansen test excluding group:     chi2(36)   = 292.69  Prob > chi2 =  0.000
    Difference (null H = exogenous): chi2(1)    =   0.66  Prob > chi2 =  0.417
  iv(x4)
    Hansen test excluding group:     chi2(36)   = 293.14  Prob > chi2 =  0.000
    Difference (null H = exogenous): chi2(1)    =   0.21  Prob > chi2 =  0.643
  iv(x5)
    Hansen test excluding group:     chi2(36)   = 293.26  Prob > chi2 =  0.000
    Difference (null H = exogenous): chi2(1)    =   0.09  Prob > chi2 =  0.766
  iv(x6)
    Hansen test excluding group:     chi2(36)   = 293.26  Prob > chi2 =  0.000
    Difference (null H = exogenous): chi2(1)    =   0.10  Prob > chi2 =  0.757
  iv(x7)
    Hansen test excluding group:     chi2(36)   = 293.35  Prob > chi2 =  0.000
    Difference (null H = exogenous): chi2(1)    =   0.00  Prob > chi2 =  0.982
  iv(yr3 yr4 yr5 yr6 yr7 yr8 yr9 yr10 yr11, eq(level))
    Hansen test excluding group:     chi2(28)   = 188.71  Prob > chi2 =  0.000
    Difference (null H = exogenous): chi2(9)    = 104.64  Prob > chi2 =  0.000
I am struggling with the correct interpretation of the Difference-in-Hansen test since the 'Hansen test excluding group' is always highly rejected whereas the 'Difference' test is not.

I am also not sure if all of my controls are really exogenous or if they're predetermined or even endogenous.
Can I use the ivreg2 command to test if my controls are exogenous? So for example:
Code:
xi: ivreg2 y L.y x2 x3 x4 x5 x6 x7 (x1=L.x1) i.yr, gmm2s robust cluster(ID) endogtest(x1)
Do you have any suggestions how I could fix my regression command so that the AR(2) and Hansen test show the desired results?
Thanks a lot in advance for your help, any help is highly appreciated.

Kind regards,
Ferdi