z_fisher_test: Fisher's Z test for Pearson's correlation.

Description Usage Arguments Details Value Examples

View source: R/z_fisher_test.R

Description

z_fisher_test performs test on Pearson's correlation using Fisher's Z transform.

Usage

1
2
z_fisher_test(x, y, rho0 = 0, alternative = "two.sided",
conf_level = 0.95)

Arguments

x

a numeric vector.

y

a numeric vector.

rho0

Pearson's correlation under null hypothesis.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf_level

confidence level of the interval

Details

It can be proved that \frac{1}{2}\ln≤ft(\frac{1 + r}{1- r} \right) has normal distribution with mean \frac{1}{2}\ln≤ft(\frac{1 + ρ}{1- ρ} \right) and variance σ^2 = \frac{1}{n - 3}.

Value

z_fisher_test return a list with the following components:

statistic

statistic of test

p_value

p-value

alternative

a character string specifying the alternative hypothesis

lower_ci

lower bound in the confidence interval

upper_ci

upper bound in the confidence interval

conf_level

confidence level of the interval

Examples

1
2
3
4
5
6
7
8
# x and y are not correlated
Sigma <- matrix(c(1, 0, 0, 1), ncol = 2)
m <- MASS::mvrnorm(500, mu = c(0, 1), Sigma = Sigma)
z_fisher_test(m[, 1], m[, 2])
# x and y are correlated
Sigma <- matrix(c(1, 0.85, 0.85, 1), ncol = 2)
m <- MASS::mvrnorm(500, mu = c(0, 1), Sigma = Sigma)
z_fisher_test(m[, 1], m[, 2])

gilberto-sassi/power documentation built on July 17, 2020, 1:02 p.m.