Reputation: 1453
I'm running a bunch of bivariate regressions which I would like to report in an Excel file. The resulting table at the moment looks like this:
var1 coef1a coef1b
(tvalue1a)(tvalue1b)
var2 coef2a coef2b
(tvalue2a) (tvalue2b) ...
Where ...
stands for another 50 variables. I know this is much to ask of outreg
but is there some way to get an output like:
var1 coef1a coef1b
(tvalue1a)(tvalue1b)
var2 coef2a coef2b
(tvalue2a) (tvalue2b)
...
although the two coefficients come from different regressions?
I'm just interested in the coefficients and the t-values, the other statistics do not need to be recorded (constant, R2 etc).
Reproducible example:
clear all
ssc install outreg2
sysuse auto
local path yourpath
cd "`path'"
local vars mpg rep78 headroom trunk weight length
local replace replace
foreach i of local vars{
reg price `i'
outreg2 using "$path\example.xls", ctitle("var1") long `replace'
local replace
reg price `i', robust
outreg2 using "$path\example.xls", ctitle("var1") long `replace'
}
Upvotes: 0
Views: 1503
Reputation: 11102
Have you tried the ESTOUT
module, from SSC?
sysuse auto, clear
eststo: quietly regress price weight mpg
eststo: quietly regress price weight mpg foreign
esttab
You can save to .csv files. See for example
http://repec.org/bocode/e/estout/esttab.html#esttab010
which has more examples.
Ben Jann, the author of ESTOUT
, has written a program that can stack model results to be used with esttab
. Below the program with examples:
. capt prog drop appendmodels
. *! version 1.0.0 14aug2007 Ben Jann
. program appendmodels, eclass
1. // using first equation of model
. version 8
2. syntax namelist
3. tempname b V tmp
4. foreach name of local namelist {
5. qui est restore `name'
6. mat `tmp' = e(b)
7. local eq1: coleq `tmp'
8. gettoken eq1 : eq1
9. mat `tmp' = `tmp'[1,"`eq1':"]
10. local cons = colnumb(`tmp',"_cons")
11. if `cons'<. & `cons'>1 {
12. mat `tmp' = `tmp'[1,1..`cons'-1]
13. }
14. mat `b' = nullmat(`b') , `tmp'
15. mat `tmp' = e(V)
16. mat `tmp' = `tmp'["`eq1':","`eq1':"]
17. if `cons'<. & `cons'>1 {
18. mat `tmp' = `tmp'[1..`cons'-1,1..`cons'-1]
19. }
20. capt confirm matrix `V'
21. if _rc {
22. mat `V' = `tmp'
23. }
24. else {
25. mat `V' = ///
> ( `V' , J(rowsof(`V'),colsof(`tmp'),0) ) \ ///
> ( J(rowsof(`tmp'),colsof(`V'),0) , `tmp' )
26. }
27. }
28. local names: colfullnames `b'
29. mat coln `V' = `names'
30. mat rown `V' = `names'
31. eret post `b' `V'
32. eret local cmd "whatever"
33. end
. sysuse auto
(1978 Automobile Data)
. eststo b1: quietly regress price weight
. eststo b2: quietly regress price mpg
. eststo b3: quietly regress price foreign
. eststo bivar: appendmodels b1 b2 b3
. esttab b1 b2 b3 bivar, mtitles
Source: http://repec.org/bocode/e/estout/advanced.html#advanced901
Upvotes: 1