Announcement

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

  • Gravity model with GEPPML: General equilibrium analysis with PPML

    Dear All,

    I am applying the method of General equilibrium analysis with Poisson pseudo-maximum-likelihood (PPML) by Anderson et al. (2018). I have panel data for nine years from 2006-2016, with ten exporting countries and 154 importing countries for each exporter (total observations 11,781). The dependent variable is bilateral export. I have six independent variables. All variables are continuous. I have also included importer and exporter fixed effects.

    The problem I face is that when I enter the following command in STATA:

    ppml logexport transshipment geometricavg shipsize competition loggdp_rest loggdp_ten Exporter_fixed* Importer_fixed1-Importer_fixed '=NoC'-1',iter(30) noconst


    I got the message "variable Importer_fixed not found"

    Could you please guide me on how to fix this problem?

    I hope Joao Santos Silva can help me to solve this issue.


    Reference

    Anderson, J. E., Larch, M., and Yotov, Y. V. (2018). GEPPML: general equilibrium analysis with PPML, The World Economy, 41: 2750–2782.

  • #2
    Dear NAIMA SAEED,

    You probably have a typo in the name of your last variable. Anyway, I suggest that you use ppmlhdfe instead of ppml.

    Best wishes,

    Joao

    Comment


    • #3
      Dear Joao Santos Silva thank you very much for a quick reply. I use the term ppmlhdfe but got the same error message, please see the screenshot. In the screenshot you can also see exporter and importer fixed effects. The commands which I have used contains * after the variables "Exporter_fixed" and because of this package recognizes to include all ten exporters' fixed effect variables. But after the variable Importer_fixed, * is missing which is why I think I got the error message. But the problem is that this is how it is mentioned in Anderson et al (2018) and also in another document "An Advanced Guide to Trade Policy Analysis: The Structural Gravity Model", Online Revised Version, by Yotov et al. So I am not sure how to fix this problem.
      Attached Files

      Comment


      • #4
        You are just probably copying and pasting code without understanding it.

        Code:
        '=NoC'-1'
        most likely refers to a local containing the number of countries. The leftward character in a local is a grave accent (`). So that if I define

        Code:
        local NoC 121
        di `NoC'
        I get

        Code:
        . local NoC 121
        
        .
        . di `NoC'
        121
        `

        So what is probably wanted is

        Code:
        Importer_fixed`=`Noc'-1'
        without a space between _fixed and the number.

        Code:
        di "Importer_fixed`=`NoC'-1'"
        Res.:

        Code:
        . di "Importer_fixed`=`NoC'-1'"
        Importer_fixed120

        Comment


        • #5
          Dear Joao Santos Silva and Andrew Musau many thanks for your reply. There was a typo in my command which I have corrected now and it works.

          Comment


          • #6
            Dear Naima,
            There are still a few issues here that it looks like you should fix:
            - with ppml, the dependent variable should be in levels, not logs ("exports", not "logexports")
            - you should use the "absorb" option with ppmlhdfe to implement the FEs, as in:

            HTML Code:
            ppmlhdfe exports transshipment ... , absorb(EXPORTER_FE IMPORTER_FE)
            This will be much faster

            - it's not clear to me that the country-specific variables are identifiable in the presence of exporter and importer FEs.
            - no need to use "noconst". I don't think this option actually does anything.

            Hope this is helpful!

            Regards,
            Tom

            Comment


            • #7
              Dear Tom Zylkin many thanks for the helpful comments. I have fixed all the issues mentioned above.

              Comment


              • #8
                Dear @Joao Santos Silva

                I am also applying the method of General equilibrium analysis with Poisson pseudo-maximum-likelihood (PPML) by Anderson et al. (2018). One of my questions is that after I use ppml to estimate the tradehat, whether the tradehat is a predicted value or a fitted value. The actual data processed in this paper is cross-sectional data, not panel data. I am a little confused about the conversion of cross-sectional data to panel data, and I am not sure how to change it. It first used panel data to complete the trade cost item, but only kept the base year when doing counterfactual analysis. My counterfactual analysis is a parallel result if I keep the panel data. For example, in 2016, I got the tradehat of 2016, and I got the tradehat of 2017 in 2017. But how to combine the two? Is the tradehat average? It seems to be incorrect. I'm sorry, I don't know much about this turn. If I can, I hope to get your advice.


                Best wishes,

                Zibing Zhou

                Comment


                • #9
                  Dear Zibing Zhou,

                  I am afraid I am not familiar with that command.

                  Best wishes,

                  Joao

                  Comment


                  • #10
                    Dear @Joao Santos Silva

                    I still thank you for your reply.

                    Best wishes,

                    Zhou

                    Comment


                    • #11
                      Originally posted by Zibing Zhou View Post
                      Dear @Joao Santos Silva

                      I am also applying the method of General equilibrium analysis with Poisson pseudo-maximum-likelihood (PPML) by Anderson et al. (2018). One of my questions is that after I use ppml to estimate the tradehat, whether the tradehat is a predicted value or a fitted value. The actual data processed in this paper is cross-sectional data, not panel data. I am a little confused about the conversion of cross-sectional data to panel data, and I am not sure how to change it. It first used panel data to complete the trade cost item, but only kept the base year when doing counterfactual analysis. My counterfactual analysis is a parallel result if I keep the panel data. For example, in 2016, I got the tradehat of 2016, and I got the tradehat of 2017 in 2017. But how to combine the two? Is the tradehat average? It seems to be incorrect. I'm sorry, I don't know much about this turn. If I can, I hope to get your advice.


                      Best wishes,

                      Zibing Zhou
                      Dear Zibing,

                      If you have having trouble implementing that procedure, there is a Stata command I wrote that, while it does not apply the same method, will still let you achieve the result of computing the same types of results. The command is called "ge_gravity", which you can install using ssc install ge_gravity. There is an interactive .do file you can follow to get a sense of how it works. I believe working through the examples in the .do file and help file will answer your questions about use with panel data. I'm not sure what you mean by averaging 2 years though or why you would want to do that. The model you are trying to use is a static model, so typically one would pick a single time period and try to construct a counterfactual version of that one period where the policy is different.

                      Hope this helps,
                      Tom

                      Comment


                      • #12
                        Dear @Tom Zylkin

                        Thank you for your reply, but I think I may still have some questions about the panel data, not the code change, but the principle.

                        Code:
                        ppml trade EXPORTER_TIME_FE* IMPORTER_TIME_FE1-IMPORTER_TIME_FE$NT_yr , iter(30) noconst offset(ln_tij_bln)
                                           predict tradehat_BLN, mu
                        (1)I have a question. Is the predicted value or fitted value calculated by the predict command here? If it is a fitted value, which is different from the actual value, I am a little confused about how to explain this? Is it because of the value we calculated under an ideal condition? However, due to various situations in reality, there will be a little deviation from the actual value?
                        (2)The second problem is that this calculation has a corresponding value every year, and the results obtained by counterfactual analysis are also the same. When I calculate the rate of change, should I compare the counterfactual value of the most recent year with the benchmark value? Or should I compare the counterfactual value of multiple years with the benchmark value and then take the average? I think this is why I don’t understand The key to how to convert section data into panel data. I hope to get your help.

                        If possible, I hope you can help look at the third question.

                        Code:
                         * Re-specify the factory-gate prices under the baseline and conditional scenarios                
                                    generate exp_pi_0 = exp_pi_BLN
                                    generate tempexp_pi_ii_0 = exp_pi_0 if exporter == importer
                                        bysort importer: egen exp_pi_j_0 = mean(tempexp_pi_ii_0)
                                    generate exp_pi_1 = exp_pi_CDL
                                    generate tempexp_pi_ii_1 = exp_pi_1 if exporter == importer
                                        bysort importer: egen exp_pi_j_1 = mean(tempexp_pi_ii_1)
                                        drop tempexp_pi_ii_*
                                    generate exp_chi_0 = exp_chi_BLN    
                                    generate exp_chi_1 = exp_chi_CDL    
                                    
                                    * Compute the first order change in factory-gate prices    in the 
                                    * baseline and conditional scenarios
                                    generate change_pricei_0 = 0                
                                    generate change_pricei_1 = ((exp_pi_1 / exp_pi_0) / (E_R_1 / E_R_0))^(1/(1-sigma))
                                    generate change_pricej_1 = ((exp_pi_j_1 / exp_pi_j_0) / (E_R_1 / E_R_0))^(1/(1-sigma))
                                
                                    * Re-specify the outward and inward multilateral resistances in the
                                    * baseline and conditional scenarios
                                    generate OMR_FULL_0 = Y_0 * E_R_0 / exp_pi_0
                                    generate IMR_FULL_0 = E_0 / (exp_chi_0 * E_R_0)        
                                    generate IMR_FULL_1 = E_1 / (exp_chi_1 * E_R_1)
                                    generate OMR_FULL_1 = Y_1 * E_R_1 / exp_pi_1
                                    
                                * Compute initial change in outward and multilateral resitances, which 
                                * are set to zero        
                                    generate change_IMR_FULL_1 = exp(0)        
                                    generate change_OMR_FULL_1 = exp(0)
                                
                        
                            ****************************************************************************
                            ******************** Start of the Iterative Procedure  *********************
                            
                            * Set the criteria of convergence, namely that either the standard errors or
                            * maximum of the difference between two iterations of the factory-gate 
                            * prices are smaller than 0.01, where s is the number of iterations    
                                local s = 3    
                                local sd_dif_change_pi = 1
                                local max_dif_change_pi = 1
                            while (`sd_dif_change_pi' > 0.01) | (`max_dif_change_pi' > 0.01) {
                                local s_1 = `s' - 1
                                local s_2 = `s' - 2
                                local s_3 = `s' - 3
                                
                                * (ii)    Allow for endogenous income, expenditures and trade    
                                    generate trade_`s_1' =  tradehat_`s_2' * change_pricei_`s_2' * change_pricej_`s_2' / (change_OMR_FULL_`s_2'*change_IMR_FULL_`s_2')
                        (3)I am not sure how to derive the final formula. I hope to get your help.

                        Best wished,

                        Zibing Zhou

                        Comment


                        • #13
                          Hi Zibing,
                          Probably I do not understand your first question but there is no reason the fitted value and actual value would be the same. The fitted value is based on the estimated coefficients only and does not include the error term. For your other questions, again I suggest reading the documentation for ge_gravity.
                          You are more likely to reach success and understanding that way. If you'd prefer to get advice on the Anderson et al procedure, I would suggest emailing the authors of that paper.
                          Regards,
                          Tom

                          Comment


                          • #14
                            Hi Tom Zylkin,

                            I still thank you for your reply.

                            Best wishes,

                            Zibing Zhou

                            Comment

                            Working...
                            X