CorCI: Confidence Intervals for Pearson Correlation

View source: R/CorCI.R

CorCIR Documentation

Confidence Intervals for Pearson Correlation

Description

Find the confidence intervals for a specified correlation based on Fisher's z-transformation.

Usage

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

Arguments

rho

the Pearson's correlation coefficient

n

sample size used for calculating the confidence intervals

conf.level

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

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.

Details

The sampling distribution of Pearson's r is not normal. Fisher developed a transformation now called "Fisher's z-transformation" used for the calculation of normal distributed confidence intervals.

Value

rho, lower and upper confidence intervals (CorCI)

Author(s)

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

See Also

FisherZ, FisherZInv

Examples


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

zs <- FisherZ(cors)
rs <- FisherZInv(zs)
round(zs, 2)
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)


AndriSignorell/DescTools documentation built on Feb. 20, 2025, 1:54 a.m.