Comparing correlations form two separate samples using fisher's transformation in R
Copy and paste the below into R.
fn <- function(r1,r2,n1,n2,alpha) { a <- abs((1+r1)/(1-r1)) b <- abs((1+r2)/(1-r2)) a <- 0.5*log(a) b <- 0.5*log(b) c <- 1/(n1-3) d <- 1/(n2-3) chisq <- abs((a-b)/sqrt(c+d)) pow <- 1 - pchisq(abs(qchisq(1-alpha,1)),1,chisq*chisq) cat("Power for Fisher's test is") print(pow) }
Input the (two-tailed) type one error, alpha, correlations, r1 and r2, and sample sizes, n1 and n2 as below into R.
alpha <- 0.05 r1 <- 0.7 r2 <- 0.8 n1 <- 67 n2 <- 10000
then copy and paste, or type in, the below to obtain the power.
fn(r1,r2,n1,n2,alpha)