Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | "Joseph Coveney" <stajc2@gmail.com> |
To | <statalist@hsphsun2.harvard.edu> |
Subject | st: Re: Difference between -spearman- and -pwcorr- with ranked variables |
Date | Mon, 23 Sep 2013 15:43:42 +0900 |
Owen Gallupe wrote: My understanding is that Spearman correlations are simply Pearson correlations using ranked data. However, when I run the spearman command I get different results from when I convert the variables to ranks and then run the pwcorr command with the ranks. . spearman var1 var2 rho = -0.0112, p = 0.5642 . egen rankvar1 = rank(var1) . egen rankvar2 = rank(var2) . pwcorr rankvar1 rankvar2, sig r = -0.0100, p = 0.6058 I suspect it has something to do with the way I created the ranked variables, but I'm not sure. If someone could point me in the right direction, I would really appreciate it! -------------------------------------------------------------------------------- You rank the pooled variables. See below. Joseph Coveney . sysuse auto, clear (1978 Automobile Data) . rename price var1 . rename gear_ratio var2 . quietly reshape long var, i(make) j(dummy) . egen double rank = rank(var) . quietly reshape wide var rank, i(make) j(dummy) . spearman var1 var2 Number of obs = 74 Spearman's rho = -0.2525 Test of Ho: var1 and var2 are independent Prob > |t| = 0.0299 . pwcorr rank1 rank2, sig | rank1 rank2 -------------+------------------ rank1 | 1.0000 | | rank2 | -0.2525 1.0000 | 0.0299 | . * * 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/