Matrix Tests
A package dedicated to running multiple statistical hypothesis tests on rows and columns of matrices.
Goals
- Fast execution via vectorization.
- Handling of edge cases (NA values, 0 row inputs).
- Output that is detailed and easy to use.
- Result compatibility with tests that are implemented in R.
Examples
1. Bartlett's test on columns
Bartlett's test on every column of iris dataset using Species as groups:
col_bartlett(iris[,-5], iris$Species) obs.tot obs.groups var.pooled df statistic pvalue
Sepal.Length 150 3 0.26500816 2 16.005702 0.0003345076070163084
Sepal.Width 150 3 0.11538776 2 2.091075 0.3515028004158132768
Petal.Length 150 3 0.18518776 2 55.422503 0.0000000000009229038
Petal.Width 150 3 0.04188163 2 39.213114 0.0000000030547839322
2. Welch t-test on rows
Welch t-test on each row of 2 large (million row) matrices:
X <- matrix(rnorm(10000000), ncol=10)
Y <- matrix(rnorm(10000000), ncol=10)
row_t_welch(X, Y) # running time: 2.4 secondsAvailable Tests
Location tests (1 group)
|-----------------------------|-------------------------------|---------------------------------------|
| Name | Function | R equivalent |
|-----------------------------|-------------------------------|---------------------------------------|
| single sample t.test | row_t_onesample(x) | t.test(x) |
| single sample wilcoxon test | row_wilcoxon_onesample(x) | wilcox.test(x) |
|-----------------------------|-------------------------------|---------------------------------------|
Location tests (2 groups)
|-----------------------------|-------------------------------|---------------------------------------|
| Name | Function | R equivalent |
|-----------------------------|-------------------------------|---------------------------------------|
| equal variance t.test | row_t_equalvar(x, y) | t.test(x, y, var.equal=TRUE) |
| welch t.test | row_t_welch(x, y) | t.test(x, y) |
| two sample wilcoxon test | row_wilcoxon_twosample(x, y) | wilcox.test(x, y) |
|-----------------------------|-------------------------------|---------------------------------------|
Location tests (2+ groups)
|-----------------------------|-------------------------------|---------------------------------------|
| Name | Function | R equivalent |
|-----------------------------|-------------------------------|---------------------------------------|
| equal variance oneway anova | row_oneway_equalvar(x, g) | oneway.test(x ~ g, var.equal=TRUE) |
| welch oneway anova | row_oneway_welch(x, g) | oneway.test(x ~ g) |
| kruskal-wallis test | row_kruskalwallis(x, g) | kruskal.test(x, g) |
| van der waerden test | row_waerden(x, g) | PMCMR::vanWaerden.test(x, g) |
|-----------------------------|-------------------------------|---------------------------------------|
Location tests (paired)
|-----------------------------|-------------------------------|---------------------------------------|
| Name | Function | R equivalent |
|-----------------------------|-------------------------------|---------------------------------------|
| paired t.test | row_t_paired(x, y) | t.test(x, y, paired=TRUE) |
| paired wilcoxon test | row_wilcoxon_paired(x, y) | wilcox.test(x, y, paired=TRUE) |
|-----------------------------|-------------------------------|---------------------------------------|
Scale tests (2 groups)
|-----------------------------|-------------------------------|---------------------------------------|
| Name | Function | R equivalent |
|-----------------------------|-------------------------------|---------------------------------------|
| f variance test | row_f_var(x, y) | var.test(x, y) |
|-----------------------------|-------------------------------|---------------------------------------|
Scale tests (2+ groups)
|-----------------------------|-------------------------------|---------------------------------------|
| Name | Function | R equivalent |
|-----------------------------|-------------------------------|---------------------------------------|
| bartlett's test | row_bartlett(x, g) | bartlett.test(x, g) |
| fligner-killeen test | row_flignerkilleen(x, g) | fligner.test(x, g) |
| levene's test | row_levene(x, g) | car::leveneTest(x, g, "mean") |
| brown-forsythe test | row_brownforsythe(x, g) | car::leveneTest(x, g, "median") |
|-----------------------------|-------------------------------|---------------------------------------|
Assosiation tests
|-----------------------------|-------------------------------|---------------------------------------|
| Name | Function | R equivalent |
|-----------------------------|-------------------------------|---------------------------------------|
| pearson's correlation test | row_cor_pearson(x, y) | cor.test(x, y) |
|-----------------------------|-------------------------------|---------------------------------------|
Periodicity tests
|-----------------------------|-------------------------------|---------------------------------------|
| Name | Function | R equivalent |
|-----------------------------|-------------------------------|---------------------------------------|
| cosinor | row_cosinor(x, t, period) | cosinor::cosinor.lm(x ~ t, period) |
|-----------------------------|-------------------------------|---------------------------------------|
Distribution tests
|-----------------------------|-------------------------------|---------------------------------------|
| Name | Function | R equivalent |
|-----------------------------|-------------------------------|---------------------------------------|
| jarque-bera test | row_jarquebera(x) | moments::jarque.test(x) |
|-----------------------------|-------------------------------|---------------------------------------|
Test based procedures
|-----------------------------|-------------------------------|---------------------------------------|
| Name | Function | R equivalent |
|-----------------------------|-------------------------------|---------------------------------------|
| evora | row_ievora(x, b) | --- |
|-----------------------------|-------------------------------|---------------------------------------|
Further Information
For more information please refer to the Wiki page:
See Also
Literature
Computing thousands of test statistics simultaneously in R, Holger Schwender, Tina Müller.
Statistical Computing & Graphics. Volume 18, No 1, June 2007.
Packages
CRAN:
ttests()in the Rfast package.row.ttest.stat()in the metaMA package.MultiTtest()in the ClassComparison package.bartlettTests()in the heplots package.harmonic.regression()in the HarmonicRegression package.
BioConductor:
lmFit()in the limma package.rowttests()in the genefilter package.mt.teststat()in the multtest package.row.T.test()in the HybridMTest package.rowTtest()in the viper package.lmPerGene()in the GSEAlm package.
GitHub:
