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

RE: st: RE: Changing -correlate- results


From   "louis boakye-yiadom" <louisby@hotmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   RE: st: RE: Changing -correlate- results
Date   Mon, 21 Mar 2005 12:33:57 +0000

Nick and Scott, thank you very much. I'm really learning a lot from statalist. I'll try both -egen- and the "stable" option of -sort-.

Louis





From: "Scott Merryman" <smerryman@kc.rr.com>

Tied values are randomized. From the helpfile:

"Note: ties in the sort index (i.e., identical sorting values) are broken in
an arbitrary (i.e., random) order, unless the stable option is specified."

You might try:

sort f1, stable

sort f2, stable

Hope this helps,
Scott

> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
> statalist@hsphsun2.harvard.edu] On Behalf Of louis boakye-yiadom
> Sent: Monday, March 21, 2005 6:09 AM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: Changing -correlate- results
>
> Dear All,
> Apologies for the garbled form of my last mail.
> A -correlate- command in my do file gives slightly different results each
> time the file is executed. For example, for the last three times the file
> was executed, the correlation coefficient between the same two variables
> (rankf1 and rankf2) were as follows: 0.7466, 0.7499, and 0.7524. I'm
> baffled
> by this, and I don't find any explanation from the -help- for -correlate-.
> I've provided excerpts of the do file. Any help will be appreciated.
> Thank you.
>
> use isocomb_indices, clear;
> sort f1;
> list region district dmrd dmkt dpt djss dchp fl, clean header(50);
> gen rankf1=_n;
> sort f2
> list region district pwrd pwmkt1 pwmkt2 pwjss pwchp f2, clean header(50);
> gen rankf2=_n;
> bysort region: list region district nc f1 rankf1 f2 rankf2, clean mean(f1
> rankf1 f2 rankf2);
> correlate rankf1 rankf2;
> drop rankf1 rankf2;
> sort region district;
> save isocomb_indices, replace;
> clear;
> log close;
> exit;
>
> Louis
>
>


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

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