Announcement

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

  • Gravity regression: different results between hdfereg and xtreg

    Hey I want to estimate a rather big gravity regression, I first tried it with xtreg and importer-year and exporter-year fixed effects. but it takes quite some time..
    So I also tried it with reghdfe, but the resulting coefficients are different now..

    I also tried it with some example data and there I have the same problem, so maybe I am just setting up the regression in the wrong way.

    Here is what it looks like with example data:

    Trying with reghdfe:

    Code:
    clear all
    set more off
    
    * load example data
    
    use http://fmwww.bc.edu/RePEc/bocode/e/EXAMPLE_TRADE_FTA_DATA if category=="TOTAL", clear
    
    gen ln_trade = log(trade)
    
    cap egen imp=group(isoimp)
    cap egen exp=group(isoexp)
    
    * using reghdfe
    
    reghdfe ln_trade fta ln_distw contig colony, a(imp#year exp#year) cluster(imp#exp)

    However when I try to run it with xtreg and imp-year and exp-year dummies:
    Code:
    * using xtreg
    
    * Country pairs
    egen pairid = group(isoimp isoexp)
    * country pair dummies (sometimes also included in panel gravity models)
    * tab pairid, gen(pair_)
    
    * to identify the dimension of the panel with need the country pair and time
    
    xtset pairid year
    
    * regression wit xtreg (same result as below using generated dummies)
    
    * xtreg ln_trade fta ln_distw contig colony imp#year exp#year, robust
    
    * just to check if we get different results with dummies
    cap egen imp_year = group(isoimp year)
    cap egen exp_year = group(isoexp year)
    cap tab(imp_year), gen (imp_year_)
    cap tab(exp_year), gen (exp_year_)
    
    * regression with xtreg using dummies
    xtreg ln_trade fta ln_distw contig colony imp_year_* exp_year_*, robust
    then the coefficient for fta is much lower.


    Really thankful for any comments about what went wrong here..

    (and sorry for the wrong title, should be reghdfe not hdfereg)

    Best regards
    Last edited by Flora Oblasser; 15 Jun 2023, 03:18.

  • #2
    Dear Flora Oblasser,

    If I am not mistaken, xtreg by default estimates a RE regression, whereas reghdfe estimates a pooled regression; to get similar results, you need reg instead of xtreg.

    Anyway, you should not log the dependent variable and use ppmlhdfe instead.

    Best wishes,

    Joao

    Comment


    • #3
      Thanks for your reply Joao Santos Silva ! You are perfectly correct, that using reg instead of xtreg delivers the same result as reghdfe. Are you maybe aware of any option to include RE in reghdfe. If I am not mistaken its about how to deal with the country pairs effects right? Generally, is not including country-pair (imp#exp) fixed effects ok if you include some bilateral control variables like geographical distance, etc? I read some papers and they often don't include country-pair fixed effects, sometimes only as robustness checks.
      Also in my case the coefficients just get insignificant when including country-pair fixed effects..

      Anyway back to the code..

      I also used ppmlhdfe now:
      Code:
       ppmlhdfe trade fta ln_distw contig colony, a(imp#year exp#year) cluster(imp#exp)
      I know that trade is not in logarithm now, but shouldn't be the coefficient about the same as in the case of using reghdfe like before:

      Code:
       reghdfe ln_trade fta ln_distw contig colony, a(imp#year exp#year) cluster(imp#exp)
      The coefficient for trade is nearly twice as high when using ppmlhdfe.

      Thanks again!
      Last edited by Flora Oblasser; 15 Jun 2023, 05:59.

      Comment


      • #4
        Dear Flora Oblasser,

        You should not use RE in this context as the estimator is not robust. Using trade in logs will make the estimator inconsistent for the parameters of interest, so it is not surprising that you get different results with PPML.

        Best wishes,

        Joao

        Comment


        • #5
          Thanks Joao Santos Silva !, Sorry for taking your time, but how do you assess the use of shares as dependent variables, eg. the share of a recipient country in a source country's total exports (or FDI assets). As independent variable of interest we would have a bilateral time varying variable, like fta or geopolitical distance.

          Another thing which is puzzling me is the use of FDI flows in gravity models, since they can be negative.. The IMF in this years WEO uses a gravity model to study the effects of geopolitical distance on FDI flows and uses your PPML. However, it is really not clear to me what they are doing with the negative flows, and I cannot find any explanation in the main text https://www.imf.org/en/Publications/...ook-april-2023 or in the online apendix https://rb.gy/ix2k9 of the chapter 4. Sorry, I am not expecting you to read the WEO chapters now (: but I was just interested if you have any idea of how they dealt with using PPML and having negative FDI flows..

          Best regards,
          Flora
          Last edited by Flora Oblasser; 15 Jun 2023, 07:17.

          Comment


          • #6
            Dear Flora Oblasser,

            I do not have much experience with the use of shares, but I know some people like to do that. Personally, I would avoid it unless the goal is really to model the shares.

            PPML is valid even if some observations are negative; all the is needed is that the conditional mean has the exponential form (and hence is always positive). However, few Stata commands work when there are negative observations. Can you ask the authors of the chapter what they did?

            Best wishes,

            Joao

            Comment


            • #7
              Dear Joao Santos Silva once again thank you for your very helpful responses! Just to be clear you mean that they could have used other packages than ppmlhdfe, since when applying ppmlhdfe to the data above and changing one trade observation to negative, the regression does not work:
              Code:
              . replace trade = -10747.56510925 in 1
              (1 real change made)
              . ppmlhdfe trade fta ln_distw contig colony, a(imp#year exp#year) cluster(imp#exp)
              trade must be greater than or equal to zero
              I know I am not telling you something new here.. (: But yes I will ask the authors what they did exactly.. I was just wondering about it, since I also want to estimate a gravity model with capital flows, which include negative flows..

              Thank you so much!

              Best regards,
              Flora

              Comment


              • #8
                Dear Flora Oblasser,

                Yes, they could have used a gmm-based command. I have written one such command (see an example here), but it will struggle with many fixed effects.

                Best wishes,

                Joao

                Comment


                • #9
                  Dear Joao Santos Silva thanks a lot for the helpful comment! Just to complement my remark about the WEO, I overlooked that they are using greenfield FDI flows, which if I am not missing something simply can not be negative.

                  But as I want to study regular FDI flows, I`ll have a look into your suggested gmm-based commands. Thank you very much!

                  Best regards,
                  Flora

                  Comment

                  Working...
                  X