Announcement

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

  • Gravity model with fixed effects - controlling for the heterogeneity

    Hi Stata users,

    I'm quite new to Stata and econometric packages in general, so I'd like to get some hints on how to specify a gravity model for international trade between different countries. My panel consists of 133 countries over 19 years - thus we have 17556 combinations of importers (ci) and exporters (cj), for each year. I pretend to follow the regressions using fixed effects, such as the equation number 3 (page six) of Cheng e Wall (2005) [link: http://research.stlouisfed.org/publi.../01/Cheng.pdf], i.e. controlling the heterogeneity for "country-pair" effects and the effects for each year t of my panel.

    I use the Stata/SE 12.0, on a Intel Core i5, 1.70GHz computer (not sure if this information is useful anyway).

    Anyone could help me to create these dummies for "country-pair" and "time" effects please? I would run regression using the xtreg command, and my dataset is already adjusted on Stata for panel structure, along with other usual variables of gravity equation, e.g. GDP, population, weighted distance (the remoteness), country size etc. A colleague of mine told there was no need to create and specify the dummies for the "country-pair" effects, since the xtreg command would implicitly consider it on the regression... I'm not sure of this, and that's why I request your attention with my doubts.

    Thank you all in advance!
    Jean Amann.
    Attached Files

  • #2
    take a look here at how to deal with factor/categorical variables and create interactions of them:
    http://www.stata.com/help.cgi?fvvarlist

    if I understand your question correctly, in order to create country-time dummies, what you need to do in the regression(no need to actually create these vars, they are "virtual") you need to specify: i.country_pair#i.year
    Last edited by Ariel Karlinsky; 15 Jun 2015, 09:24.

    Comment


    • #3
      Hi Ariel, thank you for the attention with my post.

      I'll read the link you sent me, but there is no need to create the country-time effects, but only the ij effect, and the time effect. Should I consider another command on the regression?

      Thank you,
      Jean Amann.

      Comment


      • #4
        Ariel's advice still applies, but using i.ci#i.cj

        However, before using xtreg you need to xtset your data, which does AFAIK requires creating the country pairs (usually with -egen group-).

        By the way, I wrote a command that improves on what xtreg,fe does, and I've found most of the heavy users are trade researchers doing gravity regressions, so you may find it useful.

        The program is called "reghdfe" and it's downloadable from Stata on SSC. It allows you to do

        reghdfe y x1 x2 , absorb(ci#cj t)

        Best,
        S
        Last edited by Sergio Correia; 15 Jun 2015, 09:30.

        Comment


        • #5
          I'm not sure I understand then. you don't need interactions? if you need a time effect just enter i.year (the i. prefix is to let stata know this is a factor variable and not a continuous one). the same for ij: just enter i.country_pair . so for example your command would be:
          xtreg y x1 x2 x3 i.year i.country_pair

          Comment


          • #6
            Have a look at Chapter 3:
            https://www.wto.org/english/res_e/pu...unctad12_e.pdf

            Comment


            • #7
              Originally posted by Ariel Karlinsky View Post
              I'm not sure I understand then. you don't need interactions? if you need a time effect just enter i.year (the i. prefix is to let stata know this is a factor variable and not a continuous one). the same for ij: just enter i.country_pair . so for example your command would be:
              xtreg y x1 x2 x3 i.year i.country_pair
              Ariel, I specified the command xtreg y x1 x2 x3 i.id i.ano (where "id" is the group created to represent the country-pair and "ano" represents the time). Please note below the output from Stata (consider that I already entered set maxvar 32767 and set matsize 11000).

              matsize too small
              You have attempted to create a matrix with too many rows or columns or attempted to fit a model with
              too many variables. You need to increase matsize; it is currently 11000. Use set matsize; see help
              matsize.

              If you are using factor variables and included an interaction that has lots of missing cells, either
              increase matsize or set emptycells drop to reduce the required matrix size; see help set emptycells.

              If you are using factor variables, you might have accidentally treated a continuous variable as a
              categorical, resulting in lots of categories. Use the c. operator on such variables.



              What should I do now?

              Comment


              • #8
                is id the panel variable?

                Comment


                • #9
                  Originally posted by Ariel Karlinsky View Post
                  is id the panel variable?
                  Yes, it is!

                  Comment


                  • #10
                    xtreg y x1 x2 x3 i.ano, re
                    for random effects
                    xtreg y x1 x2 x3 i.ano, fe
                    for fixed effects.
                    This supposes that you have -xtset- your data:
                    xtset id ano

                    Comment


                    • #11
                      Originally posted by Eric de Souza View Post
                      xtreg y x1 x2 x3 i.ano, re
                      for random effects
                      xtreg y x1 x2 x3 i.ano, fe
                      for fixed effects.
                      This supposes that you have -xtset- your data:
                      xtset id ano

                      Hi Eric! Thanks for contributing!

                      The specification as proposed by you controls for the country-pair effects?

                      Comment


                      • #12
                        if id is the panel variable, then i.id is redundant in the xtreg command, as the xtreg command already does this. I recommend reading this throughly to better understand the difference between xtreg, regular reg, and whether or not including id as a dep var in the model: http://www.princeton.edu/~otorres/Panel101.pdf

                        Comment


                        • #13
                          Originally posted by Jean Amann View Post

                          The specification as proposed by you controls for the country-pair effects?
                          This is why you should read the reference posted just above by Ariel
                          You can control for country-pair effects in various ways: the random effects model , the fixed effects models, ..
                          The fixed effects model is "equivalent" to running a regression, -reg- , with dummy variables for each country-pair.
                          If you really need to delve into gravity models the reference I posted above is very useful.

                          Comment


                          • #14
                            Ariel and Eric, than you both for the help provided. I'll follow up on the reading.
                            All the best, Jean Amann.

                            Comment


                            • #15
                              Hi stata family
                              Iam Robert, a novice stata user. Am learning a lot from this forum
                              Is there anyone who can donate panel data regarding and fitting into gravitational model of trade so that i can try it at school and see if we are at the same page

                              Comment

                              Working...
                              X