Description Usage Arguments Details Value Author(s) References See Also Examples
Across given contingency tables, the test admits any type of differences in either the joint or marginal distributions underlying the tables.
1 2 3 4 | cp.chisq.test(
tables, method=c("chisq", "nchisq", "default", "normalized"),
log.p = FALSE
)
|
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 |
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 \insertCitesong2014hunting,zhang2015chinetDiffXTables. This test is different from the heterogeneity test \insertCitezar2009biostatisticalDiffXTables.
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
\insertCitegeorge2005statisticsDiffXTables. 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.
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 ( |
Joe Song
The Sharma-Song test sharma.song.test
.
The heterogeneity test heterogeneity.test
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.