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

      Working...
      X