Announcement

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

  • Update on SSC: JWDID and Gravity models

    Dear all,
    Thanks to Prof. Baum, a new update is now available for -jwdid-.
    In this new update, many new features have been added for the estimation of linear and nonlinear models with staggered intervention. Many of these allow for a more flexible specification of DID models following the Extended TWFE approach.
    In our new paper https://ideas.repec.org/p/ris/drxlwp/2024_005.html, Yoto Yotov and Arne Nagengast present how you can use JWDID for Gravity models.
    And if you are curious about the link between the command options, and the math behind it, see https://friosavila.github.io/app_metrics/app_metrics11.html
    Best wishes
    Fernando


  • #2
    Thanks much.

    Comment


    • #3
      Dear Fernando,
      Thanks a lot for these great new extensions of the jwdid command!

      I want to estimate a gravity model using method(ppmlhdfe). To specify say exporter_country*year fixed effects could I simply write fevar(i.exporter_country##i.year)?

      Thanks again and best wishes,
      Till

      Comment


      • #4
        Basically
        check out the paper which contains all code for relevant gravity model syntax

        Comment


        • #5
          Dear FernandoRios

          Thank you very much for jwdid command and its uses in gravity models.
          I have posted a query at some other place in this forum, you can see it here (page 4, #59), I am sorry for bombarding you with multiple queries. But I have a one simple clarification.

          Here is my dataex example

          Code:
          * Example generated by -dataex-. To install: ssc install dataex
          clear
          input str3(iso_i iso_k) int year
          "ALB" "AUS" 1995
          "ALB" "AUS" 1996
          "ALB" "AUS" 1997
          "ALB" "AUS" 1998
          "ALB" "AUS" 1999
          "ALB" "AUS" 2000
          "ALB" "AUT" 1995
          "ALB" "AUT" 1996
          "ALB" "AUT" 1997
          "ALB" "AUT" 1998
          "ALB" "AUT" 1999
          "ALB" "AUT" 2000
          "CAN" "BLG" 1995
          "CAN" "BLG" 1996
          "CAN" "BLG" 1997
          "CAN" "BLG" 1998
          "CAN" "BLG" 1999
          "CAN" "BLG" 2000
          "CAN" "FRA" 1995
          "CAN" "FRA" 1996
          "CAN" "FRA" 1997
          "CAN" "FRA" 1998
          "CAN" "FRA" 1999
          "CAN" "FRA" 2000
          end
          I define my treatment assignment as

          Code:
          gen RTA_i = .
          gen RTA_k = .
          
          foreach pair in  "ALB 1995" "AUS 1997" "AUT 1998" "BLG 1999" {
              local country = word("`pair'", 1)
              local year = word("`pair'", 2)  
              replace RTA_i = `year' if iso_i == "`country'"
              replace RTA_k = `year' if iso_k == "`country'"
          }
          egen RTA_ik = rowmax(RTA_i RTA_k)
          replace RTA_ik = . if missing(RTA_i) | missing(RTA_k)
          gen D_gs = cond(missing(RTA_ik), ., (year >= RTA_ik))
          Here, RTA_i and RTA_k, take the value of year when iso_i and iso_k first became the member of regional trade agreement, respectively.
          By similar logic, RTA_ik denotes the first year, in which both the exporter and importer of country pairs (iso_i and iso_k) were part of RTA. In other words, RTA_ik denotes the treatment cohort g if the RTA onset for both iso_i and iso_k was in year g.
          D_gs is the time-varying treatment indicator equal to 1 for cohort g for s=t in post-treatment years and 0 otherwise.

          My Question is a simple clarification.,

          1) If we implement jwdid, what is my gvar() ? is it RTA_ik or D_gs in this example.?
          2) For missing values in RTA_ik or D_gs, should we replace them with 0.

          Please respond to this clarification, I shall be very thankful to you.

          Thanks and regards,
          (Ridwan)
          Last edited by Ridwan Sheikh; 05 Feb 2025, 00:49.

          Comment


          • #6
            1) Gvar its rta_ik (year when both countries joined the Euro)
            2) Why would it be missing? You do not know the country or the year?
            I would keep it as missing

            Comment


            • #7
              Thanks FernandoRios for replying back. This was definitely helpful.

              I have more to ask regarding your 2) point.

              Essentially, I am looking at the impact of compliance with some agreement on trade flows. In my case, if exporter country (iso_i) complied to the agreement in year 1995 and importer country (iso_k) complied to the agreement in year 2000, then my gvar (compliance_ik) takes the value of 2000 for this pair, which is the year when both iso_i and iso_k were first compliant to the agreement.
              However in some cases, if either iso_i or iso_k or both iso_i and iso_k are missing, then compliance_ik is missing accordingly (i.e., if certain countries in iso_i or iso_k do not comply with the agreement during the sample period, the compliance_ik takes the missing value for those country-pair during the sample period). This means that the missing values in compliance_ik are never-treated comparisons in diff-in-diff terminology. Please correct me if I am wrong. Now, I have a clarification related to this point.

              I was replicating Jeff Wooldridge ETWFE do-file, where he puts the value of 0 on never-treated units in gvar. But, here you say, you will keep compliance_ik (which is my gvar) as missing, if it is missing for never-treated country-pairs, please highlight it more. What if I replace missing values of compliance_ik with 0, in line with what I learnt from Jeff Wooldridge, should that be a problem?

              My second clarifcation is regarding your paper, "Nagengast et al. (2024). The European single market and intra-EU trade: An assesment with heterogeneity-robust difference-in-differences methods. School of Economics, LeBow College of Business, Drexel University, WP 2024-05". In this paper, you define a gvar (FTU_EU), that denotes a first year, in which both exporter (i) and importer (k) of a country-pair were part of EU, it is not a dummy variable, rather takes the value of year when both iso_i and iso_k first became members of EU. But in equation-1, you define a time-varying indicator (dummy) variable D_gs that takes value of 1 for each cohort in post-treatment period, and 0 otherwise. I am not clear, what is the difference between FTU_EU and D_gs? In my case, following your paper, I have defined a similar time-varying post-treatment dummy, D_gs for each cohort, and was not sure whether my gvar is compliance_ik or D_gs? As you said the gvar is compliance_ik, but then what is the siginificane of D_gs in jwdid estimation framework.? I am sorry if this sounds a dumbest question to ask, but I had a hardtime in understanding the difference between D_gs dummy mentioned in the paper and FTU_EU used in jwdid estimation.

              I respect a time you take to answer the queries in this form, and understand your busy schedules. Please help me to understand the above two queries.

              Thanks and regards,
              (Ridwan)
              Last edited by Ridwan Sheikh; 06 Feb 2025, 01:06.

              Comment


              • #8
                Ok that makes more sense
                if never treated gvar=0

                for the post treatment dummy. That is created internally. You only need to provide the tvar and gvar. The dummies are constructed internally

                lastly, you could define gvar as the earlier year of treatment, and use xattvar to qualify when both countries become part of the eu.

                Comment


                • #9
                  Thanks FernandoRios ! I really appreciate the clarifications you provided.

                  However, I couldn't understand your last point. How should I define gvar as the earlier year of treatment and use xattvar to qualify when both countries became compliant to the agreement.
                  I have following dataex example, that is generally representative of my sample. It would be helpful, If you can provide me with some codes.

                  Code:
                  * Example generated by -dataex-. To install: ssc install dataex
                  clear
                  input str3(iso_i iso_k) int(year treat_i treat_k compliant_ik)
                  "ALB" "AUS" 1995 1995 1997 1997
                  "ALB" "AUS" 1996 1995 1997 1997
                  "ALB" "AUS" 1997 1995 1997 1997
                  "ALB" "AUS" 1998 1995 1997 1997
                  "ALB" "AUS" 1999 1995 1997 1997
                  "ALB" "AUS" 2000 1995 1997 1997
                  "ALB" "AUT" 1995 1995 1998 1998
                  "ALB" "AUT" 1996 1995 1998 1998
                  "ALB" "AUT" 1997 1995 1998 1998
                  "ALB" "AUT" 1998 1995 1998 1998
                  "ALB" "AUT" 1999 1995 1998 1998
                  "ALB" "AUT" 2000 1995 1998 1998
                  "CAN" "BLG" 1995    . 1999    0
                  "CAN" "BLG" 1996    . 1999    0
                  "CAN" "BLG" 1997    . 1999    0
                  "CAN" "BLG" 1998    . 1999    0
                  "CAN" "BLG" 1999    . 1999    0
                  "CAN" "BLG" 2000    . 1999    0
                  "CAN" "FRA" 1995    .    .    0
                  "CAN" "FRA" 1996    .    .    0
                  "CAN" "FRA" 1997    .    .    0
                  "CAN" "FRA" 1998    .    .    0
                  "CAN" "FRA" 1999    .    .    0
                  "CAN" "FRA" 2000    .    .    0
                  "DEU" "USA" 1995 1997    .    0
                  "DEU" "USA" 1996 1997    .    0
                  "DEU" "USA" 1997 1997    .    0
                  "DEU" "USA" 1998 1997    .    0
                  "DEU" "USA" 1999 1997    .    0
                  "DEU" "USA" 2000 1997    .    0
                  "DEU" "GBR" 1995 1997 1999 1999
                  "DEU" "GBR" 1996 1997 1999 1999
                  "DEU" "GBR" 1997 1997 1999 1999
                  "DEU" "GBR" 1998 1997 1999 1999
                  "DEU" "GBR" 1999 1997 1999 1999
                  "DEU" "GBR" 2000 1997 1999 1999
                  end

                  The gvar in this example is compliant_ik, which is generated as:

                  Code:
                  egen compliant_ik = rowmax(treat_i treat_k)
                  replace compliant_ik = 0 if missing(treat_i) | missing(treat_k)
                  If I have to run jwdid, assumig data is panel (ignoring, trade and fixed effects, id_ci_ck, idt_ci, idt_ck for a moment), I will do something like:

                  Code:
                  jwdid trade, ivar(id_ci_ck) tvar(year) gvar(compliant_ik) method(ppmlhdfe) fevar( idt_ci idt_ck)
                  How will I accommodate your last point in jwdid using this dataex example
                  you could define gvar as the earlier year of treatment, and use xattvar to qualify when both countries become part of the eu.
                  Thanks and regards,
                  (Ridwan)

                  Comment


                  • #10
                    Code:
                     
                     jwdid trade, ivar(id_ci_ck) tvar(year) gvar(compliant_ik) method(ppmlhdfe) fevar( idt_ci idt_ck) xattgvar(both_members)
                    where Both_members is 1 if both countries are members of the EU.

                    Note that you need to download the latest version of it from my repository
                    F

                    Comment


                    • #11
                      Thank you FernandoRios

                      This is my code for both_members

                      Code:
                      gen both_members = (compliant_ik > 0)
                      1. Is this code correct. ?

                      both_members takes the value of 1 if both iso_i and iso_k are compliant to the agreement, and takes the value of zero if compliant_ik is 0 (i.e., if either iso_i, iso_k or both iso_i and iso_k are non-compliant).

                      2. Where can I find your latest repository? Can you post the link here.
                      I had initially installed jwdid from ssc, do I need to replace any files before downnloading your latest version.


                      Thanks,
                      (Ridwan)
                      Last edited by Ridwan Sheikh; 08 Feb 2025, 00:21.

                      Comment


                      • #12
                        FernandoRios thank you for the new update on JWDID—it’s incredibly helpful!

                        I’m currently replicating the paper Staggered Difference-in-Differences in Gravity Settings, and I am trying to reproduce the pre-trends figure. However, when I run the command: jwdid trade, ivar(id_ci_cj) tvar(year) gvar(first_treat_3) method(ppmlhdfe) fe(idt_ci idt_cj brdr_time) never ifcond(PRE) I receive the error:
                        "option ifcond not allowed."

                        Is there a way to correctly specify ifcond(PRE) in the current version of JWDID? If not, is there an alternative approach to implementing a similar restriction?

                        Thank you in advance for your guidance!
                        Zhixiao

                        Comment


                        • #13
                          Hi Zhixiao
                          couple of notes
                          1. There is no option ifcond.
                          2. Refer to the latest paper (see helpfile) an earlier version by my coauthors was using a previous iteration of jwdid that they modified a bit. I standardize it for the current version.
                          3. Not sure what you want to do with "pre".
                          F

                          Comment


                          • #14
                            Note that you need to download the latest version of it from my repository
                            Dear FernandoRios where can I find the latest version of jwdid ?

                            Thanks,
                            (Ridwan)

                            Comment

                            Working...
                            X