Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help on running xtivreg with interaction

    Dear Statalist,

    I have a question on the implementation of an interaction term in an IV-regression. I found some previous discussions but no solution yet, that´s why I am posting this question.
    I have a panel of firms and run the following main regression where initial_size is a dummy denoting the initial size of a firm:

    Code:
    xtreg outcome c.tariff_rate c.tariff_rate#i.initial_size i.year, fe robust
    Now I want to instrument the tariff_rate but I am unsure what the correct Stata syntax would be. I tried the following command with tariff_rate_instrument being my instrumental variable (for now the lagged tariff rate)

    Code:
    xtivreg outcome i.year (c.tariff_rate c.tariff_rate#i.initial_size = c.tariff_rate_instrument c.tariff_rate_instrument#i.initial_size), fe vce(robust)
    but it gave me the error that "depvars may not be interactions". I don´t understand this error and on a more general level am unsure on how to exactly code in Stata IV regressions in a panel with interactions.

    Any help would greatly be appreciated!

    All the best
    Leon

  • #2
    For this, you may create a variable as an interaction term.

    See the example below:

    Code:
    . sysuse auto
    
    . gen int1 = weight*foreign
    
    . regress mpg i.foreign##c.weight
    
          Source |       SS           df       MS      Number of obs   =        74
    -------------+----------------------------------   F(3, 70)        =     51.99
           Model |  1686.54824         3  562.182746   Prob > F        =    0.0000
        Residual |  756.911221        70  10.8130174   R-squared       =    0.6902
    -------------+----------------------------------   Adj R-squared   =    0.6770
           Total |  2443.45946        73  33.4720474   Root MSE        =    3.2883
    
    ----------------------------------------------------------------------------------
                 mpg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -----------------+----------------------------------------------------------------
             foreign |
            Foreign  |   9.271333   4.500409     2.06   0.043     .2955505    18.24711
              weight |  -.0059751   .0006622    -9.02   0.000    -.0072958   -.0046544
                     |
    foreign#c.weight |
            Foreign  |  -.0044509   .0017846    -2.49   0.015    -.0080101   -.0008916
                     |
               _cons |   39.64696   2.243364    17.67   0.000     35.17272    44.12121
    ----------------------------------------------------------------------------------
    
    . regress mpg i.foreign c.weight int1
    
          Source |       SS           df       MS      Number of obs   =        74
    -------------+----------------------------------   F(3, 70)        =     51.99
           Model |  1686.54824         3  562.182746   Prob > F        =    0.0000
        Residual |  756.911221        70  10.8130174   R-squared       =    0.6902
    -------------+----------------------------------   Adj R-squared   =    0.6770
           Total |  2443.45946        73  33.4720474   Root MSE        =    3.2883
    
    ------------------------------------------------------------------------------
             mpg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
         foreign |
        Foreign  |   9.271333   4.500409     2.06   0.043     .2955505    18.24711
          weight |  -.0059751   .0006622    -9.02   0.000    -.0072958   -.0046544
            int1 |  -.0044509   .0017846    -2.49   0.015    -.0080101   -.0008916
           _cons |   39.64696   2.243364    17.67   0.000     35.17272    44.12121
    ------------------------------------------------------------------------------
    
    .
    Best regards,

    Marcos

    Comment


    • #3
      Thank you very much Marcos for your help! I wasn´t sure whether it is appropriate in an IV context to create the interaction on the left-hand side in the brackets manually, but apparently it is. Thank you very much again!

      Comment


      • #4
        Hi everyone,

        I tried the suggested approach but a further issue arose.

        If I use
        Code:
        xtreg outcome c.VAR1 c.VAR1#i.VAR2 i.year, fe
        I get the interaction and can evaluate it for each dummy of VAR2. However, when I run the following regression with Z being the instrument for VAR1 and calculate the interaction INT = VAR1* VAR2 manually beforehand
        Code:
        xtivreg outcome i.year (VAR1 INT = c.Z  c.Z#i.VAR2), fe vce(robust)
        the interaction is continuous and not broken down by dummy-values anymore.

        Does anyone know how to address this issue?

        Thank you very much!

        All the best
        Leon

        Comment

        Working...
        X