syrvn
2010-Nov-29 15:30 UTC
[R] Significance of the difference between two correlation coefficients
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 -- View this message in context: http://r.789695.n4.nabble.com/Significance-of-the-difference-between-two-correlation-coefficients-tp3063765p3063765.html Sent from the R help mailing list archive at Nabble.com.
Adaikalavan Ramasamy
2010-Nov-29 17:02 UTC
[R] Significance of the difference between two correlation coefficients
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
>
Norm Matloff
2010-Dec-02 21:46 UTC
[R] Significance of the difference between two correlation coefficients
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