Dear all,

Hello! I am using panel data and I did an Instrumental Variable estimation using the -xtivreg- and random effect command.
However, when I use the command -estat endog- to perform the test for endogeneity and the command -estat firststage- , Stata says that my commands are invalid,

1-Is there a way I can overcome this issue? as my instrument variable is a time invariant variable

2- what is the optimal sample size in my case ? becz for this study very limited data is available

3- Lasty, i observed that when i use log of independent variable then the independent variable shows a positive sign and when i use change in independent variable like (current week newc - last week newc ) then it shows a negative relationship with return which is also a change in current -last week return as the results in both cases are given below... i belive tht the change in independent variable is correct and shows better reflects the real case scenario.. can you also share your expert opinion here too? am i right if i use change in newc as my independent variable instead of log?
Thank you in advance.

Code:
. xtivreg return (cnewc=epi) lnpop i.week i.ccode, re vce(cluster ccode)
note: 16.ccode omitted because of collinearity

G2SLS random-effects IV regression              Number of obs     =         80
Group variable: ccode                           Number of groups  =         16

R-sq:                                           Obs per group:
     within  = 0.8016                                         min =          5
     between = 1.0000                                         avg =        5.0
     overall = 0.8051                                         max =          5


                                                Wald chi2(3)      =     301.38
corr(u_i, X)       = 0 (assumed)                Prob > chi2       =     0.0000

                                 (Std. Err. adjusted for 16 clusters in ccode)
------------------------------------------------------------------------------
             |               Robust
      return |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       cnewc |  -.0012327   .0000612   -20.14   0.000    -.0013526   -.0011127
       lnpop |   .0002761   .0002695     1.02   0.305     -.000252    .0008042
             |
        week |
          2  |  -.1428736   .0086981   -16.43   0.000    -.1599216   -.1258256
          3  |  -.0287474   .0200269    -1.44   0.151    -.0679994    .0105046
          4  |   .0723392   .0148804     4.86   0.000     .0431742    .1015042
          5  |   .0229504   .0094713     2.42   0.015      .004387    .0415138
             |
       ccode |
          2  |  -.0249133   .0008014   -31.09   0.000     -.026484   -.0233427
          3  |   .0112486    .000978    11.50   0.000     .0093317    .0131656
          4  |  -.0177978   .0005632   -31.60   0.000    -.0189016    -.016694
          5  |  -.0151013   .0005151   -29.32   0.000    -.0161108   -.0140917
          6  |  -.0289862   .0006398   -45.30   0.000    -.0302402   -.0277322
          7  |  -.0055123    .000614    -8.98   0.000    -.0067158   -.0043089
          8  |  -.0091792   .0008457   -10.85   0.000    -.0108368   -.0075216
          9  |   .0028841   .0007202     4.00   0.000     .0014725    .0042958
         10  |  -.0100807    .001121    -8.99   0.000    -.0122778   -.0078835
         11  |  -.0229465   .0003582   -64.07   0.000    -.0236485   -.0222445
         12  |  -.0085706   .0010427    -8.22   0.000    -.0106143   -.0065268
         13  |   .0126779   .0008793    14.42   0.000     .0109544    .0144013
         14  |  -.0110761   .0006022   -18.39   0.000    -.0122564   -.0098958
         15  |  -.0067423   .0000562  -120.03   0.000    -.0068524   -.0066322
         16  |          0  (omitted)
             |
       _cons |          0  (omitted)
-------------+----------------------------------------------------------------
     sigma_u |          0
     sigma_e |  .28572576
         rho |          0   (fraction of variance due to u_i)
------------------------------------------------------------------------------
Instrumented:   cnewc
Instruments:    lnpop 2.week 3.week 4.week 5.week 2.ccode 3.ccode 4.ccode
                5.ccode 6.ccode 7.ccode 8.ccode 9.ccode 10.ccode 11.ccode
                12.ccode 13.ccode 14.ccode 15.ccode epi
------------------------------------------------------------------------------
independent variable as log
Code:
. xtivreg return (lnnewc=epi) lnpop i.week i.ccode, re vce(cluster ccode)
note: 16.ccode omitted because of collinearity

G2SLS random-effects IV regression              Number of obs     =         80
Group variable: ccode                           Number of groups  =         16

R-sq:                                           Obs per group:
     within  = 0.8169                                         min =          5
     between = 1.0000                                         avg =        5.0
     overall = 0.8201                                         max =          5


                                                Wald chi2(3)      =     413.85
corr(u_i, X)       = 0 (assumed)                Prob > chi2       =     0.0000

                                 (Std. Err. adjusted for 16 clusters in ccode)
------------------------------------------------------------------------------
             |               Robust
      return |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      lnnewc |   .0060875   .0020355     2.99   0.003      .002098    .0100771
       lnpop |   .0049055    .000267    18.37   0.000     .0043821    .0054289
             |
        week |
          2  |  -.1618011   .0098249   -16.47   0.000    -.1810576   -.1425446
          3  |  -.0477755   .0165408    -2.89   0.004    -.0801948   -.0153561
          4  |   .0528445   .0151661     3.48   0.000     .0231195    .0825695
          5  |          0  (omitted)
             |
       ccode |
          2  |   -.004538   .0014151    -3.21   0.001    -.0073116   -.0017644
          3  |   .0365746   .0018804    19.45   0.000     .0328892    .0402601
          4  |  -.0165036   .0033607    -4.91   0.000    -.0230903   -.0099168
          5  |  -.0157174   .0036757    -4.28   0.000    -.0229216   -.0085132
          6  |  -.0356899   .0065512    -5.45   0.000    -.0485299   -.0228498
          7  |   .0103665   .0011737     8.83   0.000     .0080661     .012667
          8  |   .0010767   .0022675     0.47   0.635    -.0033675    .0055209
          9  |   .0153335   .0006886    22.27   0.000     .0139839    .0166831
         10  |   .0121774   .0001084   112.29   0.000     .0119648    .0123899
         11  |  -.0267325   .0036785    -7.27   0.000    -.0339422   -.0195228
         12  |   .0132934    .000287    46.32   0.000     .0127309    .0138559
         13  |   .0254747   .0016441    15.49   0.000     .0222523     .028697
         14  |  -.0025233   .0011965    -2.11   0.035    -.0048685   -.0001782
         15  |  -.0148851   .0031011    -4.80   0.000    -.0209631    -.008807
         16  |          0  (omitted)
             |
       _cons |  -.1213726   .0072204   -16.81   0.000    -.1355243   -.1072208
-------------+----------------------------------------------------------------
     sigma_u |          0
     sigma_e |  .04248007
         rho |          0   (fraction of variance due to u_i)
------------------------------------------------------------------------------
Instrumented:   lnnewc
Instruments:    lnpop 2.week 3.week 4.week 5.week 2.ccode 3.ccode 4.ccode
                5.ccode 6.ccode 7.ccode 8.ccode 9.ccode 10.ccode 11.ccode
                12.ccode 13.ccode 14.ccode 15.ccode epi
------------------------------------------------------------------------------