adjust.corr: Correlation Matrices and tests with p-value adjustment

adjust.corrR Documentation

Correlation Matrices and tests with p-value adjustment

Description

The adjust.corr function produces correlation matrices from raw data frames and produces standard normal theory t-test based p-values for all correlations among pairs of variables. It will also produce adjusted p-values for the simultaneous inference on whole correlation matrices.

Usage

adjust.corr(
  x,
  type = c("pearson", "spearman"),
  use = c("complete.obs", "pairwise.complete.obs"),
  adjust = "holm"
)

Arguments

x

A data frame or a correlation matrix. If there is missing data it is safer to pass the original data and control how missing data are handled with the use argument.

type

"pearson" or "spearman" permits specification of the type of correlation coefficient.

use

specifies how missing values are handled: "complete.obs" peeforms listwise deletion of cases and is the default; "pairwise.complete.obs" performs pairwise deletion.

adjust

Which p-value adjustment for multiple testing is to be used? ("holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none"). The "holm" method is the default and is preferred to the "bonferroni" method. The "hochberg" and "hommel" methods assume independence of the multiple tests and that is unlikely for correlation matrices. The "BH" and "fdr" methods are equivalent and produce the false discovery rate adjustment. See help for the p.adjust function for details.

Details

The function takes a data frame or a correlation matrix. The former is preferred to give control over the method of handling missing data. The correlation matrix is returned, along with unadjusted and adjusted p-value matrices. Adjustment for simultaneous inference utilizes thep.adjust function from base R to accomplish the adjustments. The p-values assume a two-tailed test. Internally the function uses "Hmisc::rcorr" to calculate the correlation coefficients and to handle pairwise deletion when missing data are present.

Similar capabilities can be found in the psych::corr.test and psych::corr.p functions which will also produce confidence intervals for the correlation coefficients.

Author(s)

Bruce Dudek bruce.dudek@albany.edu

References

This function is a modeled on a function originally coded as the corr.adjust function in the RcmdrMisc package.

Examples

adjust.corr(mtcars[,c(1,4:8)], use="complete.obs", adjust="fdr")
adjust.corr(mtcars[,c(1,4:8)], use="pairwise.complete.obs")
data(attitude)
adjust.corr(attitude, adjust="none")
M2 <- cor(mtcars[,c(1,4:8)])
adjust.corr(M2)


bcdudek/bcdstats documentation built on Jan. 3, 2024, 10:09 p.m.