[R] Significance of the difference between two correlation coefficients
Adaikalavan Ramasamy
a.ramasamy at imperial.ac.uk
Mon Nov 29 18:02:37 CET 2010
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
>
More information about the R-help
mailing list