Statalist


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

Re: st: spearman correlations


From   "Joseph Coveney" <[email protected]>
To   <[email protected]>
Subject   Re: st: spearman correlations
Date   Tue, 4 Aug 2009 21:43:06 +0900

Tirthankar Chakravarty wrote:

http://www.stata.com/statalist/archive/2004-06/msg00302.html
http://sci.tech-archive.net/Archive/sci.stat.math/2006-12/msg00086.html
http://groups.google.com/group/sci.stat.math/browse_thread/thread/cca51ff31ba26420?pli=1

T

On Tue, Aug 4, 2009 at 2:19 AM, Ronggui Huang<[]@gmail.com> wrote:
> CI2 can compute confidence interval of correlation coef, then you can
> compare the other coef with the interval.
>
> Ronggui
>
> 2009/8/4 Ricardo Ovaldia <[]@yahoo.com>:
>> Is there a way to compare two spearman correlations?
>> for example using the auto data:
>>
>> . spearman  price mpg if  foreign==1
>>
>> . spearman  price mpg if  foreign==0
>>
>> How can formaly test the null that these two correlation are equal?

--------------------------------------------------------------------------------

The confidence interval from -ci2- seems to be reasonably close to that from -bootstrap- with a large enough sample size.

How about bootstrapping the difference in the coefficients and seeing whether the confidence interval excludes zero?  I haven't looked at the bootstrap sample distributions from the illustration below.  It's possible that they're ugly, but regardless, I'm assuming that there must be some theoretical reason why such an approach isn't popular.  I'm curious what it is.

Joseph Coveney

version 11.0
clear *
set more off
sysuse auto
ci2 price mpg, spearman
bootstrap rho = r(rho), reps(3000) nodots nowarn ///
    seed(`=date("2009-08-04", "YMD")'): spearman price mpg
estat bootstrap, all

program define spearem, rclass
    version 11.0
    syntax varlist(numeric min=2 max=2), by(varname)
    marksample touse
    assert `touse' // -bootstrap , nowarn-
    spearman `varlist' if `by'
    tempname holder
    scalar define `holder' = r(rho)
    spearman `varlist' if !`by'
    return scalar delta = `holder' - r(rho)
end
bootstrap delta = r(delta), reps(3000) nodots nowarn: ///
    spearem price mpg, by(foreign)
estat bootstrap, all

replace price = -price if foreign
bootstrap delta = r(delta), reps(3000) nodots nowarn: ///
    spearem price mpg, by(foreign)
estat bootstrap, all

exit



*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index