# DGB
## Correlation Difference from Two (Independent) Samples
ci.corr.is <- function(alpha, corr1, corr2, n1, n2) {
# Computes a confidence interval for a difference in population
# Pearson correlations from two independent samples
# Arguments:
# alpha: alpha value for 1-alpha confidence
# corr1: sample correlation between y and x in group 1
# corr2: sample correlation between y and x in group 2
# n1: sample size of group 1
# n2: sample size of group 2
# Values:
# lower limit, upper limit
z <- qnorm(1 - alpha/2)
se1 <- sqrt(1/((n1 - 3)))
zr1 <- log((1 + corr1)/(1 - corr1))/2
LL0 <- zr1 - z*se1
UL0 <- zr1 + z*se1
LL1 <- (exp(2*LL0) - 1)/(exp(2*LL0) + 1)
UL1 <- (exp(2*UL0) - 1)/(exp(2*UL0) + 1)
se2 <- sqrt(1/((n2 - 3)))
zr2 <- log((1 + corr2)/(1 - corr2))/2
LL0 <- zr2 - z*se2
UL0 <- zr2 + z*se2
LL2 <- (exp(2*LL0) - 1)/(exp(2*LL0) + 1)
UL2 <- (exp(2*UL0) - 1)/(exp(2*UL0) + 1)
LL <- corr1 - corr2 - sqrt((corr1 - LL1)^2 + (UL2 - corr2)^2)
UL <- corr1 - corr2 + sqrt((UL1 - corr1)^2 + (corr2 - LL2)^2)
CI <- c(LL, UL)
return(CI)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.