Hi,

I am wondering if anyone had any experience in including an interaction term in 2SLS using xtivreg?

I am now having a successful 2SLS, not including any interaction terms as follows:

Code:
xtivreg PatMV_real_log Lev CAPX_AT Size rd_log sale_log number_log (inverse_D = toughness_normalized) i.fyear, fe
inverse_D is the endogenous variable and toughness is the instrumental variable

This is successful, and I have the results like this:

Code:
Fixed-effects (within) IV regression            Number of obs     =      5,066
Group variable: all_cluster                     Number of groups  =        554

R-squared:                                      Obs per group:
     Within  =      .                                         min =          1
     Between = 0.2823                                         avg =        9.1
     Overall = 0.3891                                         max =         31

                                                Wald chi2(37)     =   19922.00
corr(u_i, Xb) = 0.0856                          Prob > chi2       =     0.0000

------------------------------------------------------------------------------
PatMV_real~g | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
-------------+----------------------------------------------------------------
   inverse_D |   13.87709   5.667382     2.45   0.014     2.769226    24.98496
         Lev |   .0032969   .0029638     1.11   0.266     -.002512    .0091058
     CAPX_AT |   1.526791   .6927957     2.20   0.028     .1689361    2.884645
        Size |   .0862929   .0621718     1.39   0.165    -.0355617    .2081474
      rd_log |   -.084102   .3179503    -0.26   0.791    -.7072731     .539069
    sale_log |   .1517564   .0322944     4.70   0.000     .0884605    .2150523
  number_log |   .0404435   .0334691     1.21   0.227    -.0251548    .1060417
             |
       fyear |
       1986  |  -.1775167    .298694    -0.59   0.552    -.7629462    .4079129
       1987  |  -.0519888   .3001776    -0.17   0.862    -.6403262    .5363485
       1988  |  -.0481431   .3076404    -0.16   0.876    -.6511073     .554821
       1989  |   .0163748   .2844115     0.06   0.954    -.5410614     .573811
       1990  |  -.0718744   .2990964    -0.24   0.810    -.6580925    .5143437
       1991  |  -.2075746   .3433348    -0.60   0.545    -.8804984    .4653492
       1992  |  -.2268283   .3502615    -0.65   0.517    -.9133282    .4596715
       1993  |   .1302594   .3597807     0.36   0.717    -.5748978    .8354166
       1994  |    .394627    .391701     1.01   0.314    -.3730928    1.162347
       1995  |  -.2333602   .4519216    -0.52   0.606     -1.11911    .6523898
       1996  |   .1275317   .4482286     0.28   0.776    -.7509803    1.006044
       1997  |  -.1892146     .55809    -0.34   0.735    -1.283051    .9046217
       1998  |  -.3070482   .5836953    -0.53   0.599     -1.45107    .8369736
       1999  |  -.6370051   .6263369    -1.02   0.309    -1.864603    .5905927
       2000  |  -.8418151   .6641659    -1.27   0.205    -2.143556    .4599261
       2001  |  -1.119607   .7252079    -1.54   0.123    -2.540988    .3017744
       2002  |  -1.545625   .8150542    -1.90   0.058    -3.143102    .0518518
       2003  |  -1.636655   .8022847    -2.04   0.041    -3.209104   -.0642054
       2004  |  -1.786408   .8443835    -2.12   0.034    -3.441369   -.1314466
       2005  |  -1.878826   .8648506    -2.17   0.030    -3.573902   -.1837496
       2006  |  -2.023935   .8749888    -2.31   0.021    -3.738882   -.3089884
       2007  |  -2.223262   .9041965    -2.46   0.014    -3.995455   -.4510695
       2008  |  -2.062127   .8859147    -2.33   0.020    -3.798488   -.3257664
       2009  |   -2.24123   .9245712    -2.42   0.015    -4.053357   -.4291043
       2010  |  -2.249556   .9657848    -2.33   0.020    -4.142459   -.3566523
       2011  |  -2.138431    .923046    -2.32   0.021    -3.947568   -.3292945
       2012  |  -2.460573   .9528901    -2.58   0.010    -4.328203    -.592943
       2013  |  -3.264231   .9082721    -3.59   0.000    -5.044412   -1.484051
       2014  |  -4.738765   .8172058    -5.80   0.000    -6.340459   -3.137071
       2015  |  -7.135273     .62943   -11.34   0.000    -8.368933   -5.901613
             |
       _cons |   1.398011    .499853     2.80   0.005     .4183173    2.377705
-------------+----------------------------------------------------------------
     sigma_u |  1.6160709
     sigma_e |  1.3406031
         rho |   .5923664   (fraction of variance due to u_i)
------------------------------------------------------------------------------
 F test that all u_i=0: F(553,4475) =     4.74            Prob > F    = 0.0000
------------------------------------------------------------------------------
Instrumented: inverse_D
 Instruments: Lev CAPX_AT Size rd_log sale_log number_log 1986.fyear
              1987.fyear 1988.fyear 1989.fyear 1990.fyear 1991.fyear
              1992.fyear 1993.fyear 1994.fyear 1995.fyear 1996.fyear
              1997.fyear 1998.fyear 1999.fyear 2000.fyear 2001.fyear
              2002.fyear 2003.fyear 2004.fyear 2005.fyear 2006.fyear
              2007.fyear 2008.fyear 2009.fyear 2010.fyear 2011.fyear
              2012.fyear 2013.fyear 2014.fyear 2015.fyear toughness_normalized
And now, I want to add an interaction term: log_analysts. I found that in previous posts that integrating interaction terms into a new variable is recommended, so I did:

Code:
gen int_log_analysts = c.inverse_D#c.log_analysts

gen int_log_analysts_iv = c.toughness_normalized#c.log_analysts
And then I suppose that my code should be:

Code:
xtivreg PatMV_real_log Lev CAPX_AT Size rd_log sale_log number_log log_analysts (inverse_D int_log_analysts= toughness_normalized int_log_analysts_iv) i.fyear, fe
I wonder if this is correct. In particular, I want to know if variable 'log_analysts' should exist outside the parenthesis, and more importantly: does this mean that I am using one instrumental variable 'toughness' on one endogenous variable 'inverse_D'? I was worried that this implies using 2 instruments on 2 endogenous variables, with 2x2 = 4 first stage estimations.

For more information, I am trying to mimic the code using ivreg2:

Code:
ivreg2 y w (x c.x#c.w= z c.z#c.w)
where w is the interaction term variable, x is the endogenous variable and z is the instrument. I don't know if it will be the same in xtivreg though. Any other suggestions or recommendations will be much appreciated.

Many Thanks,
Harry