[R] Fisher's r to z' transformation - help needed

Duncan Murdoch murdoch at stats.uwo.ca
Wed May 23 14:38:03 CEST 2007


On 5/23/2007 7:40 AM, Mike White wrote:
> I am trying to use Fisher's z' transformation of the Pearson's r but the
> standard error does not appear to be correct.  I have simulated an example
> using the R code below.  The z' data appears to have a reasonably normal
> distribution but the standard error given by the formula 1/sqrt(N-3) (from
> http://davidmlane.com/hyperstat/A98696.html) gives a different results than
> sd(z).  Can anyone tell me where I am going wrong?

Your simulation is very strange.  Why are you calculating the 
correlation of data with its own mean?

Here's a simpler simulation that seems to confirm the approximation is 
reasonable:

 > p <- 10
 > sdx <- 1
 > sdy <- 1
 > x <- matrix(rnorm(1000*p, sd=sdx), 1000, p)
 > y <- matrix(rnorm(1000*p, mean=x, sd=sdy), 1000, p)

The true correlation is sdx/sqrt(sdx^2 + sdy^2), i.e. 0.71.

 > r <- numeric(1000)
 > for (i in 1:1000) r[i] <- cor(x[i,], y[i,])
 > f <- 0.5*(log(1+r) - log(1-r))
 > sd(f)
[1] 0.3739086
 > 1/sqrt(p-3)
[1] 0.3779645

 > p <- 5
 > x <- matrix(rnorm(1000*p, sd=sdx), 1000, p)
 > y <- matrix(rnorm(1000*p, mean=x, sd=sdy), 1000, p)
 > r <- numeric(1000)
 > for (i in 1:1000) r[i] <- cor(x[i,], y[i,])
 > f <- 0.5*(log(1+r) - log(1-r))
 > sd(f)
[1] 0.6571383
 > 1/sqrt(p-3)
[1] 0.7071068

Duncan Murdoch



More information about the R-help mailing list