Announcement

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

  • Exporting post-estimation results from xthdidregress using esttab

    Hello everyone!

    I'm using xthdidregress and then obtaining aggregated treatment effects using estat aggregation. I want to export these results to a formatted Latex table. I normally use esttab but, in this case, esttab is pulling the results from the main command, not from estat aggregation. Could someone provide some ideas on how to export the results stored after estat aggregation?

    Thank you!
    Marialejandra

  • #2
    estout is from SSC (FAQ Advice #12). The results from estat aggregation are stored in r(). You can transfer these to e() using estadd. Here is some approach:

    Code:
    webuse akc, clear
    xtset breed year
    estimates clear
    xthdidregress twfe (registered best) (movie), group(breed)
    estat aggregation, cohort
    
    *COLLECT MATRICES AND TRANSFER TO e()
    estadd matrix b_a= r(table)["b", 1 ...]
    estadd matrix se_a = r(table)["se", 1 ...]
    estadd matrix p_a= r(table)["pvalue", 1 ...]
    
    *OUTPUT
    esttab, cells(b_a(fmt(2) star pval(p_a)) se_a(fmt(2) par)) ///
    eqlab(none) mlab(ATET, lhs(Cohort)) collab(none) nonumb ///
    note("Standard errors in parentheses")
    Res.:

    Code:
    . estat aggregation, cohort
    
    ATET over cohort                                         Number of obs = 1,410
    
                                    (Std. err. adjusted for 141 clusters in breed)
    ------------------------------------------------------------------------------
                 |               Robust
          Cohort |       ATET   std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
            2034 |     1665.6   108.1196    15.41   0.000     1451.841    1879.358
            2036 |   2014.238   46.58969    43.23   0.000     1922.127    2106.348
            2037 |   2311.245   68.99377    33.50   0.000     2174.841     2447.65
    ------------------------------------------------------------------------------
    
    
    
    . 
    . *OUTPUT
    . esttab, cells(b_a(fmt(2) star pval(p_a)) se_a(fmt(2) par)) ///
    > eqlab(none) mlab(ATET, lhs(Cohort)) collab(none) nonumb ///
    > note("Standard errors in parentheses")
    
    ----------------------------
    Cohort               ATET   
    ----------------------------
    2034              1665.60***
                     (108.12)   
    2036              2014.24***
                      (46.59)   
    2037              2311.25***
                      (68.99)   
    ----------------------------
    N                    1410   
    ----------------------------
    Standard errors in parentheses
    
    
    
    .

    Comment


    • #3
      Thank you so much, this works perfectly!

      Comment


      • #4
        Following up on this conversation: do you know how I can combine the results of these aggregations with other estimation approaches using esttab?
        Say I want to compare the treatment effect of a simple TWFEs and the overall effect estimated using Callaway and Sant' Anna:
        Code:
        webuse akc, clear
        xtset breed year
        
        *simple twfe model
        reghdfe registered movie best, cluster(breed) a(breed year)
        eststo twfe
        
        * Callaway and Sant' Anna
        xthdidregress aipw (registered best) (movie), group(breed) basetime(common)
        estat aggregation
        Overall ATET                                             Number of obs = 1,410
        
                                        (Std. err. adjusted for 141 clusters in breed)
        ------------------------------------------------------------------------------
                     |               Robust
          registered |       ATET   std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
               movie |
           (1 vs 0)  |   2093.318   122.5752    17.08   0.000     1853.075    2333.561
        ------------------------------------------------------------------------------
        Is there a way I can use `esttab' to show the overall of the estiamtors?

        Doing the following does not work as the stored estimates for the Callaway model are not the ones of the simplified aggregation


        Code:
        xthdidregress twfe (registered best) (movie), group(breed)
        estat aggregation
        eststo csdid
        esttab twfe csdid
        thanks a lot for your support
        Last edited by Tom Ford; 13 May 2025, 04:53.

        Comment


        • #5
          One possibility is to include the aggregate ATET as a summary statistic alongside the TWFE results.

          Comment

          Working...
          X