Significance of the difference between two correlation coefficients

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Significance of the difference between two correlation coefficients

syrvn
Hi,

based on the sample size I want to calculate whether to correlation coefficients are significantly different or not. I know that as a first step both coefficients
have to be converted to z values using fisher's z transformation. I have done this already but I dont know how to further proceed from there.

unlike for correlation coefficients I know that the difference for z values is mathematically defined but I do not know how to incorporate the sample size.

I found a couple of websites that provide that service but since I have huge data sets I need to automate this procedure.

(http://faculty.vassar.edu/lowry/rdiff.html)

Can anyone help?

Cheers,
syrvn
Reply | Threaded
Open this post in threaded view
|

Re: Significance of the difference between two correlation coefficients

Adaikalavan Ramasamy-2
Thanks for providing the example but it would be useful to know who I am
communicating with or from which institute, but nevermind ...

I don't know much about this subject but a quick google search gives me
the following site: http://davidmlane.com/hyperstat/A50760.html

Using the info from that website, I can code up the following to give
the two-tailed p-value of difference in correlations:

  diff.corr <- function( r1, n1, r2, n2 ){

    Z1 <- 0.5 * log( (1+r1)/(1-r1) )
    Z2 <- 0.5 * log( (1+r2)/(1-r2) )

    diff   <- Z1 - Z2
    SEdiff <- sqrt( 1/(n1 - 3) + 1/(n2 - 3) )
    diff.Z  <- diff/SEdiff

    p <- 2*pnorm( abs(diff.Z), lower=F)
    cat( "Two-tailed p-value", p , "\n" )
  }

  diff.corr( r1=0.5, n1=100, r2=0.40, n2=80 )
  ## Two-tailed p-value 0.4103526

  diff.corr( r1=0.1, n1=100, r2=-0.1, n2=80 )
  ## Two-tailed p-value 0.1885966

The p-value here is slightly different from the Vassar website because
the website rounds it's "diff.Z" values to 2 digits.

Regards, Adai



On 29/11/2010 15:30, syrvn wrote:

>
> Hi,
>
> based on the sample size I want to calculate whether to correlation
> coefficients are significantly different or not. I know that as a first step
> both coefficients
> have to be converted to z values using fisher's z transformation. I have
> done this already but I dont know how to further proceed from there.
>
> unlike for correlation coefficients I know that the difference for z values
> is mathematically defined but I do not know how to incorporate the sample
> size.
>
> I found a couple of websites that provide that service but since I have huge
> data sets I need to automate this procedure.
>
> (http://faculty.vassar.edu/lowry/rdiff.html)
>
> Can anyone help?
>
> Cheers,
> syrvn
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Significance of the difference between two correlation coefficients

syrvn
Hi,

thanks a lot. that's what i tried to figure out!
it works great and is exactly what i need.

Best,
syrvn
Reply | Threaded
Open this post in threaded view
|

Re: Significance of the difference between two correlation coefficients

William Revelle
In reply to this post by Adaikalavan Ramasamy-2
At 5:02 PM +0000 11/29/10, Adaikalavan Ramasamy wrote:

>Thanks for providing the example but it would be useful to know who
>I am communicating with or from which institute, but nevermind ...
>
>I don't know much about this subject but a quick google search gives
>me the following site: http://davidmlane.com/hyperstat/A50760.html
>
>Using the info from that website, I can code up the following to
>give the two-tailed p-value of difference in correlations:
>
>  diff.corr <- function( r1, n1, r2, n2 ){
>
>    Z1 <- 0.5 * log( (1+r1)/(1-r1) )
>    Z2 <- 0.5 * log( (1+r2)/(1-r2) )
>
>    diff   <- Z1 - Z2
>    SEdiff <- sqrt( 1/(n1 - 3) + 1/(n2 - 3) )
>    diff.Z  <- diff/SEdiff
>
>    p <- 2*pnorm( abs(diff.Z), lower=F)
>    cat( "Two-tailed p-value", p , "\n" )
>  }
>
>  diff.corr( r1=0.5, n1=100, r2=0.40, n2=80 )
>  ## Two-tailed p-value 0.4103526
>
>  diff.corr( r1=0.1, n1=100, r2=-0.1, n2=80 )
>  ## Two-tailed p-value 0.1885966
>
>The p-value here is slightly different from the Vassar website
>because the website rounds it's "diff.Z" values to 2 digits.
>
>Regards, Adai
>


See also r.test in the psych package which will test for the
difference between two independent correlations as well as the more
complicated case of two dependent correlations.

>  r.test(n=100,r12=.5,r34=.4, n2=80)
Correlation tests
Call:r.test(n = 100, r12 = 0.5, r34 = 0.4, n2 = 80)
Test of difference between two independent correlations
  z value 0.82    with probability  0.41
>

r.test(n=100, .1,-.1,n2=80)

>  r.test(n=100, .1,-.1,n2=80)
Correlation tests
Call:r.test(n = 100, r12 = 0.1, r34 = -0.1, n2 = 80)
Test of difference between two independent correlations
  z value 1.31    with probability  0.19
>

Bill

>
>On 29/11/2010 15:30, syrvn wrote:
>>
>>Hi,
>>
>>based on the sample size I want to calculate whether to correlation
>>coefficients are significantly different or not. I know that as a first step
>>both coefficients
>>have to be converted to z values using fisher's z transformation. I have
>>done this already but I dont know how to further proceed from there.
>>
>>unlike for correlation coefficients I know that the difference for z values
>>is mathematically defined but I do not know how to incorporate the sample
>>size.
>>
>>I found a couple of websites that provide that service but since I have huge
>>data sets I need to automate this procedure.
>>
>>(http://faculty.vassar.edu/lowry/rdiff.html)
>>
>>Can anyone help?
>>
>>Cheers,
>>syrvn
>>
>
>______________________________________________
>[hidden email] mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Significance of the difference between two correlation coefficients

Norm Matloff
In reply to this post by Adaikalavan Ramasamy-2
Adaikalavan Ramasamy wrote:

> Using the info from that website, I can code up the following to give
> the two-tailed p-value of difference in correlations:
>
>   diff.corr <- function( r1, n1, r2, n2 ){
> ...

William Revelle also mentioned the r.test in the psych package.

I would add here that inference on second-order quantities, such as
correlation coefficients and variances, is not robust to the assumption
of a normally-distributed population.  (Inference on first-order
quantities such as means and regression coefficients, IS pretty robust
to that assumption.) A good general alternative is the bootstrap,
implemented in R in the boot package.

Norm Matloff

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Significance of the difference between two correlation coefficients

André
This post has NOT been accepted by the mailing list yet.
In reply to this post by Adaikalavan Ramasamy-2
Hi
my name is Andre, I'm from University of Sao Paulo, Brasil.

I'm also starting to work with correlations, and wonder if this test you code up also works to obtain the significance of the difference between two correlation coefficients even if the data were not normally distributed.

regards

Andre