Convert a correlation to a z score or z to r using the Fisher transformation or find the confidence intervals for a specified correlation.

FisherZ(rho)
FisherZInv(z)
CorCI(rho, n, conf.level = 0.95, alternative = c("two.sided", "less", "greater"))

Arguments

rho

the Pearson's correlation coefficient

z

a Fisher z transformed value

n

sample size used for calculating the confidence intervals

alternative

is a character string, one of "greater", "less", or "two.sided", or the initial letter of each, indicating the specification of the alternative hypothesis. "greater" corresponds to positive association, "less" to negative association.

conf.level

confidence level for the returned confidence interval, restricted to lie between zero and one.

Details

The sampling distribution of Pearson's r is not normally distributed. Fisher developed a transformation now called "Fisher's z-transformation" that converts Pearson's r to the normally distributed variable z. The formula for the transformation is:

$$z_r = tanh^{-1}(r) = \frac{1}{2}log\left ( \frac{1+r}{1-r}\right )$$

Value

z value corresponding to r (in FisherZ)

r corresponding to z (in FisherZInv)

rho, lower and upper confidence intervals (CorCI)

See also

Author

William Revelle <revelle@northwestern.edu>,
slight modifications Andri Signorell <andri@signorell.net> based on R-Core code

Examples

cors <- seq(-.9, .9, .1)

zs <- FisherZ(cors)
rs <- FisherZInv(zs)
round(zs, 2)
#>  [1] -1.47 -1.10 -0.87 -0.69 -0.55 -0.42 -0.31 -0.20 -0.10  0.00  0.10  0.20
#> [13]  0.31  0.42  0.55  0.69  0.87  1.10  1.47
n <- 30
r <- seq(0, .9, .1)
rc <- t(sapply(r, CorCI, n=n))
t <- r * sqrt(n-2) / sqrt(1-r^2)
p <- (1 - pt(t, n-2)) / 2

r.rc <- data.frame(r=r, z=FisherZ(r), lower=rc[,2], upper=rc[,3], t=t, p=p)

round(r.rc,2)
#>      r    z lower upper     t    p
#> 1  0.0 0.00 -0.36  0.36  0.00 0.25
#> 2  0.1 0.10 -0.27  0.44  0.53 0.15
#> 3  0.2 0.20 -0.17  0.52  1.08 0.07
#> 4  0.3 0.31 -0.07  0.60  1.66 0.03
#> 5  0.4 0.42  0.05  0.66  2.31 0.01
#> 6  0.5 0.55  0.17  0.73  3.06 0.00
#> 7  0.6 0.69  0.31  0.79  3.97 0.00
#> 8  0.7 0.87  0.45  0.85  5.19 0.00
#> 9  0.8 1.10  0.62  0.90  7.06 0.00
#> 10 0.9 1.47  0.80  0.95 10.93 0.00