sharma.song.test {DiffXTables} | R Documentation |
Sharma-Song Test for Second-Order Difference Across Contingency Tables
Description
The test detects differential departure from independence via second-order difference in joint distributions underlying two or more contingency tables.
Usage
sharma.song.test(
tables, null.table.marginal = c("observed", "uniform"),
compensated = FALSE
)
Arguments
tables |
a list of at least two non-negative matrices or data frames representing contingency tables of the same dimensions. |
null.table.marginal |
a character string to specify marginal distributions of null tables. The options are |
compensated |
a logical value to compensate for the Cochran's condition. It is only used if |
Details
The Sharma-Song test determines whether the patterns underlying multiple input contingency tables are second-order differential. The test statistic measures differential departure form independence. Its null test statistic is proved to asymptotically follow the chi-squared distribution. For full detail of the test, see (Sharma et al. 2021).
If null.table.marginal
is set to "observed"
, the null hypothesis uses the observed marginals. The compensated
parameter, if set to TRUE
, adds a small constant to each entry of the tables to address the Cochran's condition that the expected count in any table entry is 5 or less.
If the null.table.marginal
is set to "uniform"
, the null tables are set to have uniform marginals. No longer suffering from the Cochran's condition, it detects second-order differential patterns with additional robustness.
Value
A list with class "htest
" containing the following components:
statistic |
the Sharma-Song chi-squared test statistic. |
parameter |
degrees of freedom of the chi-squared test statistic. |
p.value |
p-value of the Sharma-Song test, computed using the chi-squared distribution. |
Author(s)
Ruby Sharma and Joe Song
References
Sharma R, Kumar S, Song M (2021). “Fundamental gene network rewiring at the second order within and across mammalian systems.” Bioinformatics. doi: 10.1093/bioinformatics/btab240, https://doi.org/10.1093/bioinformatics/btab240.
See Also
cp.chisq.test
, heterogeneity.test
, strength.test
, marginal.change.test
, and
type.analysis
.
Examples
# Two second-order differential tables:
tables <- list(
matrix(c(4,0,0,
0,4,0,
0,0,4), nrow=3),
matrix(c(0,4,4,
4,0,4,
4,4,0), nrow=3)
)
sharma.song.test(tables)
# Three tables differ in the first-order but not second-order:
tables <- list(
matrix(c(2, 4, 6, 8,
3, 6, 9, 12,
4, 8, 12, 16), nrow=4),
matrix(c( 2, 1, 3, 7,
2, 1, 3, 7,
10, 5, 15, 35), nrow=4),
matrix(c(40, 16, 72, 16,
45, 18, 81, 18,
25, 10, 45, 10), nrow=4)
)
sharma.song.test(tables, null.table.marginal = "uniform")