Announcement

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

  • etable - multiple regression estimates and combining them in two headers

    Click image for larger version

Name:	Screenshot 2024-11-18 at 9.45.58 PM.png
Views:	2
Size:	90.1 KB
ID:	1767845
    Hi All,

    I am trying to customize the etable by putting two headers for the eight regressions estimates. For first four columns (OLS_List1, OLS_List2, OLS_List3, OLS_List4) should have a header "OLS" and the remaining four estimates (IV_List1, IV_List2, IV_List3, IV_List4) should have the header as "IV". I am unable to achieve this. I will greatly appreciate your help. The screenshot of the output is attached.

    Thank you.

    Last edited by Preety Bhogal; 18 Nov 2024, 21:08.

  • #2
    You did not provide any data or code, so we have to come up with our own example and hope it matches your case.

    In order to group your column headers, you need to define a new dimension that assigns the levels OLS or IV to each of your estimation results consumed by etable. Then add that new dimension to the layout.

    Here is a simple example using the auto data and 4 simple linear regressions.
    Code:
    * example setup
    sysuse auto
    unab ylist : turn trunk displ head
    foreach y of local ylist {
        regress `y' foreign
        est store `y'
        local eqrecode `eqrecode' eqrecode(`y'=xb)
    }
    etable , estimates(`ylist') `eqrecode'
    
    * query the layout to see what dimension is used for the column header; in
    * this case it is -etable_depvar-
    collect layout
    * list the levels and labels of -etable_depvar-
    collect label list etable_depvar
    
    * define a new dimension, named -group-, assigning the levels you want to see
    * in the column header -- I'm using 'Group1' and 'Group2'
    collect addtags group[Group1], fortags(etable_depvar[1 2])
    collect addtags group[Group2], fortags(etable_depvar[3 4])
    
    * respecify the layout, but add dimension -group- to the column specification
    collect layout (coleq#colname#result[_r_b _r_se] result[N]) (group#etable_depvar#stars[value])
    Here is the resulting table.
    Code:
    ------------------------------------------------------------
                                Group1             Group2
                             turn   trunk  displacement headroom
    ------------------------------------------------------------
    Car origin              -6.033  -3.341     -122.484   -0.540
                           (0.874) (1.022)     (18.568)  (0.207)
    Intercept               41.442  14.750      233.712    3.154
                           (0.477) (0.557)     (10.124)  (0.113)
    Number of observations      74      74           74       74
    ------------------------------------------------------------
    It appears from your example table that your column headers might be the names specified in estimates(), so you might have to work with dimension etable_estimates instead of etable_depvar.

    Comment

    Working...
    X