Announcement

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

  • PPML prediction - gravity

    Hello all,

    I am writing to seek some guidance on a 'problem'. I am estimating a gravity model using a panel using multiple methods (fixed effects, time-varying FE etc). Using those estimates I can then compare the predicted values (using the "predict" command) with the actual ones. Would this also work in the same manner for PPML estimation? That is, something along the lines of:

    Code:
    predict fitppml, xb
    predict stdpred_fitppml, stdp
    generate upbound_fitppml = yhat_fitppml + invnormal(0.975)*stdpred_fitppml
    generate lowbound_fitppml = yhat_fitppml - invnormal(0.975)*stdpred_fitppml
    On the website http://personal.lse.ac.uk/tenreyro/SampleDoS.do (Log of Gravity) the authors mention: "If you want to compute 'undertrading' and 'overtrading' after fixed-effects regressions with panel data, you need to obtain a set of residuals with zero mean." However, I don't understand how (and why it makes a difference) I would implement this.

    Thanks.
    Last edited by Waleed A; 26 Aug 2015, 03:51.

  • #2
    Welcome to the Forum. Please follow the etiquette recommended by the Forum FAQ which is to use full names here (firstname lastname). As the FAQ explains, it's easy and quick to re-register to accomplish tthis (hit the Contact button at bottom right and make your request). Thank you.

    Comment


    • #3
      To be able to help you I need to know a bit more about what you are doing. Please post the command that you are using (also recommended in the FAQ) and I'll see if I can help, OK?

      Comment


      • #4
        Thank you for your reply. I'm trying to find the trade 'gap' between a pair of countries using gravity. For this, I need to predict the flows. Here are the (relevant) commands I run:

        Code:
        * Creating dummies and identifying panel
            quietly tab exporter, gen(exporter_)
            quietly tab importer, gen(importer_)
            quietly tab year, gen(year_)
            egen pairid = group(exporter importer)
            xtset pairid year
        
        * PPML estimation:
            ppml flow ldist contig col_hist comlang_off comleg religion comcur rta wto_exp exporter_* importer_* year_*, cluster(pairid) strict
        
        * where trade flow is in levels, contig-->wto_exp are dummies, and the three-way effects.
        
        * Predictions (with confidence intervals)
            predict fittedppml, xb
            predict stdpred_fitppml, stdp
            
            generate upbound_fitppml = fittedppml + invnormal(0.975)*stdpred_fitppml
            generate lowbound_fitppml = fittedppml - invnormal(0.975)*stdpred_fitppml
        Code:
        *Not sure about this code: (adapted from Log of Gravity)
            * Residuals with zero mean
            gen yhat_ppml = exp(fittedppml)
            egen meany = mean(flow) if yhat_ppml !=., by(pairid)
            egen meanyhat_ppml  = mean(yhat_ppml), by(pairid)
            gen exp_alpha  = meany / meanyhat_ppml
            gen error_y = flow - (yhat_ppml * exp_alpha)
            
            summarize error_y
        Could you please explain the significance of what you mentioned on the website, and how to implement it? Also, how would I estimate with time-varying FE's?

        I appreciate your help
        Last edited by Waleed A; 26 Aug 2015, 10:49.

        Comment


        • #5
          Dear Waleed,

          What is mentioned in the website does not apply to your case; it only applies when -xtpqml- or -ivpoisson- with the -fe- options are used. So, all you need to do is to use the standardprediction commands. How exactly to do that depends on whether you are using Stata 14 or an earlier version.

          All the best,

          Joao

          Comment


          • #6
            Dear Mr. Silva,

            Thank you for your time. Ok, I will discard the second code then. I'm using Stata 13.1, so is this prediction code correct?

            Code:
                predict fittedppml, xb
                predict stdpred_fitppml, stdp
                generate upbound_fitppml     = fittedppml + invnormal(0.975)*stdpred_fitppml
                generate lowbound_fitppml    = fittedppml - invnormal(0.975)*stdpred_fitppml

            Comment


            • #7
              To predict trade you need to use the option mu, not xb. To get the confidence intervals with Stata 13.1 is a bit more complicated, do you really need those?

              Joao

              Comment


              • #8
                Ah yes, I missed that point, thank you! I plan to make a graph which would plot the predictions v/s the actual values. I think it would be useful to show the confidence intervals in this case. Could you help?

                Comment


                • #9
                  The confidence intervals you you want are for the realizations of random variable and these are generally impossible to obtain unless you are willing to make totally unrealistic assumptions about the distribution of your data. Alternatively you would need to use a semi-parametric alternative but that would require methods totally different form those you are using.

                  All the best,

                  Joao

                  Comment


                  • #10
                    Thanks for all your helpful comments. I appreciate it.

                    Kind regards,
                    Waleed

                    Comment


                    • #11
                      Hi, in #7 Joao mentioned to use mu option instead of xb. I am wondering what the difference between the two option is? Would be glad for some more information, the help files don't say much..

                      Comment


                      • #12
                        Dear Felix Stips,

                        These options follow the usual Stata convention: xb gives you literally xb (the linear index) and mu gives you the expected value, in this case exp(xb).

                        Best wishes,

                        Joao

                        Comment


                        • #13
                          Thank you!

                          Comment

                          Working...
                          X