Announcement

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

  • Esttab: Adding customized column

    Hello all,

    I am trying to generate a regression table with an additional column of customized contents (average of coefficients across different regression columns) using estout/esttab.
    The purpose is to show the average impact across industries.

    I could generate a matrix of mean coefficients, but I am having trouble combining the mean matrix and existing regression tables using esttab command.

    I am attaching an example code below:
    TT is the mean matrix, and I would like to generate a regression table using something like "esttab TT M1 M2 M3 M4 M5".
    (I need to keep the number of observations and will be exporting the regression table to Latex.)

    Code:
    clear all
    cls all
    
    sysuse auto, clear
    
    reg price weight length
    mat TT =e(b)
    mat list TT
    mat TT[1,1] = 0
    mat TT[1,2] = 0
    mat TT[1,3] = 0
    mat list TT
    
    tostring rep78, replace
    drop if rep78=="."
    
    levelsof rep78, local(c)
    foreach i of local c {
    eststo M`i': reg price weight length if rep78 =="`i'"
    
    matrix B_`i'=e(b) 
    
    mat TT[1,1]= TT[1,1] + B_`i'[1,1]
    mat TT[1,2]= TT[1,2] + B_`i'[1,2]
    mat TT[1,3]= TT[1,3] + B_`i'[1,3]
    }
    
    * Mean of coefficients
    mat TT[1,1] = TT[1,1]/5
    mat TT[1,2] = TT[1,2]/5
    mat TT[1,3] = TT[1,3]/5
    
    mat list TT
    
    
    esttab M1 M2 M3 M4 M5,     stats(N, fmt(%9.0fc) ///
        labels(`"Observations"'))

    Any help would be greatly appreciated.

    Thank you.

  • #2
    estout is from SSC (FAQ Advice #12).

    I am trying to generate a regression table with an additional column of customized contents (average of coefficients across different regression columns)
    Use suest to combine the estimates from the regressions, then average using nlcom, specifying the -post- option and storing the averaged estimates.

    Comment


    • #3
      Dear Andrew,

      Thank you very much for your comment.
      I tried suest but there is one issue:

      This is the error message I am getting:
      re-estimate without the cluster() option, and
      specify the cluster() option with suest.


      I would like to estimate using ivreghdfe instead of reg, but suest does not support cluster option with multiple variables.

      This is the actual regression command I need to estimate:
      Code:
      eststo clear
      levelsof HS2, local(c)
      foreach i of local c {
      capture: eststo M`i' : ivreghdfe dep ln_pop (P_ijht ln_ns = iv1 iv2 iv3 iv4) if HS2=="`i'" , first absorb(ijh year) cluster(ijh year)
      di `i'
      }

      I am wondering if there is any way to modify the esttab by adding a mean matrix I generated.

      Thank you so much!

      Comment


      • #4
        suest does not support ivreghdfe (SSC), so it appears that you are in a fix. However, you seem not to be interested in standard errors in #1, so you can still proceed with your manual approach of calculating the coefficients. Then see how the columns "N" and "Clusters" are introduced in #6 of https://www.statalist.org/forums/for...rs-with-esttab.

        Comment

        Working...
        X