I am running mixed effects regressions on data which is structured as follows: I have about 30 data sets, each one with about 100K observations and representing a sample from one year. I need to run 30 regressions (15 different dependent variables using two different analytical techniques) per data set and save the regression output. Critically, I need the output organized by year. I'm using the excellent estout package to achieve this. However, with 30^2 saved results, I will very quickly exceed my version of Stata's limits on saved results. The easiest solution I could find for this limit is to call -esttab- within each data year then appending the results for each consecutive year. Unfortunately, -esttab- appends new results "below" previous results, resulting in a very long column that will be very tedious to restructure after all results are compiled.
The below code is a simple "reprex" that will produce the structure of regression output I would like:
Unfortunately, the size of my data and limited computing power force me to implement code similar to the following, which produces the "long" column of regression outut:
I would appreciate advice on any of the following directions:
The below code is a simple "reprex" that will produce the structure of regression output I would like:
Code:
version 13.1 webuse productivity, clear forval y = 1970/1986 { qui mixed gsp || region : if year == `y', mle eststo vardecomp_y`y', noesample qui mixed gsp private emp hwy water other unemp || region : if year == `y', cov(un) mle eststo mix_y`y', noesample } esttab mix_y* using mix.csv, replace nostar noparentheses plain cells("b(fmt(a6) nostar) se(par fmt(a6)) t(par fmt(a6))") esttab vardecomp_y* using vardecomp.csv, replace nostar noparentheses plain cells("b(fmt(a6) nostar) se(par fmt(a6)) t(par fmt(a6))")
Code:
forval y = 1970/1986 { if `y' == 1979 { loc replace_append replace } else { loc replace_append append } qui mixed gsp || region : if year == `y', mle eststo vardecomp, noesample esttab vardecomp using vardecomp.csv, `replace_append' nostar noparentheses plain cells("b(fmt(a6) nostar) se(par fmt(a6)) t(par fmt(a6))") qui mixed gsp private emp hwy water other unemp || region : if year == `y', cov(un) mle eststo mix, noesample esttab mix using mix.csv, `replace_append' nostar noparentheses plain cells("b(fmt(a6) nostar) se(par fmt(a6)) t(par fmt(a6))") }
- Ideally, I would like to use -estout- in combination with the _append_ option but produce "wide" output, as in the first code chunk.
- Or if you see a simple/easy way to restructure the "long" output into wide after all the append operations are complete, this would be equally good.