cortest: Correlation

cortestR Documentation

Correlation

Description

Performs a correlation test on each row/column of a the input matrix.

Usage

row_cor_pearson(x, y, alternative = "two.sided", conf.level = 0.95)

col_cor_pearson(x, y, alternative = "two.sided", conf.level = 0.95)

Arguments

x

numeric matrix.

y

numeric matrix for the second group of observations.

alternative

alternative hypothesis to use for each row/column of x. A single string or a vector with value for each observation. Must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence levels used for the confidence intervals. A single number or a numeric vector with value for each observation. All values must be in the range of [0;1] or NA.

Details

Functions to perform various correlation tests for rows/columns of matrices. Main arguments and results were intentionally matched to the cor.test() function from default stats package.

row_cor_pearson(x, y) - test for Pearson correlation on rows. col_cor_pearson(x, y) - test for Pearson correlation on columns.

Results should be the same as running cor.test(x, y, method="pearson") on every row (or column) of x and y.

Value

a data.frame where each row contains the results of a correlation test performed on the corresponding row/column of x.

Each row contains the following information (in order):
1. obs.paired - number of paired observations (present in x and y)
2. cor - estimated correlation coefficient
3. df - degrees of freedom
4. statistic - t statistic
5. pvalue - p-value
6. conf.low - lower confidence interval
7. conf.high - higher confidence interval
8. alternative - chosen alternative hypothesis
9. cor.null - correlation of the null hypothesis (=0)
10. conf.level - chosen confidence level

Note

For a marked increase in computation speed turn off the calculation of confidence interval by setting conf.level to NA.

Author(s)

Karolis Koncevičius

See Also

cor.test()

Examples

X <- iris[iris$Species=="setosa",1:4]
Y <- iris[iris$Species=="virginica",1:4]
col_cor_pearson(X, Y)
row_cor_pearson(t(X), t(Y))


karoliskoncevicius/matrixTests documentation built on Oct. 18, 2023, 5:50 a.m.