Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: RE: RE: RE: RE: -esttab- label and -estpost- Spearman


From   Amy Dunbar <Amy.Dunbar@business.uconn.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: RE: RE: -esttab- label and -estpost- Spearman
Date   Mon, 18 Oct 2010 17:35:08 +0000

Thank you, Nick.  

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
Sent: Monday, October 18, 2010 12:05 PM
To: 'statalist@hsphsun2.harvard.edu'
Subject: st: RE: RE: RE: -esttab- label and -estpost- Spearman

Almost but not quite what I had in mind. The -unique- option is not appropriate here. You need the default of -egen, rank()- for precisely the treatment of tied ranks that is appropriate for Spearman correlations. 

Nick
n.j.cox@durham.ac.uk 

Amy Dunbar

Thank you! Worked great.  Here's my final code.

egen rETR1 = rank (GAAP_ETR_t), unique
egen rETR2 = rank (CURR_ETR_t), unique
egen rETR3 = rank (CASH_ETR_t), unique
egen rETR4 = rank (LR_CASH_ETR_t), unique egen rBTD  = rank (w_totalBTD), unique egen rpBTD = rank (w_permBTD), unique egen rDTAX = rank (w_DTAX), unique egen raBTD = rank (w_abnBTD), unique egen rSCOR = rank (w_SHELTER), unique

* correlate gives same results as pwcorr
* The columns of the matrix are stored in separate equations. Hence, use the unstack option in esttab or estout to print the matrix.

estpost correlate GAAP_ETR_t CURR_ETR_t CASH_ETR_t LR_CASH_ETR_t 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 Correlations}) ///
	  label varwidth(8) modelwidth(7) ///
	  nonotes nonumbers
* correlate gives same results as spearman when correlating ranked variables.  Output full matrix to  enable easy cut and paste into upper half of pwcorr correlation matrix above.

estpost correlate rETR1 rETR2 rETR3 rETR4 rBTD rpBTD rDTAX raBTD rSCOR, matrix nohalf quietly esttab . using "table3.rtf", append notype unstack compress noobs nogaps nostar ///
      title({\b Table 3, Panel B:} {\i Spearman Rank Correlations}) ///
	  varwidth(8) modelwidth(7) ///
	  nonotes nonumbers 

Nick Cox

You can always get Spearman rank correlations by ranking the variables and then running -correlate-. That's what they are. 

Amy Dunbar

3. Is there a way to estimate Spearman correlations using -estpost-?


*
*   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/


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