cp.chisq.test {DiffXTables} | R Documentation |
Comparative Chi-Squared Test for Difference Across Contingency Tables
Description
Across given contingency tables, the test admits any type of differences in either the joint or marginal distributions underlying the tables.
Usage
cp.chisq.test(
tables, method=c("chisq", "nchisq", "default", "normalized"),
log.p = FALSE
)
Arguments
tables |
a list of at least two nonnegative matrices or data frames representing contingency tables of the same dimensions. |
method |
a character string to specify the method to compute the chi-squared statistic and its p-value. The default is Note: |
log.p |
logical; if |
Details
The comparative chi-squared test determines whether the patterns underlying multiple contingency tables are heterogeneous. Its null test statistic is proved to asymptotically follow the chi-squared distribution (Song et al. 2014; Zhang et al. 2015). This test is different from the heterogeneity test (Zar 2009).
Two methods are provided to compute the chi-squared statistic and its p-value. When method = "chisq"
(or "default"
), the p-value is computed using the chi-squared distribution; when method =
"nchisq"
(or "normalized"
) a normalized statistic is obtained by shifting and scaling the original chi-squared test statistic and a p-value is computed using the standard normal distribution
(George et al. 2005). The normalized test is more conservative on the degrees of freedom.
Either test statistic is minimized to zero if and only if the input tables are linearly scaled versions of each other.
The test is recommended to determine whether multiple contingency tables have the same distributions, regardless of independence of row and column variables in each table.
Value
A list with class "htest
" containing the following components:
statistic |
chi-squared test statistic if |
parameter |
degrees of freedom of the chi-squared statistic. |
p.value |
p-value of the comparative chi-squared test. By default, it is computed by the chi-squared distribution ( |
Author(s)
Joe Song
References
George EP, Hunter JS, Hunter WG, Bins R, Kirlin IV K, Carroll D (2005).
Statistics for Experimenters: Design, Innovation, and Discovery.
Wiley, New York.
Song M, Zhang Y, Katzaroff AJ, Edgar BA, Buttitta L (2014).
“Hunting complex differential gene interaction patterns across molecular contexts.”
Nucleic Acids Research, 42(7), e57.
doi: 10.1093/nar/gku086, https://doi.org/10.1093/nar/gku086.
Zar JH (2009).
Biostatistical Analysis, 5th edition.
Prentice Hall, New Jersey.
Zhang Y, Liu ZL, Song M (2015).
“ChiNet uncovers rewired transcription subnetworks in tolerant yeast for advanced biofuels conversion.”
Nucleic Acids Research, 43(9), 4393–4407.
doi: 10.1093/nar/gkv358, https://doi.org/10.1093/nar/gkv358.
See Also
The Sharma-Song test sharma.song.test
.
The heterogeneity test heterogeneity.test
.
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)
)
cp.chisq.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)
)
cp.chisq.test(tables)