Skip to contents

The t test is exact under bivariate normality with df = n - 2; the interval comes from Fisher's variance-stabilising transform, which is why it is not symmetric about r.

Usage

Pearsonr(x, y, level = 0.95)

Arguments

x, y

Paired samples of the same length, n >= 3.

level

Confidence level.

Value

List with estimate, statistic, p_value, df, z, se_z, ci_lower, ci_upper, n.

Details

Formula: rhat = Sxy / sqrt(Sxx Syy); t = rhat sqrt(n - 2)/sqrt(1 - rhat^2) on n - 2 df; z = atanh(rhat), se_z = 1/sqrt(n - 3)

References

Wasserman (2004), All of Statistics, Example 7.13, which derives the plug-in sample correlation. The t test on n - 2 degrees of freedom and Fisher's z transform are NOT in that section; they are the standard published forms (Fisher, 1915, Biometrika 10(4), 507-521).

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
Pearsonr(V, V)
#> $estimate
#> [1] 1
#> 
#> $statistic
#> [1] Inf
#> 
#> $p_value
#> [1] 0
#> 
#> $df
#> [1] 6
#> 
#> $z
#> [1] Inf
#> 
#> $se_z
#> [1] 0.4472136
#> 
#> $ci_lower
#> [1] 1
#> 
#> $ci_upper
#> [1] 1
#> 
#> $n
#> [1] 8
#> 
#> $method
#> [1] "Sample correlation, Wasserman Example 7.13"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"