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: RE: RE: RE: Re: Stata 12: wish list
From
Amy Dunbar <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: RE: RE: RE: Re: Stata 12: wish list
Date
Tue, 2 Nov 2010 15:44:49 +0000
Thanks for the ranking code, Nick. I frequently forget that missing vars are still included as the largest. And now I finally understand the "touse" code that I have seen so frequently in sample code. Awesome!
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: Tuesday, November 02, 2010 10:04 AM
To: '[email protected]'
Subject: st: RE: RE: Re: Stata 12: wish list
I see main three points arising here.
1. None of this is trivially easy, even if what you want is provided in the software and well documented.
2. Whatever StataCorp do, it's not going to get much easier, unless exceptionally their defaults on everything happen to match exactly your choices. Whatever StataCorp do, the consequence is going to be lots of handles to tweak, and mastering that won't be trivial either. I am still getting to grips with Stata graphics, which I have used just about every working day for almost 20 years. Tables, or reporting, is about the same size of beast.
3. What I see here is positive: You care about well-designed tables and put a lot of work into this code. Next time, not everything will be different and you can steal from what you learned.
On a detail: if ranking lots of variables, watch out for missing values. Safer code looks like this:
gen touse = !missing(a, b, c)
foreach v of var a b c {
egen rank_`v' = rank(`v') if touse
}
That way, missing values are excluded systematically across a varlist.
Nick
[email protected]
Amy Dunbar
Looking at it from capturing share of the market, it may make sense "standardize" table output. I spent the better part of a weekend trying to figure out how to output tables, and yes, now I know how to do it, but many users aren't willing to put that time in. If another product provides a more intuitive way to create table output, the other product may be more attractive. (OK, maybe not; I love Stata.) I get the impression that the Latex users are daily users of Stata, so they can probably figure out just about anything. Someone like me has to struggle understanding the Stata commands. For example, it was nonintuitive to me that some output required -estpost- and some required -eststo-. Undoubtedly some of you are thinking that is obvious, but I may be representative of a lot of Stata users.
I am providing my code below simply to show how "nonintuitive" this code is to an occasional user; now imagine that user having to come up with this code. I have no doubt that my code can be improved, but I sweat bullets over this code. I received a lot of helpful comments from statalist users, so thank you once again! And thank goodness for this link, http://repec.org/bocode/e/estout/index.html.
********************************
*TABLE 3 and 3matrixfull - Correlations*
********************************
egen rETR1 = rank (GAAP_ETR)
egen rETR2 = rank (CURR_ETR)
egen rETR3 = rank (CASH_ETR)
egen rETR4 = rank (LR_CASH_ETR)
egen rBTD = rank (w_totalBTD)
egen rpBTD = rank (w_permBTD)
egen rDTAX = rank (w_DTAX)
egen raBTD = rank (w_abnBTD)
egen rSHELTER = rank (w_SHELTER)
estpost correlate GAAP_ETR CURR_ETR CASH_ETR LR_CASH_ETR w_totalBTD w_permBTD w_DTAX w_abnBTD w_SHELTER, matrix quietly
esttab . using "table3.rtf", replace notype unstack compress noobs nogaps nostar ///
title({\b Table 3, Panel A:} {\i Unadjusted Correlations}) ///
label varwidth(8) modelwidth(7) ///
nonotes nonumbers ///
addnote("Pearson (Spearman) correlation coefficents are reported below (above) the diagonal. See Table 1 for variable definitions.")
*thanks to Nick, I figured out how to output a correlation table that had spearman, but I still have to do a cut and paste to get the final table.
* Output full matrix to enable easy cut and paste into upper half of pwcorr correlation matrix.
estpost correlate rETR1 rETR2 rETR3 rETR4 rBTD rpBTD rDTAX raBTD rSHELTER, matrix nohalf quietly
esttab . using "table3matrixfull.rtf", replace notype unstack compress noobs nogaps nostar ///
title({\b Table 3, Panel B:} {\i Unadjusted Spearman Rank Correlations}) ///
varwidth(8) modelwidth(7) ///
nonotes nonumbers ///
addnote("See Table 1 for variable definitions.")
********************************
*TABLE 4 - Summary Stats*
********************************
estpost tabstat `xlist', stat(n mean sd p25 med p75) columns(statistics)
esttab . using "table4.rtf", replace cells("mean(fmt(%9.4f)) sd p25 p50 p75") noobs nogaps ///
title({\b Table 4, Panel A:} {\i Descriptive Statistics}) ///
label varwidth(10) modelwidth(10) ///
addnote("See Table 1 for variable definitions.")
********************************
*TABLE 6 - Regression Output*
********************************
eststo clear
eststo ETR1: quietly ivreg2 GAAP_ETR medGAAP_ETR lagGAAP_ETR, robust cluster(gvkey fyear)
esttab using "table6.rtf",replace se ar2 unstack nogaps compress nonumbers ///
title({\b Table 6} {\line}{\pard \qc Multivariate Regressions \par}) ///
label varwidth(14) modelwidth(8) ///
stat(N r2_a, labels("N" "Adj. R2")) ///
addnote("See Table 1 for variable definitions.")
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/