Hello everyone,

I am working with the command xtabond2 for Difference and System GMM using Panel Data.

My data set contains 8,232 students in a Panel Data format with T=5. For each student, I have the test scores (depvar) and a list of observed variables over the time period (indepvar).

During the time series (2003-2008), a policy change is implemented in state schools in year 2007. Then, students from state schools are my treatment group and students from municipal schools are the control group. My DiD is 1 if student is enrolled in state school (treated) in post-treatment period (time).


I assume that the schools are able to select the students based on their previous scores. In a linear model, I would include a school fixed effect in the model such as:
Code:
xtreg profic_mat DiD time treated i.IDescola $controlVar, fe robust
However, when I include the school fixed effect in the GMM, the estimation of xtabond2 will omit automatically some schools, and consequently, Stata will not be able to estimate the Sargar and Arellano-Bond Tests.

Code:
. xi: xtabond2 L(0/2).Zprofic_mat DiD time treated Du_o5_q01 Du_o5_q26 Du_o5_q25 Du_o5_q09 Du_mudou o5_q02_1 o5_q02_2 o5_q02_3 o5_q02_5 escomaep_
> 1 escomaep_2 escomaep_3 escomaep_4 escopaip_2 escopaip_3 escopaip_4 escopaip_5 Renda_2 Renda_3 Renda_4 Renda_5 Du_q111 educaTeach_1 educaTeach_
> 2 educaTeach_3 educaTeach_4 q110_1 q110_2 q110_3 q110_4 q110_6 q108_1 q108_3 q108_4 q108_5 q108_6 q106_2 q106_3 q106_4 q106_5 q105_1 q105_3 q10
> 4_3 q104_2 Du_e029 Du_e025 Du_e024 Du_e027 Du_e023 Du_q036 Du_q038 Du_q037 Du_q039 Du_q044 Du_q045 Du_q046 i.wave i.IDescola, /// Time and scho
> ol fixed effects
> gmmstyle(L(1/2).Zprofic_mat, equation(diff) lag(1 2)) ///
> ivstyle(DiD time treated Du_o5_q01 Du_o5_q26 Du_o5_q25 Du_o5_q09 Du_mudou o5_q02_1 o5_q02_2 o5_q02_3 o5_q02_5 escomaep_1 escomaep_2 escomaep_3
> escomaep_4 escopaip_2 escopaip_3 escopaip_4 escopaip_5 Renda_2 Renda_3 Renda_4 Renda_5 Du_q111 educaTeach_1 educaTeach_2 educaTeach_3 educaTeac
> h_4 q110_1 q110_2 q110_3 q110_4 q110_6 q108_1 q108_3 q108_4 q108_5 q108_6 q106_2 q106_3 q106_4 q106_5 q105_1 q105_3 q104_3 q104_2 Du_e029 Du_e0
> 25 Du_e024 Du_e027 Du_e023 Du_q036 Du_q038 Du_q037 Du_q039 Du_q044 Du_q045 Du_q046 i.wave i.IDescola, eq(level)) ///
> cluster(IDturma) twostep small
i.wave            _Iwave_1-5          (naturally coded; _Iwave_1 omitted)
i.IDescola        _IIDescola_35018107-35924957(naturally coded; _IIDescola_35018107 omitted)
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 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: IDaluno                         Number of obs      =      2792
Time variable : wave                            Number of groups   =      1468
Number of instruments = 93                      Obs per group: min =         1
F(125, 266)   =      8.94                                      avg =      1.90
Prob > F      =     0.000                                      max =         3
                                       (Std. Err. adjusted for clustering on IDturma)
-------------------------------------------------------------------------------------
                    |              Corrected
        Zprofic_mat |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
--------------------+----------------------------------------------------------------
        Zprofic_mat |
                L1. |   .2537511   .1634702     1.55   0.122     -.068109    .5756113
                L2. |   .0465596   .0592663     0.79   0.433    -.0701312    .1632503
                    |
                DiD |    .448612   .2869837     1.56   0.119    -.1164366    1.013661
               time |          0  (omitted)
            treated |  -.2301341   .6129212    -0.38   0.708    -1.436928    .9766602
          Du_o5_q01 |  -.0430907   .0397603    -1.08   0.279    -.1213756    .0351943
          Du_o5_q26 |  -.0251998   .0636501    -0.40   0.692     -.150522    .1001223
          Du_o5_q25 |   .0688531   .0428434     1.61   0.109    -.0155022    .1532084
          Du_o5_q09 |   .1848394   .0826963     2.24   0.026     .0220168     .347662
           Du_mudou |    .080205   .1004046     0.80   0.425    -.1174838    .2778939
           o5_q02_1 |    .191965   .1412245     1.36   0.175    -.0860951    .4700251
           o5_q02_2 |   .2069986   .1623368     1.28   0.203    -.1126299    .5266271
           o5_q02_3 |   -.156176    .130866    -1.19   0.234     -.413841    .1014891
           o5_q02_5 |   .0199771   .1023867     0.20   0.845    -.1816144    .2215687
         escomaep_1 |   -.040428   .1185954    -0.34   0.733    -.2739331    .1930771
         escomaep_2 |   .0257018   .1122042     0.23   0.819    -.1952195    .2466231
         escomaep_3 |   .1764039   .1640517     1.08   0.283    -.1466012     .499409
         escomaep_4 |   .1896322   .1124265     1.69   0.093    -.0317268    .4109913
         escopaip_2 |    .140275   .0693525     2.02   0.044     .0037253    .2768246
         escopaip_3 |   .1708387   .0678455     2.52   0.012     .0372562    .3044212
         escopaip_4 |   .1634181   .1095341     1.49   0.137    -.0522461    .3790822
         escopaip_5 |   .4912139   .1526228     3.22   0.001     .1907115    .7917164
            Renda_2 |   .0933153   .0616152     1.51   0.131    -.0280002    .2146308
            Renda_3 |   .0163953   .0933256     0.18   0.861    -.1673556    .2001461
            Renda_4 |   .2666845   .0873947     3.05   0.003     .0946112    .4387578
            Renda_5 |   .2662964    .110231     2.42   0.016     .0492601    .4833327
            Du_q111 |   .5380821   .4176415     1.29   0.199    -.2842215    1.360386
       educaTeach_1 |  -3.019066   3.429023    -0.88   0.379    -9.770545    3.732414
       educaTeach_2 |  -5.912968   11.67559    -0.51   0.613     -28.9013    17.07536
       educaTeach_3 |  -2.065842    2.69118    -0.77   0.443    -7.364567    3.232883
       educaTeach_4 |  -1.856968   2.623601    -0.71   0.480    -7.022635    3.308699
             q110_1 |  -.3607261    .546011    -0.66   0.509    -1.435779    .7143273
             q110_2 |   .2978884    .221639     1.34   0.180    -.1385015    .7342783
             q110_3 |   .8829852   .4686447     1.88   0.061    -.0397398     1.80571
             q110_4 |   .5271323   .2760155     1.91   0.057    -.0163207    1.070585
             q110_6 |   .9013528   .7762364     1.16   0.247    -.6269964    2.429702
             q108_1 |  -.1960608   .3830281    -0.51   0.609    -.9502134    .5580917
             q108_3 |   .9061771   .5481086     1.65   0.099    -.1730062     1.98536
             q108_4 |   .0042357   .1711532     0.02   0.980    -.3327518    .3412231
             q108_5 |   .1451295   .1802297     0.81   0.421    -.2097289    .4999878
             q108_6 |   .4085612   .2218124     1.84   0.067    -.0281701    .8452925
             q106_2 |   .5777173   .3246634     1.78   0.076    -.0615197    1.216954
             q106_3 |  -.0988376   .1491627    -0.66   0.508    -.3925274    .1948521
             q106_4 |  -.0322118    .152472    -0.21   0.833    -.3324174    .2679938
             q106_5 |  -.1465515    .306685    -0.48   0.633    -.7503905    .4572875
             q105_1 |   .0787046   .0759949     1.04   0.301    -.0709235    .2283327
             q105_3 |  -.2406296   .4147677    -0.58   0.562    -1.057275    .5760157
             q104_3 |  -.1188809   .1116265    -1.06   0.288    -.3386647    .1009029
             q104_2 |  -.2395509   .1670625    -1.43   0.153     -.568484    .0893823
            Du_e029 |  -.0434536   .3644224    -0.12   0.905     -.760973    .6740657
            Du_e025 |    .122461   .4459636     0.27   0.784    -.7556068    1.000529
            Du_e024 |   .5351176   .4680328     1.14   0.254    -.3864026    1.456638
            Du_e027 |   .2289053   .1812665     1.26   0.208    -.1279943    .5858049
            Du_e023 |   .3873136   .4261825     0.91   0.364    -.4518068    1.226434
            Du_q036 |   .1698781   .2570093     0.66   0.509    -.3361532    .6759095
            Du_q038 |  -.1834807   .1135685    -1.62   0.107    -.4070882    .0401269
            Du_q037 |  -.3691757   .1856809    -1.99   0.048     -.734767   -.0035844
            Du_q039 |  -.0190678    .287225    -0.07   0.947    -.5845916    .5464559
            Du_q044 |  -.4120254    .495199    -0.83   0.406    -1.387034    .5629829
            Du_q045 |   .4063863   .3802124     1.07   0.286    -.3422225    1.154995
            Du_q046 |   .3986951   .2680375     1.49   0.138    -.1290499    .9264401
           _Iwave_2 |          0  (omitted)
           _Iwave_3 |   .2099717   .2614781     0.80   0.423    -.3048583    .7248017
           _Iwave_4 |          0  (omitted)
           _Iwave_5 |  -.2529867   .2569849    -0.98   0.326      -.75897    .2529966
_IIDescola_35018348 |          0  (omitted)
_IIDescola_35018387 |  -.0818578   .5368907    -0.15   0.879    -1.138954    .9752383
_IIDescola_35018399 |          0  (omitted)
_IIDescola_35018485 |   .3155897   .3655157     0.86   0.389    -.4040823    1.035262
_IIDescola_35018512 |    .143877   .5348828     0.27   0.788    -.9092657     1.19702
_IIDescola_35018824 |   .4443162   .4797733     0.93   0.355    -.5003201    1.388953
_IIDescola_35042648 |          0  (omitted)
_IIDescola_35047193 |          0  (omitted)
_IIDescola_35059122 |          0  (omitted)
_IIDescola_35059158 |   .3268788   .6604518     0.49   0.621    -.9734995    1.627257
_IIDescola_35059161 |  -.0629993   .2322528    -0.27   0.786    -.5202869    .3942884
_IIDescola_35059171 |  -.1820903   .1765463    -1.03   0.303    -.5296964    .1655157
_IIDescola_35059213 |   .2274499   .2299902     0.99   0.324     -.225383    .6802828
_IIDescola_35059225 |          0  (omitted)
_IIDescola_35059237 |  -.1043981   .3003652    -0.35   0.728    -.6957938    .4869976
_IIDescola_35071122 |   .4696931   .2185348     2.15   0.033     .0394151    .8999712
_IIDescola_35083811 |          0  (omitted)
_IIDescola_35083823 |          0  (omitted)
_IIDescola_35083847 |  -.2173451   .3715826    -0.58   0.559    -.9489623    .5142721
_IIDescola_35083859 |  -.0878887   .4867207    -0.18   0.857    -1.046204    .8704266
_IIDescola_35083860 |          0  (omitted)
_IIDescola_35084153 |   4.895327   3.468213     1.41   0.159    -1.933315    11.72397
_IIDescola_35086236 |  -.0757299   .1568506    -0.48   0.630    -.3845565    .2330967
_IIDescola_35088614 |  -.2404066   .5230525    -0.46   0.646    -1.270256    .7894431
_IIDescola_35088648 |          0  (omitted)
_IIDescola_35088675 |  -.1844955   .2543595    -0.73   0.469    -.6853096    .3163185
_IIDescola_35088705 |  -.4447369   .5724957    -0.78   0.438    -1.571936    .6824626
_IIDescola_35091455 |   -20.9064    12.8691    -1.62   0.105    -46.24466    4.431867
_IIDescola_35112513 |          0  (omitted)
_IIDescola_35112641 |          0  (omitted)
_IIDescola_35112859 |          0  (omitted)
_IIDescola_35112872 |          0  (omitted)
_IIDescola_35121009 |          0  (omitted)
_IIDescola_35123067 |          0  (omitted)
_IIDescola_35123080 |          0  (omitted)
_IIDescola_35126846 |          0  (omitted)
_IIDescola_35131994 |          0  (omitted)
_IIDescola_35132263 |          0  (omitted)
_IIDescola_35138769 |          0  (omitted)
_IIDescola_35140636 |          0  (omitted)
_IIDescola_35156590 |          0  (omitted)
_IIDescola_35159955 |          0  (omitted)
_IIDescola_35162024 |          0  (omitted)
_IIDescola_35172467 |          0  (omitted)
_IIDescola_35172510 |          0  (omitted)
_IIDescola_35172716 |          0  (omitted)
_IIDescola_35185103 |          0  (omitted)
_IIDescola_35283685 |   .6349923    .520267     1.22   0.223     -.389373    1.659358
_IIDescola_35802062 |          0  (omitted)
_IIDescola_35901124 |          0  (omitted)
_IIDescola_35901143 |          0  (omitted)
_IIDescola_35903917 |   .0293609   .3065506     0.10   0.924    -.5742134    .6329351
_IIDescola_35905446 |   .0460966    .554006     0.08   0.934    -1.044698    1.136891
_IIDescola_35907397 |  -.3803192   .2787009    -1.36   0.174    -.9290597    .1684213
_IIDescola_35909397 |          0  (omitted)
_IIDescola_35913005 |  -.1219617   .3336628    -0.37   0.715    -.7789178    .5349945
_IIDescola_35913923 |   .4049739   .3900606     1.04   0.300    -.3630252    1.172973
_IIDescola_35914885 |   .1912228   .3279678     0.58   0.560    -.4545203     .836966
_IIDescola_35924945 |   .0655114   .4482779     0.15   0.884     -.817113    .9481359
_IIDescola_35924957 |   .1630651    .462909     0.35   0.725    -.7483668    1.074497
              _cons |  -.0487338   1.703039    -0.03   0.977    -3.401885    3.304418
-------------------------------------------------------------------------------------
Instruments for first differences equation
  GMM-type (missing=0, separate instruments for each period unless collapsed)
    L(1/2).(L.Zprofic_mat L2.Zprofic_mat)
Instruments for levels equation
  Standard
    DiD time treated Du_o5_q01 Du_o5_q26 Du_o5_q25 Du_o5_q09 Du_mudou o5_q02_1
    o5_q02_2 o5_q02_3 o5_q02_5 escomaep_1 escomaep_2 escomaep_3 escomaep_4
    escopaip_2 escopaip_3 escopaip_4 escopaip_5 Renda_2 Renda_3 Renda_4
    Renda_5 Du_q111 educaTeach_1 educaTeach_2 educaTeach_3 educaTeach_4 q110_1
    q110_2 q110_3 q110_4 q110_6 q108_1 q108_3 q108_4 q108_5 q108_6 q106_2
    q106_3 q106_4 q106_5 q105_1 q105_3 q104_3 q104_2 Du_e029 Du_e025 Du_e024
    Du_e027 Du_e023 Du_q036 Du_q038 Du_q037 Du_q039 Du_q044 Du_q045 Du_q046
    _Iwave_2 _Iwave_3 _Iwave_4 _Iwave_5 _IIDescola_35018348
    _IIDescola_35018387 _IIDescola_35018399 _IIDescola_35018485
    _IIDescola_35018512 _IIDescola_35018824 _IIDescola_35042648
    _IIDescola_35047193 _IIDescola_35059122 _IIDescola_35059158
    _IIDescola_35059161 _IIDescola_35059171 _IIDescola_35059213
    _IIDescola_35059225 _IIDescola_35059237 _IIDescola_35071122
    _IIDescola_35083811 _IIDescola_35083823 _IIDescola_35083847
    _IIDescola_35083859 _IIDescola_35083860 _IIDescola_35084153
    _IIDescola_35086236 _IIDescola_35088614 _IIDescola_35088648
    _IIDescola_35088675 _IIDescola_35088705 _IIDescola_35091455
    _IIDescola_35112513 _IIDescola_35112641 _IIDescola_35112859
    _IIDescola_35112872 _IIDescola_35121009 _IIDescola_35123067
    _IIDescola_35123080 _IIDescola_35126846 _IIDescola_35131994
    _IIDescola_35132263 _IIDescola_35138769 _IIDescola_35140636
    _IIDescola_35156590 _IIDescola_35159955 _IIDescola_35162024
    _IIDescola_35172467 _IIDescola_35172510 _IIDescola_35172716
    _IIDescola_35185103 _IIDescola_35283685 _IIDescola_35802062
    _IIDescola_35901124 _IIDescola_35901143 _IIDescola_35903917
    _IIDescola_35905446 _IIDescola_35907397 _IIDescola_35909397
    _IIDescola_35913005 _IIDescola_35913923 _IIDescola_35914885
    _IIDescola_35924945 _IIDescola_35924957
    _cons
------------------------------------------------------------------------------
Arellano-Bond test for AR(1) in first differences: z =  -3.10  Pr > z =  0.002
Arellano-Bond test for AR(2) in first differences: z =      .  Pr > z =      .
------------------------------------------------------------------------------
Sargan test of overid. restrictions: chi2(-33)  =   6.42  Prob > chi2 =      .
  (Not robust, but not weakened by many instruments.)
Hansen test of overid. restrictions: chi2(-33)  =   1.77  Prob > chi2 =      .
  (Robust, but weakened by many instruments.)


.
end of do-file

***QUESTIONS**
  1. How can I calculate Sargan and Arellano-Bond Tests by omitted variables?
  2. Will the inclusion of FE change the values of Sargan and Arellano-Bond Tests?
I welcome all of your comments, feature requests and suggestions.