Announcement

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

  • Hello everybody,

    I am estimating effects of WTO accession on Vietnam's trade flows bu using the gravity model approach. The data consists of Vietnam's exports (EX) and imports (IM) (separately) with 71 partner countries from 1990 to 2015 .

    I am estimating PPML so my dependent variables are in levels and rescaled by 1000 i.e EX = EX_ijt/1000 and IM=IM_ijt/1000. My independent variables are: distance, real of Exchange rate (RER), common border, colony, comcol, smctry, RTA, VNin( dummy=1 if t=2007 to 2015) and Partin( dummy=1 if Vietnam's partner country is GATT/WTO in year t).

    I have declared my data to a panel data by command: xtset Coutry1 Year and my data is strongly balanced.

    * (1) For estimating PPML without fixed effects (FE), I use the following command:

    ppml EX lnGDP_it lnGDP_jt lnDist lnRER_ijt contig colony comcol smctry RTA_ijt Vnin_jt Partin_jt, cluster(distcap)
    ppml IM lnGDP_it lnGDP_jt lnDist lnRER_ijt contig colony comcol smctry RTA_ijt Vnin_jt Partin_jt, cluster(distcap)


    * (2) For estimating PPML With year FE I use:

    xtpqml EX lnGDP_it lnGDP_jt lnDist lnRER_ijt contig colony comcol smctry RTA_ijt Vnin_jt Partin_jt Year_*, fe cluster(distcap)
    xtpqml IM lnGDP_it lnGDP_jt lnDist lnRER_ijt contig colony comcol smctry RTA_ijt Vnin_jt Partin_jt Year_*, fe cluster(distcap)

    * (3) For estimating PPML With country-pair FE I use:

    xtpqml EX lnGDP_it lnGDP_jt lnDist lnRER_ijt contig colony comcol smctry RTA_ijt Vnin_jt Partin_jt pair_* , fe cluster(distcap)
    xtpqml IM lnGDP_it lnGDP_jt lnDist lnRER_ijt contig colony comcol smctry RTA_ijt Vnin_jt Partin_jt pair_* , fe cluster(distcap)

    *(4) For estimating PPML With both country-pair FE and year FE I use:

    xtpqml EX lnGDP_it lnGDP_jt lnDist lnRER_ijt contig colony comcol smctry RTA_ijt Vnin_jt Partin_jt pair_* Year_* , fe cluster(distcap)
    xtpqml IM lnGDP_it lnGDP_jt lnDist lnRER_ijt contig colony comcol smctry RTA_ijt Vnin_jt Partin_jt pair_* Year_*, fe cluster(distcap)


    I have these following problems:

    1) When I estimate using (2) With year FE, the time-invariant variables drop as they are supposed to, but lnGDP_it also drops which is surprsing to me . Is it correct?

    2) I have managed to estimate EX both w/o, With year FE, With country-pair FE and also With country-pair + year FE (all 4) and IM for PPML w/o FE and With year FE , but when I estimate PPML With country-pair I get an r(200) saying that there are no observations. To fix this error, some suggest that I have to change from the variables from string to numeric and I am pretty sure this is not my case. Some suggest that this error comes because I have missing values and I do have many missing values, but how can I fix it without changing them to, for instance, 1?

    I am really sorry for such a long post but I hope you guys understand what I have trouble With and please help me to fix them! I have to hand in my Master thesis in about 2 weeks

    Comment


    • Dear Anh,

      1) Yes, that is right: Vietnam's GDP is collinear with the year dummies.

      2) Notice that in (2) to (4) you are using xtpqml with FE and therefore, by default, all these regressions include country-pair fixed effects. So, the results in (2) and (4) should be the same and in (3) the pair dummies should be dropped. If this is not what you find, I guess you have a problem with the way your data is arranged.

      Best wishes,

      Joao

      Comment


      • Hello,

        I am currently estimating the effects of FTA and bilateral exchange rate on UK exports using the gravity model. I am using panel data with fixed effects and this is what I have done so far:

        *generate a pair id for the countries*
        egen pairid= group(importer exporter)

        * set data as panel and provide the cross sectional and time dimension*

        xtset pairid year

        *generate log variables*

        generate lnexports = log(exports)
        generate lngdp_exporter = log(gdp_exporter)
        generate lngdp_importer = log(gdp_importer)
        generate lndistw = log(distw)
        generate lnrer = log(rer)


        *regress with fixed effects

        xtreg lnexports comlang_off lndistw lngdp_exporter lngdp_importer fta_wto colony lnrer, fe

        *regress with fixed effects and importer and exporter dummy variables

        tab (year), gen (year_)
        egen impyear = group(importer year)
        egen expyear = group(exporter year)
        tab (impyear), gen (impyear__)
        tab (expyear), gen (expyear__)


        xtreg lnexports comlang_off lndistw lngdp_exporter lngdp_importer fta_wto colony lnrer impyear_* expyear_* year_*, fe robust

        When I run the last line, the dummy variables for importer year, exporter year are omitted due to collinearity.

        I am really confused about how fixed effects works, do I need to add dummies for country time effects "importer year and exporter year" or for time effects "year", or is it all done for me when I use the commend "fe"?

        Comment


        • Dear Joao,

          Thank you so much for your reply! You are totally right about the commands and I have changed them as you suggested. Unfortunately, I still have a problem with IM when I estimate it with country-pair dummies. This is the command I use now:

          xtpqml IM lnGDP_it lnGDP_jt lnDist lnRER_ijt contig colony comcol smctry RTA_ijt Vnin_jt Partin_jt , fe cluster(distcap)

          I still get the r(2000) error. I'm sorry but I do not get what you mean about the arrangement of my data

          Best wishes,

          Anh Thi

          Comment


          • Originally posted by stephen balla View Post
            Hello,

            I am currently estimating the effects of FTA and bilateral exchange rate on UK exports using the gravity model. I am using panel data with fixed effects and this is what I have done so far:

            *generate a pair id for the countries*
            egen pairid= group(importer exporter)

            * set data as panel and provide the cross sectional and time dimension*

            xtset pairid year

            *generate log variables*

            generate lnexports = log(exports)
            generate lngdp_exporter = log(gdp_exporter)
            generate lngdp_importer = log(gdp_importer)
            generate lndistw = log(distw)
            generate lnrer = log(rer)


            *regress with fixed effects

            xtreg lnexports comlang_off lndistw lngdp_exporter lngdp_importer fta_wto colony lnrer, fe

            *regress with fixed effects and importer and exporter dummy variables

            tab (year), gen (year_)
            egen impyear = group(importer year)
            egen expyear = group(exporter year)
            tab (impyear), gen (impyear__)
            tab (expyear), gen (expyear__)


            xtreg lnexports comlang_off lndistw lngdp_exporter lngdp_importer fta_wto colony lnrer impyear_* expyear_* year_*, fe robust

            When I run the last line, the dummy variables for importer year, exporter year are omitted due to collinearity.

            I am really confused about how fixed effects works, do I need to add dummies for country time effects "importer year and exporter year" or for time effects "year", or is it all done for me when I use the commend "fe"?
            From what I understand, the Fixed effects model does not estimate the variables that do not change over time such as the dummy variables for common Colony etc.. and the specific fixed effects. when using the fixed effects model- one assumes that these fixed effects are correlated with the independent variables and we control them by not including them when estimating the model. If these fixed effects/dummy variables are included, they will be dropped/omitted from the model as your result showed- due to collinearity.

            Comment


            • Originally posted by Peniana Patrick View Post

              From what I understand, the Fixed effects model does not estimate the variables that do not change over time such as the dummy variables for common Colony etc.. and the specific fixed effects. when using the fixed effects model- one assumes that these fixed effects are correlated with the independent variables and we control them by not including them when estimating the model. If these fixed effects/dummy variables are included, they will be dropped/omitted from the model as your result showed- due to collinearity.
              So what you're saying is the importer and exporter specific fixed effects will be omitted due to them being correlated to the independent variables when estimating with fixed effects?

              Also, how can I add importer, exporter, time and country pair effects then?
              Last edited by stephen balla; 21 Apr 2017, 09:15.

              Comment


              • Dear Joao,

                I am MA student at Central European University writing my thesis on Gravity model estimation for tourism flows to New Zealand. The data is of an unbalanced panel type: I have arrivals from 206 countries to New Zealand from 1990 to 2016 year.
                The question I have is not related to Stata directly, but i really hope that you may give me some idea on my results. I estimate the gravity equation in R using two types of techniques - a linear one (estimated by GLM):
                Code:
                 glm(A_t ~ lnGDP + lnGDP_NZ + lnW_DIST + lnPOP + S_LANG + dEX_RATE +
                           lnACCOM + LOTR1 + LOTR2 + LOTR3 + WRC, data=panel, family=quasipoisson(link="log"))
                and the multiplicative one (with the usage of PPML function):
                Code:
                 PPML("A_t", dist = "W_DIST", x = c("lnGDP","lnGDP_NZ", "lnPOP", "S_LANG", "dEX_RATE",
                                                    "lnACCOM", "LOTR1", "LOTR2", "LOTR3", "WRC"),
                                                     vce_robust = TRUE, data = panel)
                The PPML function in R is written such that it estimates the Gravity equation in multiplicative form in the same way that your function for Stata does (proposed in Santos-Silva, J. M. C. and Tenreyro, S. (2006)).

                1) What I am interested in is that both models give identical results (please, see the attachment. LOTR1-LOTR3, WRC variables are just dummies for crucial for NZ tourism events) - is it the feature of Poisson Pseudo-Maximum Likelihood estimator, i.e. that it doesnt care about the linear/multiplicative form of the equations? (I mean, do you find it suspicious that linear and multiplicative form of equation give identical results while estimating with PPML?)

                2) Do you think it makes sense to include New Zealand variables such as its GDP, number of accomodation places, etc. into regression? These variables are the same for all countries so there are no muh variation in them to give me significant estimations. Moreover, it influences all countries simultaneously, hence almost gives no value added to regression.

                3) Do you think i have biased results now because I didnt include FE for departing countries? Should i include it? It is the same as country-pairs dummies in usual trade models, but since i have only one destination I can include country dummies.

                I understand that its Stata forum and i am asking question related to R, but I hope you can give me some hints on my estimation model!

                Best regards,
                Nikita Malykhin
                Attached Files

                Comment


                • Dear Nikita,

                  1) The two functions you are using do exactly the same thing. You say that the first approach is a linear model but that is not the case because you specify a log link. In Stata you can also estimate the model by using the -glm- and the -poisson- commands. The -ppml- command in stata, however, is different in that it check for the existence of the estimates; I am not aware of an R function doing the same.

                  2) This is really up to you, but I can imagine situations where including those variables would be interesting.

                  3) Again, I would say that this is up to you; only you know what you are trying to do.

                  Best wishes,

                  Joao

                  Comment


                  • Dear Joao, Thank you for reply!

                    Oh... There is no any hidden mystery at all, I was using similar approaches... I guess I had to look deeper into R-help first
                    I will think of respecification of my model then after I look more carefully through the literature.

                    Thanks once again! You make great job while answering to all these questions regarding gravity model by yourself. This forum has become a delicious source of information for researchers applying these types of models.

                    Best,
                    Nikita

                    Comment


                    • Hi Joao,

                      I am a MSc Student, writing a dissertation on the effect of EU membership on Swedish Trade; in regards to Trade Creation/Diversion.
                      I am a novice with Stata so I am unsure of my coding.

                      I am developing a PPML model in Stata, with Sweden as the only exporter, and up to 200 country partners (Importers).

                      I have used the following command which gave me reasonable results. (I am also running regressions using OLS as a comparative tool).

                      ppml exports lgdp_swe lgdp_part ldist comlang border bothin onein year_*

                      As I have included the dummy year_* - which contains year dummies from 1975-2015 - does this mean my model includes year FE?

                      I also attempted to create a country dummy, and ran something like:

                      ppml exports lgdp_swe lgdp_part ldist comlang border bothin onein year_* importer_*

                      But my distance variable does not drop out like it should (since it is time constant), am I doing something obviously incorrect?

                      As I am using the PPML command in Stata, do I need to include anything at the end of my code (Eg. , fe robust cluster(dist))?

                      I can happily send you my Stata database if this helps.

                      Many thanks,

                      Michael

                      Comment


                      • Dear Michael,

                        Yes, the year dummies are often called year FE. I believe that the coefficient on lgdp_swe is not identified when you include the year dummies, right?

                        When you include the country dummies, you should not be able to identify ldist, comlang, border (and maybe others). Stata is probably dropping some of the fixed effects and keeping those variables. I suggest you include the fixed effects before the other regressors; Stata should drop a different set of variables in that case.

                        Indeed, using -ppml- in this context you should cluster by country.

                        Best wishes,

                        Joao

                        Comment


                        • Dear Sir,
                          I am analyzing the effects of trade creation and diversion of ASEAN India FTA using the gravity model. The sample includes 80 countries with 110,160 observations for 17 years. Following the latest recommendations I generated country year and pair fixed effects and estimated the model using ppml. However, I am facing a number of problems:

                          1) How to check and remove singletons in the data? I used the following commands to identify and remove singletons, but not sure if I am correct (posted in this forum).
                          su exp_time_fe* imp_time_fe* pair_fes* if e(sample)
                          bysort pair_id : egen OK = count(trade)
                          replace OK = OK >1
                          egen group = group(pair_id) if OK
                          su group, meanonly

                          where, trade is dependent variable, and the fixed effects are country time and pair fixed effects. Am I following the correct procedure?
                          When I run simple regression the observations are reduced to 26314. So singleton would be 1/26314 or 1/110160 ?

                          2) While estimating the equation using ppml model with pair fixed effects most of these fixed effects are dropped due to collinearity (around 52000) and some for the estimator to exist.

                          The following command was used to generate pair fixed effects:

                          sum pair_id
                          replace pair_id=pair_id+100000 if exporter==importer
                          qui tab pair_id, gen(pair_fes)

                          and the model being estimated is as follows:

                          ppml trade ln_GDP_i ln_GDP_j ln_GDPPC_i ln_GDPPC_j LANDLOCKED_i LANDLOCKED_j
                          > TC_ij TD_iin_jout TD_iout_jin pair_fes*, cluster(pair_id)

                          Is there something wrong with the generation of fixed effects? Why almost half of the observations are being dropped ? Will this give unreliable estimates?

                          A general query .

                          3) Are there any tests which should be done to check the anomalies in the data prior to gravity estimation?

                          Thank you very much.

                          Best regards
                          Richa

                          Comment


                          • Dear Richa,

                            To be honest, I am not familiar enough with Stata to be able to comment on your code. I just generate the dummies with the -xi- command (not the -xi- prefix) and include them in -ppml-. Notice, however, that estimating a model with all the fixed effects that including may be asking too much form the data. I suggest that you start with a simpler model and increase its complexity step by step.

                            Best wishes,

                            Joao

                            Comment


                            • Dear Sir Joao Santos Silva
                              Thank you so much for your response. I did start with simpler models for which I was able to get results. But I am facing these problems while estimating the model only with pair fixed effects. Also the model is taking way too long to run and then dropping most of these fixed effects.
                              1) Do you think singletons could cause a major problem? And if I am able to remove them correctly, then my estimation would give reliable results?
                              2)Also can there be a difference in results while using the commands ppml or ppml_panel_sg ? As while with ppml I obtain results with importer and exporter fixed effects, using the new command drops the log_gdp and other time varying country specific variables from the model giving different results. Could you or Tom Zylkin please suggest where am I going wrong and how to correct my mistake?
                              further the ppml_panel_sg command is not running with pair fixed effects.

                              I would greatly appreciate some help here.

                              Thank you very much

                              Best regards
                              Richa

                              Comment


                              • Richa,

                                Dropping fixed effects is unlikely to be related to singletons. The likely cause of that is that they correspond to pairs with no variation of the dependent variable. Estimating with -xtpoisson- with the FE option should that take too long, but it all depends on your computer.

                                As for your second question, ppml and ppml_panel_sg should give you the same results if you use the same fixed effects on both. Make sure you understand what the commands are doing, especially what fixed effects ppml_panel_sg includes.

                                Best wishes,

                                Joao

                                Comment

                                Working...
                                X