Skip to contents

Calculate two correlation coefficients and test if they are statistically different (given the sample-sizes).

Usage

calculate.and.compare.correlations(x1, x2, y1, y2, method = 'spearman');

Arguments

x1

Vector of x-values for correlation 1

x2

Vector of x-values for correlation 2

y1

Vector of y-values for correlation 1

y2

Vector of y-values for correlation 2

method

What correlation method should be used? Currently only supports Spearman's rho

Value

No return value

Author

Paul C. Boutros

Note

I worry about the use of length(x1) and length(x2) in the code. We really need to be determining the number of jointly non-NA entries (since we set use = 'pairwise.complete.obs'). I think this would be something like length( x1[ !is.na(x1&y1) ] );

Examples

calculate.and.compare.correlations(
  x1 = rnorm(100),
  x2 = rnorm(100),
  y1 = runif(100),
  y2 = runif(100),
  method = 'spearman'
  );
#> [1]   0.15003900  -0.09705371   0.01092784   0.01092784  -0.24854051
#> [6]   0.14783663   0.09272728 100.00000000 100.00000000