Announcement

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

  • Creating interaction variable manually

    Hello,

    I am trying to run -xtdpdsys- with an interaction variable of a dummy variable for an id (a country-pair) and time variable. But -xtdpdsys- doesn't allow for -i.pair##c.year-. Hence, I need to create the interactions manually, can anyone please help me on how to exactly do this?
    Maybe I should do a loop which would multiply each dummy for a country-pair by year, because I have 110 country-pairs and 20 years of observations, so it would be quite cumbersome to write it out by hand.


    Thank you in advance!

  • #2
    See -xi-

    Code:
    xi i.pair##c.year
    will create your interaction variables.

    hth,
    Jeph

    Comment


    • #3
      Dear Jeph,

      I have tried that already, but it produces error r(101), saying that interactions are not allowed. Is there a way to produce the interactions manually?

      Comment


      • #4
        If interactions are not allowed, then there is often a very good reason for that. In that case you do not want to create them manually.
        ---------------------------------
        Maarten L. Buis
        University of Konstanz
        Department of history and sociology
        box 40
        78457 Konstanz
        Germany
        http://www.maartenbuis.nl
        ---------------------------------

        Comment


        • #5
          The correct xi expression should be

          Code:
          xi i.pair*year
          The # and c. operators were introduced with factor variable notation and they should not be mixed with xi.

          Whether this is the correct way to include interaction terms in more complex models, like the one fit by xtdpdsys, I cannot tell. Perhaps Maarten's warning is well placed.

          Best
          Daniel

          Comment


          • #6
            Dear Maarten,

            I will try to explain the problem in a little more detail then. I am trying to estimate a gravity model using the GMM system (-xtdpdsys-), one of my variables is a country-pair specific time trend, which is basically a product of country-pair specific fixed effects (which in my case are dummies for a country-pair: i.pair) and of a time variable (year). I would think that this is done through the interaction variable, but please correct me if I'm wrong.

            regards,
            Alibek

            Comment


            • #7
              how did you solve this Alibek?

              regards,

              austin

              Comment


              • #8
                Dear Alibek. This may be a bit late for an attempted answer, but perhaps Austin may still need the answer.:
                I do not know what your general model specification is, but as you try to estimate the gravity model you must be careful of the amount of fixed effects-dimensions included in the model. By modelling an FE dimension try to think of the amount of dummies you generate (xtreg, areg, reghdfe etc. does not actually generate the dummies but the concept is the same). For the FE on bilateral pairs you have 1 dummy for every pair i.e. dummy1= USA-Canada dummy2=USA-Mexico.. .and so on. If you try to generate an additional time-varying effect within each pair, you end up with a dummy indicator for each observation. i.e dummy1 = USA-Canada year 1995. dummy2=USA-Canada 1996, dummy3 = USA-Mexico 1995... and so on. thus you have fixed all the variation you are interested in estimating.
                If the exports of USA-Canada1995 is significantly greater than USA-Canada1996 you will have a relatively larger coefficient on this FE-dummy that does not explain anything except that the exports are in fact larger with no apparent explanatory variables.

                If you believe that there is an increase in country-pair FE over years, this means that the variation over time is explained by something not included in the model. You must therefore explore which variables are unique for country-pairs and at the same time time-varying, i.e trade agreements, sanctions, relative exchange rates, conflicts etc.

                The above-mentioned statement is assuming that you model on aggregate exports. If you have a panel of industry-level exports the FE's above will work, as the industry-exports variation is still intact (each observation is unique by the mix of country-pair, year and industry). But what does this really tell you, except for which industries are exported the most globally? so as Maarten mentioned, the use of this interaction may not be a good idea.

                Regards,
                Søren

                Comment


                • #9
                  I am new to the stata softwear. I write interaction as i.pair#c.year in fgls regression and it gives output. Does it correct?

                  Comment


                  • #10
                    As long as the model corresponds to the model you want to estimate and you interpret the results correctly, then yes it is correct. Given the information you have given us, we cannot tell if that is the case. Many people are more familiar with interactions in the form of i.pair##c.year, but either form can be legitimate and equivalent if interpreted correctly.
                    ---------------------------------
                    Maarten L. Buis
                    University of Konstanz
                    Department of history and sociology
                    box 40
                    78457 Konstanz
                    Germany
                    http://www.maartenbuis.nl
                    ---------------------------------

                    Comment

                    Working...
                    X