cor_test: Test for Multiple Correlations Between Paired Samples

Description Usage Arguments Value See Also Examples

View source: R/cor_test.R

Description

Test for multiple associations between paired samples, using one of Pearson's product moment correlation coefficient, Kendall's tau or Spearman's rho.

Usage

1
2
3
4
5
6
7
8
9
cor_test(
  x,
  y = NULL,
  use = "pairwise",
  method = "pearson",
  boot_ci = FALSE,
  p_adjust = "fdr",
  ...
)

Arguments

x

a numeric matrix or data frame.

y

NULL (default) or a matrix or data frame with compatible dimensions to x. The default is equivalent to y = x (but more efficient).

use

an optional character string giving a method for handling missing values. This must be (an abbreviation of) one of the strings "everything", "all.obs", "complete.obs", "na.or.complete", or "pairwise.complete.obs" (default). See cor for explanation of these options.

method

a character string indicating which correlation coefficient is to be computed. One of "pearson" (default), "kendall", or "spearman": can be abbreviated.

boot_ci

Logical value indicating whether or not to generate a bootstrapped confidence interval for the correlation coefficient. Defaults to FALSE.

p_adjust

Character string naming the correction method to adjust for multiple correlation tests. In addition to the standard available p.adjust.methods, one may also choose "permute", in which case cor_perm will be used to empirically determine and adjust for the family-wise error rate. Default method is to control the false discovery rate ("fdr") with the Benjamini–Hochberg ("BH") procedure.

...

Optional named arguments accepted by cor_boot, cor_perm, and/or cor.test

Value

a cor_test object

See Also

cor.test, cor_list, summarise.cor_list, cor_boot, cor_perm, p.adjust

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Create a correlation list for the numeric variables from the iris data set
cor_test(iris[,-5])

# Calculate a bootstrap confidence interval
cor_test(iris[,-5], boot_ci = TRUE, n_rep = 1000)

# Obtain unadjusted p-values with no correction for false discovery
cor_test(iris[,-5], p_adjust = "none")

# Use permutation test to adjust p-value for family-wise error
cor_test(iris[,-5], p_adjust = "permute", n_perm = 1000)

# Use Bonferroni correction to adjust p-value for family-wise error
cor_test(iris[,-5], p_adjust = "bonferroni")

#' Calculate spearman's rho
cor_test(iris[,-5], method = "spearman")

jashu/corxplor documentation built on Dec. 10, 2019, 7:09 p.m.