cor_test: Correlation Test for Two Continuous Variables

Description Usage Arguments Details Value Examples

View source: R/statistical_tests_and_estimates.R

Description

A wrapper for cor.test function, except if spearman selected and ties in at least one variable, in which case this is a wrapper for coin::spreaman_test in with approximate method.

Usage

1
2
3
4
5
6
7
8
9
cor_test(
  x,
  y,
  method = c("pearson", "kendall", "spearman"),
  seed = 68954857,
  B = 10000,
  exact = TRUE,
  verbose = FALSE
)

Arguments

x

numeric vector (can include NA values)

y

numeric vector (can include NA values)

method

a character string indicating which correlation coefficient is to be used for the test. One of "pearson", "kendall", or "spearman", can be abbreviated

seed

seed (only used if method = "spearman")

B

number of reps (only used if method = "spearman")

exact

Should exact method be used. Ingorned it method = "spearman" and ties present

verbose

a logical variable indicating if warnings and messages should be displayed

Details

To always get reproducible results when using approximate method we need to set seed inside of the call, and order the data

Value

spearman_test pvalue

Examples

1
2
3
4
5
6
set.seed(5432322)
x <- rnorm(20,0,3)
y <- x + rnorm(20,0,5)
cor_test(x,y, method = 'pearson')
cor_test(x,y, method = 'kendall')
cor_test(x,y, method = 'spearman')

z2thet/MoffittFunctions documentation built on July 17, 2021, 9:51 a.m.