Announcement

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

  • ppmlhdfe post-estimation

    Joao Santos Silva Tom Zylkin

    I am using trying to use two-stage estimation from Freeman et al. (2021), "Unlocking new methods to estimate country-specific trade costs and trade elasticties, Drexel working paper series, WP 2021-17".

    X_i,j,t = exp[m_i,t + (P_i,t)^1-sigma + (P_j,t)^ 1-sigma) ] * e_i,j,t (1)

    stage-1.
    Run the standard version of Gravity model

    X_i,j,t = exp(D_i,j + c_i,t + k_j,t ) e_i,j,t (2)

    where c_i,t and k_j,t are importer-time and exporter-time FE's to approximate (P_i,t)^1-sigma and (P_j,t)^ 1-sigma respectively.

    obtain \hat(c_i,t) and \hat(k_i,t) from (2), and then by additive property of PPML, we recover the estimates of IMR [(P_i,t)^1-sigma] and OMR [(P_j,t)^1-sigma] as:


    \hat [(P_i,t)^1-sigma] = Y_i,t / exp[\hat(c_i,t)] * E_0,t / Y_t (3)

    and

    \hat [(P_i,t)^1-sigma] = E_j,t / exp[\hat(k_j,t)] * 1/ E_0,t (4)

    E_0,t
    is GDP of country that has been selected as numaraire, Freeman et al (2021); Anderson et al (2018)

    stage-2. Substituting (P_i,t)^1-sigma and (P_j,t)^ 1-sigma by their estimates from (3) and (4) in (1), we estimate the following

    X_i,j,t = exp[m_i,t +\hat [(P_i,t)^1-sigma]+ \hat [(P_i,t)^1-sigma] ] * e_i,j,t

    Therefore, I ran the following code to estimate (2) as

    Code:
    cap egen exp = group(iso_e)
    cap egen imp = group(iso_i)
    Code:
    ppmlhdfe Trade_Value ln_distwces contig comlang_off colony comcol, absorb(exp#Year imp#Year) d cluster(distwces) nolog
    


    From here onwards, I do not know the code to estimate exp#Year (k_j,t) and imp#Year (c_i,t) FE's.
    After that, i need to estimate expressions in (3) and (4). Please help me with to find the estimated MRTs (P_i and P_j) in stage-1. I shall be very thankful.
    I am not a STATA geek and had tried a bit of coding, but i was not able to calculate IMR and OMR, Your help will be greatly appreciated.

    regards,
    ​​​​​​​
    (Ridwan)

  • #2
    Dear Carlo Lazzaro ; Clyde Schechter Jeff Wooldridge !
    If you have any suggestions to add, I will be highly thankful.
    I have been struggling to obtain the estimated values of importer-time (imp#Year or c_i,t) and exporter -time (exp#Year or k_j,t) fixed effects after I run the ppmlhdfe with absorb ( ) option. I need these estimated FE's to obtain the expression (3) and (4), so that i could be able to run the regression

    X_i,j,t = exp[m_i,t +\hat [(P_i,t)^1-sigma]+ \hat [(P_i,t)^1-sigma] ] * e_i,j,t (5)

    Thanks and regards,
    (Ridwan)
    Last edited by Ridwan Sheikh; 19 Nov 2022, 11:06.

    Comment


    • #3
      Dear Ridwan Sheikh,

      I suggest you contact the authors of the paper.

      Best wishes,

      Joao

      Comment


      • #4
        Thanks Joao Santos Silva ,
        I contacted one of the authors of the paper, they did not share the codes as how to obtain estimates of exp#Year and imp#Year fixed effects.
        I am unable to proceed further to generate an expression for (3) and (4).

        (Ridwan)

        Comment


        • #5
          Dear Joao Santos Silva
          I have been able to figure-out the estimates of exp#Year and imp#Year FE's, thanks to Tom Zylkin for sharing a codes with me.

          However, if we estimate X_i,j,t = exp(D_i,j + c_i,t + k_j,t ) e_i,j,t , the full set of exporter-time (k_j,t) and importer-time (c_i,t) FE's are not of full rank, Fally, (2015). the restrictions (dropping benchmark country FE: c_o,t =0 for i=0 and estimating the model without constant) has to be imposed. How can i do that. I ran the following
          Code:
          ppmlhdfe Y D_ij, a(c_it = imp#year k_jt = exp#year, savefe) d cluster(pair)
          I need E_0,t which is the GDP of country whose importer-time FE's are dropped.

          Please help, i shall be very thankful
          Last edited by Ridwan Sheikh; 21 Nov 2022, 08:51.

          Comment


          • #6
            Hi Ridwan,
            I already responded to your most recent question on Twitter: https://twitter.com/TomZylkin/status...25230467059713
            Regards,
            Tom

            Comment


            • #7
              Dear Ridwan Sheikh,

              Please see Tom's reply.

              Best wishes,

              Joao
              Last edited by Joao Santos Silva; 21 Nov 2022, 10:57.

              Comment


              • #8
                Thanks Joao Santos Silva .
                I am very thankful to Tom Zylkin for sharing ppmlhdfe and normalization.do, it was a great learning resource, that I followed in my case.
                I want to share few points about my data and results that i got.
                1) I have sectoral level data on bilateral trade flows of 88 developing countries from 28 HIC's across 1976-2019 period. In my data internal trade flows are not included (no X_ii)
                2) I did not include pair-FE's, in the first-stage ppml, because it will absorb the D_ij covariates. Therefore, as mentioned in ppmlhdfe and normalization.do, i did not absorb the constant (nuisance here) in pair-Fe's
                I ran the following codes, where i-denotes exporter and j-denotes importer:

                First stage (obtain estimated values of importer-time and exporter-time FE's)

                Code:
                use Data, clear
                bysort iso_i Year: egen y_it = sum(Trade_Value)  
                bysort iso_j Year: egen y_jt = sum(Trade_Value) 
                cap egen exp = group(iso_i)
                cap egen imp = group(iso_j)
                I then run the following ppmlhdfe code

                Code:
                ppmlhdfe Y D_ij, a(s_it = exp#Year m_jt = imp#Year, savefe) d cluster(distwces)
                I then try Normalizing Argentina (ARG) IMR to 1 i.e., set m_jt = log(EXP_ARGt).
                ARG is iso_j = 2
                Code:
                sort Year iso_j iso_i
                by Year: egen EXP_ARGt = sum(Trade_Value*(iso_j==2))   
                by Year: egen m_ARGt   = max(m_jt*(iso_j==2))     
                 
                gen adjustment_factor = log(EXP_ARGt) - m_ARGt
                replace m_jt = m_jt + adjustment_factor
                replace s_it = s_it - adjustment_factor
                Second stage (generate Importer multilateral resistance IMT_jt).
                I run the following codes to generate IMT_jt
                Code:
                gen M_jt = exp(m_jt)
                gen IMR_jt = y_it / M_jt
                Is the ARG IMR always equal to 1? We can check it as:

                Code:
                sum IMR_jt if iso_j==2
                The results i get by summarizing IMR_jt for ARG (iso_j==2) are

                Variable | Obs Mean Std. Dev. Min Max
                ------------+--------------------------------------------------------------------------------
                IMR_jt | 21,240 8.527052 16.12827 .0024593 168.4213

                Therefore for Argentina IMR_jt is not closer to 1 (mean of 8.52).

                I want to ask why that is a case.?

                Do i need to absorb constant, how to do that if there are no pair-FE's

                Do i need to include exp#industry#year FE's; imp#industry#year FE's, instead of exp#year and imp#year.

                Please help, i shall be very thankful. I appreciate the help you already provided in my case.

                sorry for the long query

                regards,
                (Ridwan)




                Comment


                • #9
                  Sorry Tom Zylkin , i was doing little error while creating IMR_j,t , the correct substitution is not y_it as i was initially writing in the code, rather it is y_ jt

                  Code:
                  gen M_jt = exp(m_jt)
                  gen IMR_jt = y_jt / M_jt
                  sum IMR_jt if iso_j==2
                  The mean of IMR_jt for ARG(iso_j==2) now is (1.9602).

                  Thanks,
                  (Ridwan)
                  Last edited by Ridwan Sheikh; 22 Nov 2022, 11:57.

                  Comment


                  • #10
                    Sorry, Ridwan Sheikh, I am not sufficiently familiar with this method to be able to help.

                    Best of luck,

                    Joao

                    Comment


                    • #11
                      Thanks Joao Santos Silva, my interaction with Tom Zylkin on Twitter has been very helpful.I am reposting the twitter-link here, so that it benefits someone visiting to the forum in future and having similar questions about ppmlhdfe, postestimation.

                      https://twitter.com/TomZylkin/status...25230467059713

                      thank you all
                      (Ridwan)

                      Comment


                      • #12
                        Thanks Joao Santos Silva, my interaction with Tom Zylkin on Twitter has been very helpful.I am reposting the twitter-link here, so that it benefits someone visiting to the forum in future and having similar questions about ppmlhdfe, postestimation.

                        https://twitter.com/TomZylkin/status...25230467059713

                        thank you all
                        (Ridwan)
                        Last edited by Ridwan Sheikh; 24 Nov 2022, 03:10.

                        Comment

                        Working...
                        X