View source: R/confIntCorrelation.R
confIntCorrelation | R Documentation |
Computes a confidence interval for a correlation coefficient r
using
the variance-stabilizing transformation
z = \tanh^{-1}(r) = 0.5 \log((1 + r) / (1 - r)),
known as Fisher's z
-transformation.
Independent of the true correlation \rho
, z
is approximately
normally distributed with variance (n-3)^{-1}
. This enables the construction
of a Wald-type confidence interval. Back-transformating this interval yields a confidence
interval for r
. An advantage of this method is
that the interval is contained in (-1, 1)
.
confIntCorrelation(
x,
y,
conf.level = 0.95,
method = c("spearman", "pearson"),
type = c("t", "z")
)
x |
Vector containing the first variable. |
y |
Vector of same length as |
conf.level |
Confidence level for confidence interval. Default is 0.95. |
method |
Correlation coefficient to be used: "spearman" (default) or "pearson". |
type |
Quantile to be used: "t" (default) or "z". |
List with entries:
estimate |
Value of correlation coefficient. |
ci |
Computed confidence interval. |
p.value |
|
n |
Number of observations. |
p2 |
|
Kaspar Rufibach
kaspar.rufibach@gmail.com
n <- 40
x <- runif(n = n)
y <- 2 * x + 0.5 * rnorm(n = n)
confIntCorrelation(x = x, y = y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.