Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: estout options


From   "Jann Ben" <ben.jann@soz.gess.ethz.ch>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: estout options
Date   Sat, 6 Aug 2005 00:54:30 +0200

Raoul wrote:
> I have 3 questions and I would like to use this tool to its 
> full potential. 
> I am using estout after a regression analysis.
> 
> 1) Is it possible to swap the rows and colums so that the 
> original variables 
> (the predictors in my regression model)  in the first colum 
> are placed in 
> the first row?
> 
> 2) Is it possible to change the font of the "stars" that indicate 
> significance, i.e can I change it to subscript?
> 
> 3) Is it possible to draw horizontal lines in the output 
> under certain rows?

ad 1)

-estout- cannot swap rows and columns. However, here's a solution 
using mata:

 . sysuse auto
 . reg mpg price weight
 . est sto m1
 . reg mpg price weight turn
 . est sto m2
 . estout * using example.txt, replace
 . mata
 : s = insheet("example.txt")
 : s = s'
 : outsheet("example_t.txt", s)
 : end

where insheet() and outsheet() are:

string matrix insheet(string scalar filename)
{
	s = J(0,0,"")
	fh = fopen(filename, "r")
	while ((line=fget(fh))!=J(0,0,"")) {
		row = J(1,0,"")
		tab = strpos(line, char(9))
		while (tab) {
			row = row, substr(line, 1, tab-1)
			line = substr(line, tab+1, .)
			tab = strpos(line, char(9))
		}
		row = row, line
		s =  (s , J(rows(s), max((cols(row)-cols(s), 0)), "") )
/*
		*/ \ (row , J(1, max((cols(s)-cols(row), 0)), "") )
	}
	fclose(fh)
	return(s)
}

void outsheet(string scalar filename, string matrix s)
{
	fh = fopen(filename, "w")
	for (i=1; i<=rows(s); i++) {
		line = J(1,1,"")
		for (j=1; j<=cols(s); j++) {
			line = line + char(9) + s[i,j]
		}
		fput(fh, line)
	}
	fclose(fh)
}


ad 2)

If you use LaTeX of HTML, then formatting the significance 
stars is easy. For example, 

 . estout ... , starlevels(\$^*\$ .05 \$^{**}\$ .01)

would do with LaTeX. If you use Word, things might be 
more complicated. A possible solution would be to set tags
and then use a Word macro to reformat the table. Another
approach could be to produce a formated HTML table with 
-estout- an then paste it into word.


ad 3)

Use the -varlabels(, elist())- option to add information at
the end of certain rows. For example, 

 . estout ..., varlables(, elist(price \hline))

would add "\hline" at the end of the row for the regressor
called "price" (assuming that such a regressor exists). If 
used with LaTeX, this would draw a horizontal line beneeth 
that row.

ben




  

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index