Announcement

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

  • Creating Tables with appended panels/models

    Hello,

    My results require many regressions. Currently I am appending each regression as a column in my output using outreg2. However, I would like one table to have multiple panels, like the attached photo (this photo is from an example paper I found that creates a table like what I'm trying to make, in this case Hardy and Ziliak 2014, it is not related to my current project).

    When I have seen the replication code for tables that do this, they tend to outreg2 all the regressions the "normal way" i.e. as columns. And then presumably they manually edit the tables to have "panels". Because I need to create many "panels" in one table, however, I would like to automate this process, if possible. Basically I have all my regressions, would just like to know if there's a way to automate actually making the sort of table that I have attached a photo of.

    In case it is helpful, here is a snippet of the code I am currently running to make one such table (this is just putting all the regressions in columns, which makes for a very wide yet short table).

    Code:
    cd "$PATH/Output"
    local categories "work nonmarket_work education leisure_1 tv eating sleeping personal_care child_care_full own_medical_care other_care civic"
    *what I would like to be "part 1" of the table - all days of the survey
    foreach variable of varlist `categories' {
        qui reg `variable' `controls1' mw [pweight = tuwgt] if teen == 1 & teengroup == 2, a(gestfips)
        outreg2 using workandday_1819teens.xls, keep(mw)   bdec(4)  symbol (**,*,+) nonote label excel word append
    }
    
    *what I would like to be "part 2" of the table - same "categories" columns, but for weekdays of the survey
    *I would like this to appear as a "second panel" below the regressions in the previous for loop. Separated by another title, of course
    foreach variable of varlist `categories' {
        qui reg `variable' `controls1' mw [pweight = tuwgt] if teen == 1 & teengroup == 2 & weekend == 0 , a(gestfips)
        outreg2 using workandday_1819teens.xls, keep(mw)   bdec(4)  symbol (**,*,+) nonote label excel word append
    }
    
    *what I would like to be "part 3" of the table - same "categories" columns, but for weekends of the survey
    foreach variable of varlist `categories' {    
        qui reg work `controls1' mw [pweight = tuwgt] if teen == 1 & teengroup == 2 & weekend == 1 , a(gestfips)
        outreg2 using workandday_1819teens.xls, keep(mw)   bdec(4)  symbol (**,*,+) nonote label excel word append
    }
    While this is currently creating a table in excel using outreg2, I can use estout and/or latex if those help at all.

    If you are able to help, thank you so much!!

    (source for the example table: Hardy, Bradley and James P. Ziliak. 2014. “Decomposing Trends in Income Volatility: The “Wild Ride” at the Top and Bottom.” Economic Inquiry 52(1): 459-476.)
    Attached Files
Working...
X