psych (version 1.3.10.12)

corr.test: Find the correlations, sample sizes, and probability values between elements of a matrix or data.frame.

Description

Although the cor function finds the correlations for a matrix, it does not report probability values. corr.test uses cor to find the correlations for either complete or pairwise data and reports the sample sizes and probability values as well. For symmetric matrices, raw probabilites are reported below the diagonal and correlations adjusted for multiple comparisons above the diagonal. In the case of different x and ys, the default is to adjust the probabilities for multiple tests.

Usage

corr.test(x, y = NULL, use = "pairwise",method="pearson",adjust="holm")
corr.p(r,n,adjust="holm")

Arguments

x
A matrix or dataframe
y
A second matrix or dataframe with the same number of rows as x
use
use="pairwise" is the default value and will do pairwise deletion of cases. use="complete" will select just complete cases.
method
method="pearson" is the default value. The alternatives to be passed to cor are "spearman" and "kendall"
adjust
What adjustment for multiple tests should be used? ("holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none"). See p.adjust for details about why to use "holm" rather than "bonferroni").
r
A correlation matrix
n
Number of observations of using corr.p

Value

  • rThe matrix of correlations
  • nNumber of cases per correlation
  • tvalue of t-test for each correlation
  • ptwo tailed probability of t for each correlation. For symmetric matrices, p values adjusted for multiple tests are reported above the diagonal.
  • sestandard error of the correlation

Details

corr.test uses the cor function to find the correlations, and then applies a t-test to the individual correlations using the formula $$t = \frac{r * \sqrt(n-2)}{\sqrt(1-r^2)}$$

$$se = \sqrt(\frac{1-r^2}{n-2})$$

The t and Standard Errors are returned as objects in the result, but are not normally displayed.

The probability values may be adjusted using the Holm (or other) correction. If the matrix is symmetric (no y data), then the original p values are reported below the diagonal and the adjusted above the diagonal. Otherwise, all probabilities are adjusted (unless adjust="none"). This is made explicit in the output.

See Also

cor.test for tests of a single correlation, Hmisc::rcorr for an equivalant function, r.test to test the difference between correlations, and cortest.mat to test for equality of two correlation matrices.

Also see cor.ci for bootstrapped confidence intervals of Pearson, Spearman, Kendall, tetrachoric or polychoric correlations. In addition cor.ci will find bootstrapped estimates of composite scales based upon a set of correlations (ala cluster.cor).

In particular, see p.adjust for a discussion of p values associated with multiple tests.

Other useful functions related to finding and displaying correlations include lowerCor for finding the correlations and then displaying the lower off diagonal using the lowerMat function. lowerUpper to compare two correlation matrices.

Examples

Run this code
data(sat.act)
corr.test(sat.act)
corr.test(sat.act[1:3],sat.act[4:6]) #reports all values corrected for multiple tests

corr.test(sat.act[1:3],sat.act[4:6],adjust="none")  #don't adjust the probabilities

Run the code above in your browser using DataLab