Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Using esttab to output regression results for multiple dependent variables


From   XIAOFEI XING <[email protected]>
To   [email protected]
Subject   st: Using esttab to output regression results for multiple dependent variables
Date   Sun, 26 May 2013 13:31:27 +0100

Dear all,

I have several dependent variables: y1, y2, y3, y4, y5, y6, several independent variables: x1, x2, x3, x4, x5, x6, x7, x8, x9, x10 and a categorial variable G. G have three values: 0,1,2

I need to do following regressions for each dependent variable:
reg y1 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 if G==0
reg y1 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 if G==1
reg y1 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 if G==2

For above three regressions, I want to output them in a "csv" document. 

I've write following program:
foreach var in y1 y2 y3 y4 y5 y6 {
reg `var' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 if G==0
est store `var'_m1
reg `var' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 if G==1
est store `var'_m2
reg `var' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 if G==2
est store `var'_m3
esttab `var'_m1 `var'_m2 `var'_m3 using `var'.csv, replace
}

Above program is easy to write; however, if G have several values, I need to repeat following codes several times:
reg `var' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 if G==*
est store `var'_m*

I want to use: 
bys G: eststo: reg `var' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10
However, it will show all the regressions in one "csv". I need to show regressions for each dependent variable in each "csv".

Thanks a lot for your help.

Best wishes,

Xiaofei Xing
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index