rcorr Computes a matrix of Pearson's
r or Spearman's
rho rank correlation coefficients for all possible pairs of
columns of a matrix. Missing values are deleted in pairs rather than
deleting all rows of
x having any missing variables. Ranks are
computed using efficient algorithms (see reference 2), using midranks
rcorr(x, y, type=c("pearson","spearman"))
# S3 method for rcorr print(x, …)
a numeric matrix with at least 5 rows and at least 2 columns (if
y is absent). For
x is an object
a numeric vector or matrix which will be concatenated to
y is omitted for
x must be a matrix.
specifies the type of correlations to compute. Spearman correlations are the Pearson linear correlations computed on the ranks of non-missing elements, using midranks for ties.
argument for method compatiblity.
rcorr returns a list with elements
matrix of correlations,
matrix of number of observations used in analyzing each pair of variables,
P, the asymptotic P-values.
Pairs with fewer than 2 non-missing values have the r values set to NA.
The diagonals of
n are the number of non-NAs for the single variable
corresponding to that row and column.
Uses midranks in case of ties, as described by Hollander and Wolfe.
P-values are approximated by using the
Hollander M. and Wolfe D.A. (1973). Nonparametric Statistical Methods. New York: Wiley.
Press WH, Flannery BP, Teukolsky SA, Vetterling, WT (1988): Numerical Recipes in C. Cambridge: Cambridge University Press.