Announcement

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

  • ppml_panel_sg error

    dear statalist

    hello
    i try to use panel data with 'ppml_panel_sg' gravity model

    i want to add time-varying fixed effect and pair fixed effect

    however when i use it, it shows error massesge

    Error: the set of origin, destination, industry, and time IDs do not uniquely describe the data
    If this is not a mistake, try collapsing the data first using collapse (sum)


    Does anyone know why it happens?

    Thank you

  • #2
    Hi KIM SUJIN,

    I'm the creator of ppml_panel_sg, so I'd be happy to try to help. What this message is saying is that your data does not appear to be set up in the way the command is expecting. Ordinarily, ppml_panel_sg expects a trade data set with trade flows indexed by origin, destination, and time. In addition, there should only be one observation associated with each origin, destination, and time. For example, if your data set has two different observations where the exporter is China, the importer is France, and the time period is 2004, then it will give you this error as a way of telling you to look for possible duplicate observations. However, if this is intentional on your part - perhaps there were two different types of trade flows between China and France recorded in your data - then you can obtain the total trade flow by collapsing your data, as the error message suggests.

    The same is also true if you specify an industry code. In that case, ppml_panel_sg expects each observation to have a unique combination of origin-destination-industry-time IDs. Otherwise, it assumes there is an issue with how your data has been coded.

    Regards,
    Tom

    Comment


    • #3
      Hello! thank you very much for help

      Its great to know there is ppml_panel_sg which is much faster

      I have monthly data, and maybe that's why it has problems!

      I wonder how to collapse these data to fit it for ppml_panel_sg command
      thank you in advance!

      Comment


      • #4
        Hi KIM SUJIN

        You can read about the collapse command by entering "help collapse". Specifically, if you want to collapse your data from monthly data to yearly data, you would use collapse (sum). The collapse command is a fairly fundamental data manipulation command so I suggest that you familiarize yourself with it.

        Given that you have monthly data and you appear to be trying to fit an annual model with exporter-year and importer-year fixed effects, let me just ask though if this is really what you want to be doing?

        Regards,
        Tom

        Comment


        • #5
          thank you for reply!
          I want to add time vayring fixed effect as well as country pair fixed effect!


          I used ppml_panle_sg variables variables ----, im(import) ex(export) y(year) trend

          I wonder its right command

          thank you!

          Comment


          • #6
            Hi KIM SUJIN

            When you say time-varying fixed effects, what do you specifically mean? I can tell you that

            ppml_panel_sg ..., im(import) ex(export) y(year) trend

            will give you exporter-year, importer-year, and exporter-importer fixed effects as well as an exporter-importer-specific time trend. If these is what you want, you should use collapse to collapse your data to an annual frequency.

            however, given that your data is monthly, you could just as easily have exporter-month and importer-month FEs in place of the exporter-year and importer-year FEs. In that case, you would replace "year" with a variable identifying the month and year. It depends on what you want to do.

            Alternatively, there is another new command I have worked on called ppmlhdfe that provides more flexibility in how you specify the FEs. You could try that and it would not give you an error. However, it would not solve the problem that you need to think more carefully about how your data is structured and what is the right model to apply to it.

            I hope this is helpful,
            Tom

            Comment


            • #7
              I hope to use only export-time, im-time, piar fixed effect!
              than, should I do not add any side command such as trend?


              Thank you!

              Comment


              • #8
                also, I wonder why
                note: Ban omitted because of collinearity over lhs>0 (creates possible existence issue)
                note: Log_Distance omitted because of collinearity over lhs>0 (creates possible existence issue)
                note: Log_GDP_i omitted because of collinearity over lhs>0 (creates possible existence issue)
                note: Log_GDP_j omitted because of collinearity over lhs>0 (creates possible existence issue)

                i got these result~

                Ban is a dummy variable.
                what is lhs>0 meaning?


                and why the dummy variable is also dropped in the result ?


                Thank you

                Comment


                • #9
                  Hi KIM SUJIN

                  It is because these variables are all collinear with your fixed effects. GDP for example only varies by country and time. Distance only varies by pair. When you have exporter-time, importer-time, and exporter-importer fixed efffects, you can only ID variables that vary by both pair and time (for example, a dummy equal to 1 when two countries have an FTA meets this requirement because FTA status is pair-specific and changes over time when countries sign new FTAs.)

                  Hope this helps.
                  Tom
                  Last edited by Tom Zylkin; 15 Apr 2019, 12:03.

                  Comment


                  • #10
                    Thank you Tom!!

                    trade ban is time varying at the same time pair! but its dropped
                    hu,mm
                    ..

                    Comment


                    • #11
                      HI KIM SUJIN

                      Are you sure "ban" is time-varying and pair specific? Try running the following regressions:
                      HTML Code:
                      reghdfe ban, absorb(export#year import#year export#import)
                      
                      reghdfe ban, absorb(export#year import#year)
                      
                      reghdfe ban, absorb(export#import)
                      Do any of these have an R^2 of 1?

                      Comment


                      • #12
                        I've got

                        Exporter: string variables may not be used as factor variables
                        stata(): 3598 Stata returned error
                        fixed_effects(): - function returned error
                        <istmt>: - function returned error

                        Comment


                        • #13
                          trade ban dummy variable which is 1 if there are trade ban from exporter to importer. Its monthly dummy variable~
                          i need to actually regress it but it is disappear..

                          Comment


                          • #14
                            Hi Kim,
                            Try this:

                            HTML Code:
                            egen exp_year = group(export year)
                            egen imp_year = group(import year)
                            egen pair          = group(export import)  
                            reghdfe ban, absorb(export_year import_year pair)  
                            reghdfe ban, absorb(export_year import_year)  
                            reghdfe ban, absorb(pair)

                            Comment


                            • #15
                              . reghdfe Ban, absorb(exp_year imp_year pair)
                              (dropped 2016 singleton observations)
                              warning: Ban might be perfectly explained by fixed effects (tol = 1.0e-09)




                              . reghdfe Ban, absorb(exp_year imp_year)
                              (dropped 2016 singleton observations)
                              warning: Ban might be perfectly explained by fixed effects (tol = 1.0e-09)
                              (MWFE estimator converged in 2 iterations)


                              . reghdfe Ban, absorb(pair)
                              (MWFE estimator converged in 1 iterations)


                              I got this..


                              Comment

                              Working...
                              X