test.diff.cor.single: Test for difference in correlation

Description Usage Arguments Details Value Author(s) See Also Examples

Description

This functions uses the Fisher Z-transform (atanh) to test the null hypothesis of no difference in correlations between x1 and y1 versus x2 and y2.

Usage

1
2
3
## S3 method for class 'diff.cor.single'
test(x1, y1, x2, y2,
  alternative = c("two.sided", "less", "greater"), conf.level = 0.95)

Arguments

x1

numeric vector, x-values for the first sample.

y1

numeric vector, y-values for the first sample.

x2

numeric vector, x-values for the second sample.

y2

numeric vector, y-values for the second sample.

Details

The alternative argument specifies the alternative hypothesis given below.

H0: cor(x1, y1) = cor(x2, y2)
"two.sided" => H1: cor(x1, y1) != cor(x2, y2)
"greater" => H1: cor(x1, y1) > cor(x2, y2)
"less" => H1: cor(x1, y1) < cor(x2, y2)

Value

A numeric vector giving correlation for each group, size-estimate and standard error, confidence intervals and p-values.

Author(s)

Anders Ellern Bilgrau <anders.ellern.bilgrau (at) gmail.com>

See Also

Similar usage to cor.test in stats, however not the same!
See test.diff.cor for a vectorised version.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
x1 <- rnorm(100)
y1 <- rnorm(100)
x2 <- rnorm(110)
y2 <- 4*x2 + 0.5*rnorm(110) + 1

plot(x1, y1, xlim = range(x1, x2), ylim = range(y1, y2))
abline(lm(y1 ~ x1))
points(x2, y2, col = "red")
abline(lm(y2 ~ x2), col = "red")

diff.test <- correlateR:::test.diff.cor.single
round(data.frame(
  two = diff.test(x1, y1, x2, y2, alternative = "two.sided"),
  les = diff.test(x1, y1, x2, y2, alternative = "less"),
  gre = diff.test(x1, y1, x2, y2, alternative = "greater")), 2)
  
round(diff.test(x1, y1, x1, y1, alternative = "two.sided"), 3)
round(diff.test(x1, y1, x1, y1, alternative = "less"), 3)
round(diff.test(x1, y1, x1, y1, alternative = "less"), 3)

AEBilgrau/correlateR documentation built on June 1, 2019, 9:11 p.m.