Announcement

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

  • JWDID in Gravity Setting

    Dear All!
    I am using jwdid to estimate the impact of regional trade agreements (RTA) on bilateral trade flows
    (1) In the first case, the outcome (trade-flows) is at aggregated-level and varies at exporter-importer-year dimension. I am running the following code
    Code:
    jwdid trade, ivar(id_ci_cj) tvar(year) gvar(RTA_ij) method(ppmlhdfe) fevar(idt_ci idt_cj)
    I am interested to obtain simple overall ATT using cohort-specific weights, therefore i ran the following code after jwdid
    Code:
    estat simple [pweight=w_g], predict(xb)
    it produces an error that w_g not found.

    (2) In the second case, I keep the data at disaggregated industry level. Here, the outcome varies at exporter-importer-industry-year dimension. Therefore, the panel ID, ivar(id_ci_cj_sk), identifies the trade flows between country i (ci) and country j (cj) in industry k(sk) and the tvar(year) is the time variable. Since being an industry-level panel on trade flows across 147 countries across 1990-2010 period, this involves a data set of 16,038,031 observations. I ran the following code to obtain the ETWFE estimates:
    Code:
    jwdid trade, ivar(id_ci_cj_sk) tvar(year) gvar(RTA_ij) method(ppmlhdfe) fevar(idt_ci idt_cj)
    This gives the following error message:

    reghdfe_standardize(): 3900 unable to allocate real <tmp> [15619903, 109]
    GLM: : init_variables(): - function returned error
    <istmt>: - function returned error

    r(3900)

    109 are total number of coefficients ATT(g,t)]'s estimated in our model.

    I would greatly appreciate any help in this regard.


    FernandoRios

    Thanks and regards,
    (Ridwan)

  • #2
    vFirst issue. Seems you run out of memory. you may consider upgrading your Ram

    First issue, w_g. If that variable exist in our data, then it may be an issue with your version of Stata. Stata 17 had a kind of bug with weights on Margins

    Comment


    • #3
      Thank you FernandoRios

      The w_g does not exist in my data. I have created these cohort-specific weights as:

      Code:
      * weight uniformly (as is baseline) by number of observations
      
      gen w_unif = __etr__
       
      * weight by cohort
      
      egen temp = sum(w_unif), by(FT_EU)
      gen w_g = w_unif/temp
      replace w_g = 0 if w_g==.
      drop temp w_unif
      In my case "year" denotes the time period (1990-2010) over which data on trade flows is observed

      * weight by event year

      gen w_unif = _etr_
      egen temp = sum(w_unif), by(year)
      gen w_t = w_unif/temp
      replace w_t = 0 if w_t==.
      drop temp w_unif

      Similarily, to create weights by cohort-year and trade I did as:


      * weight by cohort*year

      gen w_unif = _etr_
      egen temp = sum(w_unif), by(FT_EU year)
      gen w_gt = w_unif/temp
      replace w_gt = 0 if w_gt==.
      drop temp w_unif

      In my case "trade" is the variable names for my outcome that denote bilateral trade-flows, so to get trade-share weights, I did:

      * weight by trade

      gen w_unif = _etr_
      egen temp = sum(w_unif), by(trade )
      gen w_trade = w_unif/temp
      replace w_trade=0 if w_trade==.
      drop temp w_unif


      I hope I am doing it correct, but I am not sure. I would be thankful if you can have a look at these codes and confirm whether I am creating these weights correctly. That is the last part remining.

      ​​​​​​​Thank you very much
      Last edited by Ridwan Sheikh; 23 Jul 2025, 08:16.

      Comment


      • #4
        Cant tell. Not sure what is your end goal

        Comment


        • #5
          Thanks FernandoRios for replying back.

          I am following Nagengast and Yotov(2025) and your own paper, Nagengast, Rios-Avila, and Yotov (2025). My goal is to generate the overall treatment effects using alternative weighting scheme (Cohort, Event Year, Cohort x Year, and Trade) and see whether the results are sensitive to using different weights. I am working on a different intervention and its impacts on trade, the coding example above using FTU_EU as an intervention was just for the illustration.

          The jwdid did not create these weights and we have to create one, only then the post-estimation "estat simple [pweight=w_t], predict(xb)" will work. I hope this makes sense.

          I would still request you if you can provide some confirmation on whether I am creating the event year weights correctly? that would be of great help to me. I am kind of stuck and unable to proceed in the estimation, all with given deadlines. I hope you understand.

          Thanks,
          (Ridwan)

          Comment


          • #6
            Dear @FernandoRios ,

            I am working on a similar setting to your recent work with the jwdid package. Specifically, I follow Nagengast, Rios-Avila, and Yotov (2024) closely, but focus on the effects of FTAs in services. I am currently running the following specification:
            jwdid trade_sum, ivar(pair_id) tvar(year) gvar(g) method(ppmlhdfe) fevar(exporter_time importer_time) nolog

            where g is the first year for treatment.

            However, I noticed that the standard errors in the output are missing. I would greatly appreciate your advice on whether there is something wrong with my code, or what I should check or modify to address this issue.

            Thank you very much for your time and for developing such a useful tool.

            Best regards,
            Meng Zhang

            Comment


            • #7
              My first guess
              you are overflowing
              Either fixed effects or covariates

              Comment

              Working...
              X